/* BLC Guesser – styles (mobile-first) */
:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --danger: #dc2626;
  --navy: #0f172a;
  --radius: 14px;
  --topbar: 54px;
  --shadow: 0 6px 24px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 1rem; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar); z-index: 1000;
  display: flex; align-items: center; gap: .5rem; padding: 0 .75rem;
  background: var(--navy); color: #fff;
}
.brand { font-weight: 800; font-size: 1.1rem; color: #fff; text-decoration: none; white-space: nowrap; }
.spacer { flex: 1; }
.pill {
  background: rgba(255, 255, 255, .12); border-radius: 999px; padding: .25rem .65rem;
  font-weight: 700; font-size: .9rem; white-space: nowrap;
}
.pill-timer { font-variant-numeric: tabular-nums; }
.pill-timer.low { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.btn-lang {
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 8px; padding: .3rem .55rem; font-weight: 700; cursor: pointer;
}

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 10px; padding: .75rem 1.1rem; font-size: 1rem; font-weight: 700;
  cursor: pointer; text-decoration: none; color: #fff; background: var(--brand);
  transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); }
.btn-accent { background: var(--accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.topbar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .4); }
.btn-small { padding: .4rem .7rem; font-size: .85rem; }
.btn-big { width: 100%; padding: 1rem; font-size: 1.1rem; margin-top: 1rem; }
.btn-round {
  position: absolute; z-index: 5; left: 12px; bottom: 12px; width: 46px; height: 46px; padding: 0;
  border-radius: 50%; background: #fff; color: var(--ink); font-size: 1.4rem; box-shadow: var(--shadow);
}

input, select {
  width: 100%; font: inherit; padding: .7rem .8rem; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; margin-bottom: .9rem; font-weight: 600; }
label > span:first-child { display: block; margin-bottom: .3rem; }
label small, .privacy, .muted-msg { color: var(--muted); font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 .9rem; }
legend { font-weight: 600; margin-bottom: .4rem; padding: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; }
.form-error { color: var(--danger); font-weight: 600; margin: .8rem 0 0; }
.code-input { text-transform: uppercase; letter-spacing: .4em; font-size: 1.6rem; font-weight: 800; text-align: center; }
.row3 { display: grid; grid-template-columns: 1fr; gap: 0 .8rem; }

.card { background: var(--card); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }

