/* Virtual Voyagers — UI theme (light, yellow accent; based on the supplied reference)
   Layout: full-screen 3D view with floating white cards; gameplay HUD + host admin page. */
:root {
  --yellow: #F2C21B; --yellow-ink: #A57F00; --yellow-soft: #FFF3C2; --yellow-pale: #FFF8DD;
  --ink: #2B2B2B; --ink-2: #5A5A5A; --muted: #8C8C8C; --line: #ECECEC;
  --card: #FFFFFF; --page: #F7F7F4; --dark: #3A3A3A;
  --green: #22A06B; --green-soft: #DDF5E7; --red: #D93C3C; --red-soft: #FDE0E0; --grey-soft: #E6E6E6;
  --topbar-h: 84px;   /* measured from the real header by main.js */
  --radius: 18px; --shadow: 0 8px 28px rgba(30, 30, 30, .10);
  --brand: "Fredoka", "Nunito", system-ui, sans-serif; --ui: "Nunito", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page); color: var(--ink); font-family: var(--ui);
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; touch-action: manipulation; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, select, textarea, button { font: inherit; font-size: 16px; }   /* >=16px stops iOS auto-zoom on focus */
.hidden { display: none !important; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img.logo { width: auto; height: 46px; display: block; }          /* client logo (assets/brand/logo.png) */
.brand.big img.logo { height: 92px; max-width: 100%; }
.brand.mid img.logo { height: 64px; max-width: 100%; margin-bottom: 8px; }
.brand.centered { justify-content: center; } .lead.centered, .title.centered { text-align: center; }
.topbar .brand img.logo { height: 40px; }
@media (max-width: 600px) { .topbar .brand img.logo { height: 30px; } }
.brand img { width: auto; height: 52px; }
.brand .words { font-family: var(--brand); line-height: .9; }
.brand .w1 { display: block; font-weight: 700; font-size: 26px; color: var(--yellow); -webkit-text-stroke: .5px #d9a900; letter-spacing: .02em; }
.brand .w2 { display: block; font-weight: 700; font-size: 21px; color: var(--ink); letter-spacing: .06em; }
.brand.big img { width: auto; height: 84px; }
.brand.big .w1 { font-size: 44px; } .brand.big .w2 { font-size: 35px; }

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 26px; border-radius: 14px;
  background: var(--yellow); color: var(--ink); font-weight: 800; font-size: 18px; box-shadow: 0 3px 0 #d6a800; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.dark { background: var(--dark); color: #fff; box-shadow: 0 3px 0 #1f1f1f; }
.btn.ghost { background: #fff; box-shadow: inset 0 0 0 2px var(--line); }
.btn.red { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn:focus-visible, .field:focus-visible, .chip:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.field { width: 100%; height: 54px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 18px; outline: none;
  -webkit-user-select: text; user-select: text; }
.field:focus { border-color: var(--yellow); }
.field.code { text-align: center; letter-spacing: .4em; font-weight: 900; text-transform: uppercase; font-size: 24px; padding-left: calc(16px + .4em); }
.field.code::placeholder { letter-spacing: .05em; font-weight: 600; font-size: 18px; }
label.lbl { display: block; font-weight: 800; font-size: 14px; color: var(--ink-2); margin: 14px 0 6px; }
.err { color: var(--red); font-weight: 700; min-height: 22px; margin-top: 8px; font-size: 15px; }
.small { font-size: 14px; color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- overlay screens ---------- */
.screen { position: fixed; inset: 0; z-index: 30; display: flex; align-items: safe center; justify-content: center; overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(247, 247, 244, .94); }
.screen .card { width: min(560px, 100%); padding: 28px; margin: auto 0; position: relative; z-index: 1; }   /* decorative dots stay behind the card */
.dots { position: fixed; z-index: 0; width: 110px; height: 90px; pointer-events: none; opacity: .7;
  background-image: radial-gradient(var(--yellow) 2px, transparent 2.5px); background-size: 18px 18px; }
.dots.tl { left: 14px; top: 30%; } .dots.br { right: 18px; bottom: 18px; }
.center { text-align: center; }
h1.title { font-family: var(--brand); font-weight: 600; font-size: 30px; margin: 8px 0 4px; }
h1.title em { color: var(--yellow); font-style: normal; }
.lead { color: var(--ink-2); line-height: 1.5; margin: 0 0 6px; }
.bar { height: 10px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; margin: 18px 0 8px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--yellow); transition: width .2s; }

/* avatar picker */
.avatars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.avatar-opt { border-radius: 16px; padding: 10px 10px 12px; background: var(--page); box-shadow: inset 0 0 0 2px var(--line); text-align: center; font-weight: 800; }
.avatar-opt canvas { width: 100%; aspect-ratio: 1 / 1.05; display: block; border-radius: 12px; background: linear-gradient(#fff, #f2f2ee); }
.avatar-opt.on { box-shadow: inset 0 0 0 3px var(--yellow); background: var(--yellow-pale); }

/* ---------- gameplay HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .96); box-shadow: 0 2px 14px rgba(0, 0, 0, .06); }
.topbar .brand img { width: auto; height: 42px; } .topbar .brand .w1 { font-size: 20px; } .topbar .brand .w2 { font-size: 16px; }
.who { flex: 1; text-align: center; font-family: var(--brand); font-weight: 600; font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.who em { color: var(--yellow); font-style: normal; }
.tiles { display: flex; gap: 8px; }
.tile { min-width: 78px; padding: 8px 10px; border-radius: 12px; text-align: center; font-weight: 700; font-size: 13px; color: var(--ink-2); }
.tile b { display: block; font-size: 22px; font-weight: 900; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.todo { background: var(--yellow-soft); } .tile.todo b { color: var(--yellow-ink); }
.tile.ok { background: var(--green-soft); } .tile.ok b { color: var(--green); }
.tile.bad { background: var(--red-soft); } .tile.bad b { color: var(--red); }
.tile.time { background: var(--grey-soft); } .tile.time b { color: var(--ink); }
.tile.time.low b { color: var(--red); }
.tile.pts { background: var(--ink); color: #ddd; position: relative; min-width: 96px; } .tile.pts b { color: var(--yellow); font-size: 26px; }
.tile.pts.bump { animation: bump .5s ease; } @keyframes bump { 40% { transform: scale(1.12); } }
.tile.pts .plus { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); color: var(--green); font-weight: 900; font-size: 20px; animation: rise 1.2s ease-out forwards; pointer-events: none; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -6px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 26px); } }

.side { position: absolute; right: max(14px, env(safe-area-inset-right)); top: calc(var(--topbar-h) + 12px); width: 330px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100% - var(--topbar-h) - 120px); overflow: auto; }
.side .card { padding: 14px 16px; }
.side h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; font-weight: 800; }
.side h3 .ico { width: 30px; height: 30px; color: var(--yellow); }
.side h3 .tog { margin-left: auto; font-size: 26px; color: var(--yellow); font-weight: 900; line-height: 1; }
.lb { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.lb .row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: #f4f4f2; font-weight: 800; }
.lb .row.r1 { background: var(--yellow); } .lb .row.r2 { background: #ECECEC; } .lb .row.r3 { background: #FBEBC5; }
.lb .row.me { box-shadow: inset 0 0 0 2px var(--ink); }
.lb .row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .row .sc { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.medal { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 900; background: #fff; color: var(--ink-2); box-shadow: inset 0 0 0 2px #d4d4d4; }
.r1 .medal { box-shadow: inset 0 0 0 2px #b88a00; color: #8a6700; } .r3 .medal { box-shadow: inset 0 0 0 2px #e8a35a; color: #b5651d; }
.clues { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.slot { width: 44px; height: 44px; border-radius: 10px; background: #f4f4f2; display: grid; place-items: center; overflow: hidden; color: #bbb; font-weight: 900; }
.slot img { width: 100%; height: 100%; object-fit: contain; }
.slot.cur { box-shadow: inset 0 0 0 2px var(--yellow); color: var(--yellow-ink); }
.slot.pop { animation: pop .6s ease; }
@keyframes pop { 40% { transform: scale(1.3); } }
#miniWrap { position: relative; }
#minimap { width: 100%; height: auto; display: block; border-radius: 12px; margin-top: 10px; background: #f4f4f2; }

.qcard { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: min(470px, calc(100% - 28px));
  background: var(--dark); color: #fff; border-radius: 16px; padding: 18px 22px; box-shadow: var(--shadow); }
.qcard .k { color: var(--yellow); font-weight: 800; letter-spacing: .04em; font-size: 15px; text-transform: uppercase; padding-right: 46px; }   /* clear of the ? icon */
.qcard .q { font-size: clamp(18px, 2.4vw, 24px); font-weight: 800; margin: 6px 0 6px; line-height: 1.3; }
.qcard .hint { color: #ddd; font-size: 15px; margin: 4px 0; }
.qcard .earn { font-size: 14px; color: #ccc; } .qcard .earn b { color: var(--yellow); }
.qcard .qrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.skipbtn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 12px; background: #3d3d3d; color: #fff; font-weight: 800; font-size: 14px; }
.skipbtn:hover { background: #4a4a4a; } .skipbtn:disabled { opacity: .4; }
.qcard .qi { position: absolute; right: 16px; top: 14px; width: 34px; height: 34px; color: var(--yellow); }
.hintbtn { position: absolute; right: calc(max(14px, env(safe-area-inset-right)) + 60px); bottom: max(14px, env(safe-area-inset-bottom)); }
.zoomer { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.zoomer button { width: 46px; height: 46px; border-radius: 12px; background: #fff; box-shadow: var(--shadow); font-size: 26px; font-weight: 900; }
#joy { position: absolute; width: 132px; height: 132px; margin: -66px; border-radius: 50%; background: rgba(255, 255, 255, .5); box-shadow: inset 0 0 0 3px rgba(43, 43, 43, .25); display: none; }
#joy i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: var(--yellow); box-shadow: 0 3px 8px rgba(0,0,0,.25); }
#toast { position: absolute; left: 50%; top: calc(var(--topbar-h) + 14px); transform: translate(-50%, -8px); opacity: 0; transition: .25s; padding: 12px 20px; border-radius: 14px;
  background: #fff; box-shadow: var(--shadow); font-weight: 800; text-align: center; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { color: var(--green); } #toast.bad { color: var(--red); }
#toast .big { display: block; font-family: var(--brand); font-size: 24px; color: var(--ink); }
#ripple { position: absolute; width: 46px; height: 46px; margin: -23px; border-radius: 50%; border: 3px solid var(--yellow); opacity: 0; pointer-events: none; }
#ripple.go { animation: rip .45s ease-out; }
@keyframes rip { 0% { opacity: .9; transform: scale(.3); } 100% { opacity: 0; transform: scale(1.6); } }
.nightbadge { position: absolute; left: 50%; top: calc(var(--topbar-h) + 8px); transform: translateX(-50%); background: var(--ink); color: var(--yellow); padding: 6px 14px; border-radius: 99px; font-weight: 800; font-size: 14px; }
.shake { animation: shake .35s; } @keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* end screen */
.stat { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 2px solid var(--line); font-weight: 700; }
.stat b { font-weight: 900; font-size: 20px; }

/* ---------- host / admin ---------- */
#admin { position: fixed; inset: 0; z-index: 40; overflow: auto; background: var(--page); padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.ahead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.ahead .grow { flex: 1; }
.codebox { padding: 10px 20px; text-align: center; }
.codebox .c { font-family: var(--brand); font-weight: 700; font-size: clamp(34px, 5vw, 58px); letter-spacing: .14em; padding-left: .14em; line-height: 1; }
.codebox .u { font-size: 13px; color: var(--muted); max-width: 40ch; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.live { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--green); vertical-align: middle; margin-left: 6px; }
.live.off { background: var(--red); }
.bigtime { font-family: var(--brand); font-weight: 600; font-size: clamp(36px, 6vw, 72px); font-variant-numeric: tabular-nums; }
.agrid { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.agrid > .card { padding: 20px; min-width: 0; }
.agrid .field { width: 100%; max-width: 100%; box-sizing: border-box; }
.agrid h2 { margin: 0 0 6px; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 12px; background: #f4f4f2; font-weight: 800; }
.chip.on { background: var(--yellow); }
.chip:disabled, .field:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.lockmsg { margin-top: 8px; font-size: 13px; color: #6b6b6b; background: #fff8dc; border-radius: 10px; padding: 8px 10px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 2px solid var(--line); font-weight: 800; }
.switch small { display: block; font-weight: 600; color: var(--muted); }
.sw { width: 58px; height: 34px; border-radius: 99px; background: #d8d8d8; position: relative; flex: none; transition: .2s; }
.sw::after { content: ""; position: absolute; left: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.sw[aria-checked="true"] { background: var(--yellow); } .sw[aria-checked="true"]::after { left: 28px; }
.upl { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px solid var(--line); }
.upl .t { min-width: 140px; }
.upl .thumb { width: 64px; height: 44px; border-radius: 8px; background: #f4f4f2 center/contain no-repeat; flex: none; }
.upl .t { flex: 1; font-weight: 800; } .upl .t small { display: block; color: var(--muted); font-weight: 600; }
.upl input[type=file] { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.lbtable { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.lbtable th { text-align: left; color: var(--muted); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; padding: 0 12px; }
.lbtable td { background: #f4f4f2; padding: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.lbtable tr.r1 td { background: var(--yellow); } .lbtable tr.r2 td { background: #ececec; } .lbtable tr.r3 td { background: #fbebc5; }
.lbtable td:first-child { border-radius: 12px 0 0 12px; } .lbtable td:last-child { border-radius: 0 12px 12px 0; }
.lbtable .nm { display: flex; align-items: center; gap: 10px; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .side { width: 280px; } }
@media (max-width: 900px) {
  .agrid { grid-template-columns: minmax(0, 1fr); }
  .topbar { flex-wrap: wrap; row-gap: 6px; } .who { order: 3; flex-basis: 100%; font-size: 18px; }
  .tile { min-width: 62px; padding: 6px 8px; font-size: 11px; } .tile b { font-size: 18px; }
  .side { top: auto; bottom: 150px; width: 250px; }
  .side .card.collapsible:not(.open) .body { display: none; }
  .qcard { width: calc(100% - 28px - 320px); }   /* leave room for the hint button + zoom */
}
@media (max-width: 600px) { .tiles { gap: 5px; } .tile { min-width: 52px; }
  .side { display: none; } .qcard { width: calc(100% - 28px - 62px); bottom: 76px; } .hintbtn { bottom: 12px; }   /* zoom column sits beside the card */
  .zoomer { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* phones: the decorative dot patterns are hidden so they never touch the avatar picker or buttons */
@media (max-width: 600px) { .dots { display: none; } }
