/* Atlas Arena — dark space theme */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #060a14;
  --bg2: #0b1224;
  --panel: rgba(13, 20, 40, .88);
  --card: #101a33;
  --card-hi: #16234a;
  --ink: #e8ecf7;
  --ink-dim: #8fa0c4;
  --accent: #4fc3f7;
  --accent2: #ffd54f;
  --good: #4caf50;
  --bad: #ef5350;
  --line: rgba(120, 150, 220, .18);
  --radius: 14px;
  font-size: 16px;
}
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 800px at 70% -10%, #0d1731 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.chip {
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  padding: .45em 1em; border-radius: 999px; font-size: .9rem; transition: all .15s;
  white-space: nowrap;
}
.chip:hover { background: var(--card-hi); border-color: var(--accent); }
.chip.on { background: var(--accent); color: #04223a; border-color: var(--accent); font-weight: 600; }
.chip.gold { border-color: var(--accent2); }
.chip.gold.on { background: var(--accent2); color: #3a2a00; }

/* ---------- hub ---------- */
.hub-head { text-align: center; padding: 2.2rem 1rem .6rem; }
.logo { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: .18em; font-weight: 800;
  background: linear-gradient(90deg, #7fd4ff, #fff, #ffd54f);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(79,195,247,.35)); }
.logo span { font-weight: 300; }
.tagline { color: var(--ink-dim); margin-top: .3rem; }
.hub-links { margin-top: .9rem; display: flex; gap: .6rem; justify-content: center; }
.hub-grid {
  flex: 1; overflow-y: auto; display: grid; gap: .9rem; padding: 1.2rem clamp(1rem, 6vw, 5rem) 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-content: start;
}
.mode-card {
  background: linear-gradient(160deg, var(--card) 0%, #0c1428 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0; text-align: left; transition: transform .15s, border-color .15s, box-shadow .15s;
  display: block; /* flex layout lives on .mc-inner: <button> won't grow with flex content */
}
.mode-card .mc-inner {
  display: flex; flex-direction: column; gap: .35rem;
  min-height: 118px; height: 100%; padding: 1rem 1.1rem;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 30px rgba(79,195,247,.15); }
.mode-card .mc-icon { font-size: 1.6rem; }
.mode-card .mc-name { font-weight: 700; font-size: 1.05rem; }
.mode-card .mc-desc { color: var(--ink-dim); font-size: .82rem; line-height: 1.35; }
.mode-card .mc-best { color: var(--accent2); font-size: .75rem; margin-top: auto; }
.hub-foot { text-align: center; color: var(--ink-dim); font-size: .75rem; padding: .5rem 0 .9rem; }

/* ---------- game layout ---------- */
.game-top {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--line); background: rgba(6,10,20,.6); z-index: 5;
}
.game-title { font-weight: 700; font-size: 1.05rem; }
.game-status { margin-left: auto; color: var(--accent2); font-variant-numeric: tabular-nums; font-weight: 600; }
.game-body { flex: 1; display: flex; min-height: 0; }
#globe-wrap { position: relative; flex: 1; min-width: 0; }
#globe, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
#fx { pointer-events: none; }
.globe-tip {
  position: absolute; pointer-events: none; background: rgba(8,14,30,.92);
  border: 1px solid var(--line); border-radius: 8px; padding: .3em .65em;
  font-size: .85rem; z-index: 4; white-space: nowrap;
}
.panel {
  width: min(390px, 38vw); min-width: 300px; border-left: 1px solid var(--line);
  background: var(--panel); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; padding: 1rem; gap: .8rem; overflow-y: auto;
}
@media (max-width: 760px) {
  .game-body { flex-direction: column; }
  .panel { width: 100%; min-width: 0; max-height: 46vh; border-left: none; border-top: 1px solid var(--line); }
}
.panel h2 { font-size: 1rem; }
.panel .prompt { color: var(--ink-dim); font-size: .9rem; line-height: 1.45; }
.panel .big-prompt { font-size: 1.05rem; line-height: 1.5; }

/* ---------- autocomplete ---------- */
.ac-wrap { position: relative; }
.ac-input {
  width: 100%; background: #0a1122; color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: .65em .9em; font-size: 1rem; outline: none;
}
.ac-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,195,247,.15); }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: #0c1428; border: 1px solid var(--line); border-radius: 10px;
  max-height: 260px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.ac-item { padding: .5em .8em; display: flex; gap: .5em; align-items: baseline; cursor: pointer; }
.ac-item.sel, .ac-item:hover { background: var(--card-hi); }
.ac-item .ac-sub { color: var(--ink-dim); font-size: .78rem; margin-left: auto; }

/* ---------- guess rows ---------- */
.guess-list { display: flex; flex-direction: column; gap: .4rem; }
.guess-row {
  display: flex; align-items: center; gap: .6rem; background: #0a1122;
  border: 1px solid var(--line); border-radius: 10px; padding: .45em .7em;
  animation: rowIn .25s ease;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }
.guess-row .g-flag { font-size: 1.2rem; }
img.flag { width: 1.35em; height: 1em; object-fit: cover; border-radius: 2px; vertical-align: -0.12em; box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.guess-row .g-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-row .g-info { color: var(--ink-dim); font-size: .82rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.guess-row .g-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.guess-row.correct { border-color: var(--good); background: rgba(76,175,80,.12); }

/* ---------- misc ---------- */
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.primary {
  background: var(--accent); color: #04223a; font-weight: 700; border-radius: 10px;
  padding: .6em 1.3em; transition: filter .15s;
}
.primary:hover { filter: brightness(1.15); }
.ghost { border: 1px solid var(--line); border-radius: 10px; padding: .55em 1.1em; }
.ghost:hover { border-color: var(--accent); }
.hint-box {
  background: #0a1122; border: 1px solid var(--line); border-left: 3px solid var(--accent2);
  border-radius: 10px; padding: .6em .8em; font-size: .92rem; line-height: 1.45; animation: rowIn .3s ease;
}
.hint-box .h-tag { color: var(--accent2); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; display: block; margin-bottom: .15em; }
.divider { border-top: 1px solid var(--line); margin: .2rem 0; }
.center { text-align: center; }
.result-banner { text-align: center; padding: .8rem; border-radius: var(--radius); animation: pop .35s ease; }
.result-banner.win { background: rgba(76,175,80,.15); border: 1px solid var(--good); }
.result-banner.lose { background: rgba(239,83,80,.12); border: 1px solid var(--bad); }
.result-banner .rb-big { font-size: 1.3rem; font-weight: 800; }
.result-banner .rb-sub { color: var(--ink-dim); font-size: .85rem; margin-top: .2rem; }
@keyframes pop { 0% { transform: scale(.85); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: scale(1); } }

.silhouette-box { background: #0a1122; border: 1px solid var(--line); border-radius: var(--radius); display: flex; justify-content: center; padding: .5rem; }
.silhouette-box canvas { max-width: 100%; }

/* ---------- stats / trophies ---------- */
.scroll-body { flex: 1; overflow-y: auto; padding: 1.2rem clamp(1rem, 5vw, 4rem); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .9rem; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat-card h3 { font-size: 1rem; margin-bottom: .5rem; }
.stat-kv { display: flex; justify-content: space-between; font-size: .88rem; padding: .18em 0; }
.stat-kv .k { color: var(--ink-dim); }
.stat-kv .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-chart { display: flex; flex-direction: column; gap: 3px; margin-top: .5rem; }
.bar-row { display: flex; align-items: center; gap: .5em; font-size: .78rem; }
.bar-row .b-label { width: 2em; text-align: right; color: var(--ink-dim); }
.bar-row .b-bar { height: 14px; background: linear-gradient(90deg, var(--accent), #7fd4ff); border-radius: 3px; min-width: 2px; }
.bar-row .b-n { color: var(--ink-dim); }
.trophy { display: flex; gap: .8rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: .6rem; }
.trophy.locked { opacity: .38; filter: grayscale(1); }
.trophy .t-icon { font-size: 1.7rem; }
.trophy .t-name { font-weight: 700; }
.trophy .t-desc { color: var(--ink-dim); font-size: .82rem; }
.trophy .t-date { margin-left: auto; color: var(--accent2); font-size: .75rem; white-space: nowrap; }

/* ---------- modal / toast ---------- */
#modal-root:empty, #toast-root:empty { display: none; }
.modal-veil { position: fixed; inset: 0; background: rgba(3,6,14,.72); display: flex; align-items: center; justify-content: center; z-index: 90; animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 1.4rem 1.6rem; width: min(480px, 92vw); max-height: 86vh; overflow-y: auto; animation: pop .25s ease; }
.modal h2 { margin-bottom: .3rem; }
.modal .m-sub { color: var(--ink-dim); font-size: .9rem; margin-bottom: 1rem; }
.opt-group { margin: .8rem 0; }
.opt-group .og-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-dim); margin-bottom: .4rem; }
.opt-group .btn-row { gap: .45rem; }
#toast-root { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 95; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { background: var(--card-hi); border: 1px solid var(--accent); border-radius: 999px; padding: .5em 1.2em; font-size: .9rem; animation: toastIn .25s ease; box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.toast.gold { border-color: var(--accent2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #1c2a52; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= iPad / touch ================= */
html, body { overscroll-behavior: none; }
#globe, #fx { touch-action: none; }
canvas { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, .chip, .ac-item, .mode-card { touch-action: manipulation; }
.silhouette-box canvas { touch-action: none; }
/* iOS standalone: respect the notch/home-bar */
.game-top { padding-top: calc(.6rem + env(safe-area-inset-top, 0px)); padding-left: calc(1rem + env(safe-area-inset-left, 0px)); }
.hub-head { padding-top: calc(2.2rem + env(safe-area-inset-top, 0px)); }
.panel { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px) + var(--kb, 0px)); padding-right: calc(1rem + env(safe-area-inset-right, 0px)); }
.hub-grid { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
/* finger-first sizing (44pt targets) on coarse pointers */
@media (pointer: coarse) {
  .chip { padding: .65em 1.2em; font-size: .95rem; }
  .primary, .ghost { padding: .8em 1.4em; min-height: 44px; }
  .ac-input { padding: .8em 1em; min-height: 48px; }
  .ac-item { padding: .8em .9em; min-height: 44px; align-items: center; }
  .guess-row { padding: .6em .8em; }
  .mode-card .mc-inner { min-height: 132px; }
  #nv-byline { padding: 10px 6px; }
}
/* fat-finger candidate chooser */
#tap-chooser {
  position: absolute; z-index: 40; background: rgba(10, 17, 34, .97);
  border: 1px solid var(--accent); border-radius: 12px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.6); min-width: 190px;
  animation: pop .18s ease;
}
#tap-chooser .tc-head { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); padding: .5em .9em .2em; }
#tap-chooser button {
  display: flex; align-items: center; gap: .6em; width: 100%; text-align: left;
  padding: .7em 1em; font-size: 1rem; min-height: 44px; color: var(--ink);
}
#tap-chooser button:hover, #tap-chooser button:active { background: var(--card-hi); }

/* ================= naV Studios branding ================= */
#nv-ident {
  position: fixed; inset: 0; z-index: 200; background: #070a16;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 1; transition: opacity .45s;
}
#nv-ident.nv-out { opacity: 0; pointer-events: none; }
#nv-ident svg { width: min(52vw, 460px); }
#nv-ident .nv-e { stroke-dasharray: 400; stroke-dashoffset: 400; animation: nv-draw .7s ease-out forwards; }
#nv-ident .nv-e1 { animation-delay: .05s; } #nv-ident .nv-e2 { animation-delay: .2s; }
#nv-ident .nv-e3 { animation-delay: .3s; } #nv-ident .nv-e4 { animation-delay: .45s; }
#nv-ident .nv-e5 { animation-delay: .6s; }
#nv-ident .nv-d { opacity: 0; transform-origin: center; transform-box: fill-box; animation: nv-bloom .45s ease-out forwards; }
#nv-ident .nv-d1 { animation-delay: .9s; } #nv-ident .nv-d2 { animation-delay: 1.1s; }
#nv-ident .nv-d3 { animation-delay: 1.3s; } #nv-ident .nv-d4 { animation-delay: 1.5s; }
#nv-ident .nv-word { opacity: 0; animation: nv-fade .5s ease-out 1.65s forwards; }
#nv-ident.nv-short .nv-e { animation-duration: .35s; }
#nv-ident.nv-short .nv-e1 { animation-delay: 0s; } #nv-ident.nv-short .nv-e2 { animation-delay: .06s; }
#nv-ident.nv-short .nv-e3 { animation-delay: .12s; } #nv-ident.nv-short .nv-e4 { animation-delay: .2s; }
#nv-ident.nv-short .nv-e5 { animation-delay: .28s; }
#nv-ident.nv-short .nv-d { animation-duration: .25s; }
#nv-ident.nv-short .nv-d1 { animation-delay: .4s; } #nv-ident.nv-short .nv-d2 { animation-delay: .5s; }
#nv-ident.nv-short .nv-d3 { animation-delay: .6s; } #nv-ident.nv-short .nv-d4 { animation-delay: .7s; }
#nv-ident.nv-short .nv-word { animation-delay: .8s; }
@keyframes nv-draw { to { stroke-dashoffset: 0; } }
@keyframes nv-bloom { 0% { opacity: 0; transform: scale(0.2); } 60% { opacity: 1; transform: scale(1.5); } 100% { opacity: 1; transform: scale(1); } }
@keyframes nv-fade { to { opacity: 1; } }
#nv-presents { font-size: .72rem; letter-spacing: .38em; color: var(--ink-dim); text-transform: uppercase; margin-bottom: .35rem; }
#nv-presents b { color: #8fa3d9; font-weight: 600; }
#nv-byline {
  position: absolute; right: 18px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  font-size: 11.5px; letter-spacing: 1px; color: var(--ink-dim); opacity: .55;
  cursor: pointer; z-index: 5; user-select: none;
}
#nv-byline:hover { opacity: .95; }
#screen-hub { position: relative; }
#nv-credits {
  position: fixed; inset: 0; z-index: 210; background: #070a16d8;
  display: flex; align-items: center; justify-content: center; animation: fadeIn .18s ease;
}
#nv-credits-card {
  background: linear-gradient(180deg, #141b33, #0c1122); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px 40px 22px; text-align: center; max-width: min(92vw, 440px);
  animation: pop .25s ease;
}
#nv-credits-card svg { width: min(60vw, 300px); }
#nv-credits h2 { letter-spacing: 3px; margin-top: 6px; }
#nv-credits .nv-ver { color: var(--ink-dim); font-size: 12.5px; margin-top: 2px; }
#nv-credits .nv-line { color: var(--ink); margin-top: 10px; letter-spacing: 1px; }
#nv-credits .nv-story { color: var(--accent2); font-style: italic; margin-top: 6px; }
#nv-credits .nv-hint { font-size: 11.5px; margin-top: 10px; color: var(--ink-dim); }
#nv-credits #nv-close { margin-top: 14px; }
#nv-credits .nv-tappable { cursor: pointer; pointer-events: all; }
#nv-credits .nv-ping { animation: nv-bloom .4s ease-out; }
#nv-credits .nv-chordglow svg { filter: drop-shadow(0 0 26px #ffd24a88); transition: filter .3s; }