/* ---------- Home ---------- */
.home-main { max-width: 560px; margin: 0 auto; padding: calc(var(--topbar) + 1rem) 1rem 2rem; }
.home-main .card { margin-bottom: 1rem; }
.home-main .btn { width: 100%; }
.tagline { text-align: center; font-size: 1.1rem; color: var(--muted); margin: .4rem 0 1rem; }
.privacy { text-align: center; font-size: .85rem; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chips.muted { opacity: .4; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .45rem .8rem;
  font: inherit; font-size: .9rem; cursor: pointer; color: var(--ink);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chip-n { font-size: .75rem; opacity: .75; margin-left: .2rem; }

/* ---------- Game views ---------- */
body.game { overflow: hidden; }
#views { position: fixed; top: var(--topbar); left: 0; right: 0; bottom: 0; }
.view { position: absolute; inset: 0; display: none; overflow: auto; }
.view.active { display: block; }
/* The play view stays laid out (only invisible) so Street View keeps its size between rounds */
#v-play { display: block; visibility: hidden; overflow: hidden; }
#v-play.active { visibility: visible; }
.center-msg { text-align: center; margin-top: 30vh; color: var(--muted); }

/* Lobby */
.lobby { display: grid; gap: 1rem; padding: 1rem; max-width: 1000px; margin: 0 auto; }
.lobby-join { text-align: center; }
.join-line { margin: .2rem 0; }
.big-code { font-size: 4.5rem; font-weight: 900; letter-spacing: .15em; color: var(--brand); line-height: 1.1; margin: .3rem 0; }
.qr { width: 170px; margin: .4rem auto .8rem; }
.qr svg { width: 100%; height: auto; display: block; }
.settings { color: var(--muted); margin-top: 1rem; }
.count { color: var(--muted); font-weight: 400; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.player-list li {
  display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem;
  background: var(--bg); border-radius: 10px; font-weight: 600;
}
.player-list li.offline { opacity: .5; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.offline .dot { background: var(--muted); }
.tag { font-size: .75rem; font-weight: 500; color: var(--muted); }
.kick {
  margin-left: auto; border: 0; background: transparent; color: var(--danger);
  font-size: 1rem; cursor: pointer; padding: .2rem .4rem;
}

/* Play */
#pano { position: absolute; inset: 0; background: #1e293b; }
#nmpz-shield { position: absolute; inset: 0; z-index: 3; cursor: not-allowed; }
.guessbox {
  position: absolute; z-index: 6; display: none; flex-direction: column;
  background: #fff;
}
.guessbox.open { display: flex; inset: 0; }
#guessmap { flex: 1; min-height: 0; }
.guessbox-actions { display: flex; gap: .5rem; padding: .6rem; }
.guessbox-actions .btn { flex: 1; }
#btn-map-open {
  position: absolute; z-index: 5; left: 50%; transform: translateX(-50%); bottom: 16px;
  padding: .9rem 1.6rem; box-shadow: var(--shadow); border-radius: 999px;
}

.overlay {
  position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .55); padding: 1rem;
}
.overlay-card { text-align: center; max-width: 360px; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 1rem; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Map pins */
.pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--brand); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.pin-true { font-size: 32px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.gpin { position: relative; }
.gpin::before {
  content: ''; position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: #64748b; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
.gpin span {
  position: absolute; left: 10px; top: -11px; white-space: nowrap; background: #fff; color: var(--ink);
  font: 700 12px/1 system-ui, sans-serif; padding: 4px 6px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.gpin.me::before { background: var(--brand); }
.gpin.me span { background: var(--brand); color: #fff; }

/* Presenter */
.present { text-align: center; padding: 2rem 1rem; }
.present-round { font-size: 1.6rem; font-weight: 800; color: var(--muted); }
.present-timer { font-size: 7rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; margin: .5rem 0; }
.present-timer.low { color: var(--danger); }
.present-progress { font-size: 1.6rem; font-weight: 700; margin-bottom: 1.5rem; }
.player-grid {
  list-style: none; padding: 0; margin: 0 auto; max-width: 1000px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem;
}
.player-grid li { background: #fff; border-radius: 10px; padding: .7rem; font-weight: 700; font-size: 1.1rem; box-shadow: var(--shadow); }
.player-grid li.done { background: #dcfce7; }
.player-grid li.offline { opacity: .5; }

/* Reveal */
#v-reveal.active { display: flex; flex-direction: column; overflow: hidden; }
#revealmap { flex: 0 0 45%; }
.reveal-panel { flex: 1; overflow: auto; padding: 1rem; background: #fff; }
.it-was { margin: 0; color: var(--muted); }
.reveal-country { font-size: 1.8rem; }
.result-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.result-list li {
  display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 8px; background: var(--bg);
}
.result-list li.me { outline: 2px solid var(--brand); }
.result-list li.nog { opacity: .6; }
.rank { width: 1.6rem; font-weight: 800; color: var(--muted); text-align: center; }
.result-list .pname { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.result-list .pts { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Final */
.final { max-width: 640px; margin: 0 auto; padding: 1.2rem 1rem 2rem; text-align: center; }
.final .card { margin-top: 1rem; text-align: left; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: .6rem; margin: 1.5rem 0 .5rem; }
.step { background: #fff; border-radius: 12px 12px 0 0; padding: .8rem .5rem; width: 31%; box-shadow: var(--shadow); }
.step-1 { min-height: 170px; background: #fef3c7; }
.step-2 { min-height: 135px; }
.step-3 { min-height: 110px; }
.medal { font-size: 2.2rem; }
.step .pname { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .pts { color: var(--muted); font-weight: 700; }
.summary-list { margin: 0; padding-left: 1.4rem; }
.final-actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 150%); z-index: 2000;
  background: var(--navy); color: #fff; padding: .8rem 1.1rem; border-radius: 10px; max-width: 90vw;
  box-shadow: var(--shadow); transition: transform .25s, opacity .25s; text-align: center;
  opacity: 0; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Larger screens ---------- */
@media (min-width: 701px) {
  .mobile-only { display: none !important; }
  .row3 { grid-template-columns: repeat(3, 1fr); }
  .lobby { grid-template-columns: 1fr 1fr; align-items: start; padding: 1.5rem; }
  .big-code { font-size: 6rem; }

  /* Small map in the corner that grows on hover */
  .guessbox {
    display: flex; right: 16px; bottom: 16px; width: 340px; height: 260px;
    border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); opacity: .85;
    transition: width .2s, height .2s, opacity .2s;
  }
  .guessbox.expanded { width: min(60vw, 820px); height: min(62vh, 600px); opacity: 1; }

  #v-reveal.active { flex-direction: row; }
  #revealmap { flex: 1; }
  .reveal-panel { flex: 0 0 380px; box-shadow: var(--shadow); }
}
@media (max-width: 480px) {
  .hide-sm { display: none; }
  .pill { padding: .2rem .5rem; font-size: .8rem; }
  .big-code { font-size: 3.6rem; }
  .present-timer { font-size: 4.5rem; }
}
