/* Elephant Trail - giao diện chung */
:root {
  --forest: #1f4d36; --forest-d: #153626; --leaf: #3f9b5f; --gold: #f2b233;
  --cream: #f7f1e3; --ink: #1d2a22; --muted: #6c7a70; --red: #c8443a; --card: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", Roboto, Arial, Helvetica, sans-serif; color: var(--ink); background: var(--cream); }
button, input, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: #dfe7dc; color: var(--ink); }
button.primary { background: var(--leaf); color: #fff; font-weight: 600; }
button.gold { background: var(--gold); color: #3a2a00; font-weight: 700; }
button.danger { background: var(--red); color: #fff; }
button.ghost { background: transparent; border: 1px solid #c9d3c6; }
button:disabled { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=password], input[type=number], select {
  padding: 10px 12px; border: 1px solid #c9d3c6; border-radius: 10px; background: #fff; width: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.brand { font-weight: 800; letter-spacing: .3px; color: var(--forest); }

/* ---------- Trang đơn giản (trang chủ, vào đội) ---------- */
.center-page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #1f4d36, #2f6b49 55%, #a8843a); }
.panel { background: var(--card); border-radius: 18px; padding: 26px 22px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); text-align: center; }
.panel h1 { margin: 6px 0 4px; font-size: 26px; color: var(--forest); }
.panel p { margin: 6px 0 14px; line-height: 1.5; }
.panel img.hero { width: 150px; height: auto; }
.panel .row { display: flex; gap: 8px; margin-top: 10px; }
.panel button { width: 100%; padding: 13px; font-size: 17px; }
.err { color: var(--red); min-height: 22px; margin-top: 8px; font-size: 14px; }

/* ---------- Màn chơi ---------- */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #dfe7dc; }
#top { background: var(--forest); color: #fff; padding: 8px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#top .t-team { font-weight: 700; font-size: 16px; }
#top .t-role { font-size: 12px; background: rgba(255,255,255,.16); padding: 3px 9px; border-radius: 999px; }
#top .t-right { margin-left: auto; display: flex; gap: 10px; align-items: center; font-weight: 700; }
#top .t-time { font-variant-numeric: tabular-nums; background: var(--gold); color: #3a2a00; padding: 3px 10px; border-radius: 8px; }
#top button { padding: 5px 10px; background: rgba(255,255,255,.16); color: #fff; font-size: 13px; }
#map { flex: 1; min-height: 0; z-index: 1; }
#bottom { background: #fff; border-top: 1px solid #cfd8cc; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
#inv { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.chip { flex: none; background: #eef3ec; border-radius: 999px; padding: 5px 11px; font-size: 14px; white-space: nowrap; }
.chip b { margin-left: 3px; }
.chip.zero { opacity: .45; }
.chip.follow { background: #fff1cf; font-weight: 700; }
#hint { font-size: 14px; color: var(--muted); padding: 4px 2px 6px; line-height: 1.4; }
#acts { display: flex; flex-direction: column; gap: 6px; max-height: 34vh; overflow-y: auto; }
#acts button { text-align: left; padding: 12px 14px; font-size: 16px; }
#toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 3000; background: #1d2a22; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: 88vw; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
#toast.bad { background: var(--red); }

.cover { position: fixed; inset: 0; z-index: 2000; background: rgba(21,54,38,.93); color: #fff; display: flex;
  align-items: center; justify-content: center; padding: 22px; text-align: center; }
.cover .box { max-width: 420px; width: 100%; }
.cover h2 { margin: 0 0 8px; font-size: 24px; color: var(--gold); }
.cover p { line-height: 1.55; margin: 8px 0; }
.cover .rolebox { background: rgba(255,255,255,.1); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.cover table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.cover td { padding: 7px 6px; border-bottom: 1px solid rgba(255,255,255,.15); text-align: left; }
.cover tr.mine td { color: var(--gold); font-weight: 700; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2100; background: #fff; border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); max-height: 80vh; overflow: auto; }
.sheet h3 { margin: 0 0 4px; font-size: 20px; }
.sheet .head { display: flex; gap: 12px; align-items: center; }
.sheet .head img { width: 96px; height: auto; }
.sheet ul { list-style: none; padding: 0; margin: 10px 0; }
.sheet li { padding: 7px 0; border-bottom: 1px solid #eef1ec; display: flex; justify-content: space-between; }
.sheet li.ok span:last-child { color: var(--leaf); font-weight: 700; }
.sheet li.no span:last-child { color: var(--red); font-weight: 700; }
.sheet .btns { display: flex; gap: 8px; margin-top: 10px; }
.sheet .btns button { flex: 1; padding: 13px; font-size: 16px; }
.scrim { position: fixed; inset: 0; z-index: 2050; background: rgba(0,0,0,.35); }

/* Biểu tượng trên bản đồ */
.mk { background: none; border: 0; }
.mk-e img { width: 100%; height: 100%; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.mk-i { font-size: 22px; line-height: 28px; text-align: center; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk-g { font-size: 30px; line-height: 40px; text-align: center; background: var(--forest); border: 3px solid var(--gold);
  border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.mk-me { background: #1a73e8; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }
.mk-mate { background: #8e44ad; color: #fff; border: 2px solid #fff; border-radius: 50%; font-size: 12px; font-weight: 700;
  text-align: center; line-height: 22px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.mk-mate.off { background: #999; }
.mk-c { background: var(--gold); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 5px rgba(0,0,0,.5); }

/* ---------- Camera ---------- */
#cam { position: fixed; inset: 0; z-index: 4000; background: #000; overflow: hidden; touch-action: none; }
#cam video, #cam img.still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cam img.voi { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; pointer-events: none; }
#cam .bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; }
#cam .bar.topbar { top: 0; background: linear-gradient(rgba(0,0,0,.55), transparent); color: #fff; font-size: 14px; text-align: center; }
#cam .bar.botbar { bottom: 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.6)); flex-wrap: wrap; }
#cam button { background: rgba(255,255,255,.2); color: #fff; padding: 10px 14px; }
#cam button.shutter { width: 74px; height: 74px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.5); padding: 0; }
#cam button.gold { background: var(--gold); color: #3a2a00; }

/* ---------- Trang người dẫn ---------- */
.adm { max-width: 1180px; margin: 0 auto; padding: 16px; }
.adm header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.adm header h1 { margin: 0; font-size: 22px; color: var(--forest); }
.adm header .sp { margin-left: auto; display: flex; gap: 8px; }
.card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 10px; font-size: 17px; color: var(--forest); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.grid label { font-size: 13px; color: var(--muted); display: block; }
.grid label input, .grid label select { margin-top: 4px; }
.rowb { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
#amap { height: 520px; border-radius: 12px; z-index: 1; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tools button.on { background: var(--forest); color: #fff; }
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.status.setup { background: #e8ecf5; color: #44506b; }
.status.running { background: #d7f2de; color: #17663a; }
.status.ended { background: #f6dcd9; color: #8f2c25; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #edf0ea; font-size: 15px; vertical-align: top; }
table.list th { font-size: 13px; color: var(--muted); }
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.team { border: 1px solid #e2e8df; border-radius: 12px; padding: 12px; }
.team h3 { margin: 0 0 6px; font-size: 16px; display: flex; justify-content: space-between; gap: 8px; }
.team .qr { text-align: center; margin: 6px 0; }
.team .qr svg { width: 150px; height: 150px; }
.team .link { font-size: 12px; word-break: break-all; color: var(--muted); }
.team .pl { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-top: 6px; }
.team .pl select { width: auto; padding: 4px 6px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; flex: none; }
.dot.on { background: var(--leaf); }
.msg { font-size: 14px; min-height: 20px; }
.msg.bad { color: var(--red); }
.msg.good { color: var(--leaf); }

/* ---------- Bảng xếp hạng ---------- */
.board { min-height: 100%; background: linear-gradient(170deg, #153626, #1f4d36 60%, #3a5a2c); color: #fff; padding: 24px; }
.board header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.board h1 { margin: 0; font-size: 34px; color: var(--gold); }
.board .time { margin-left: auto; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; background: var(--gold); color: #3a2a00; padding: 4px 18px; border-radius: 12px; }
.board .cols { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.2fr); gap: 22px; }
@media (max-width: 900px) { .board .cols { grid-template-columns: 1fr; } }
.rank { background: rgba(255,255,255,.08); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 14px; font-size: 22px; }
.rank .n { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.rank.first { background: rgba(242,178,51,.25); }
.rank.first .n { background: var(--gold); color: #3a2a00; }
.rank .name { flex: 1; font-weight: 700; }
.rank .cnt { font-weight: 800; font-size: 28px; }
.rank .sub { font-size: 14px; opacity: .75; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.wall figure { margin: 0; background: rgba(255,255,255,.08); border-radius: 10px; overflow: hidden; }
.wall img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.wall figcaption { font-size: 13px; padding: 6px 8px; }
