:root {
  --bg: #0b1020;
  --bg2: #121a33;
  --panel: rgba(20, 30, 55, 0.78);
  --gold: #f4c542;
  --ink: #1a2238;
  --text: #eaf0ff;
  --muted: #9fb0d4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #25407a 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, #070b16 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

.boot, .loading { color: var(--muted); padding: 40px; text-align: center; }

#app { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
/* the game view breaks out wider and uses more vertical space */
#app.game-route { max-width: 1500px; padding-top: 16px; padding-bottom: 24px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 36px 10px 26px; }
.hero h1 {
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: 2px;
  text-shadow: 3px 3px 0 #b9101c, 6px 6px 0 #000;
}
.hero h1 .grad {
  background: linear-gradient(#ffe27a, #f4a623);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .sub { color: var(--muted); margin-top: 12px; font-size: 16px; }

/* ---------- Game grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 26px;
}
.card {
  position: relative;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  border: 2px solid rgba(244, 197, 66, 0.35);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent, var(--gold));
  box-shadow: 0 14px 30px rgba(0, 0, 0, .45);
}
.card-art {
  height: 150px;
  display: flex; align-items: center; justify-content: center;
  background-color: #0e1530;
  background-image:
    radial-gradient(120px 80px at 50% 35%, color-mix(in srgb, var(--accent) 45%, transparent), transparent),
    linear-gradient(180deg, #1b2750, #0e1530);
  background-size: cover;
  background-position: center;
}
.card-emoji { font-size: 64px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.card-body { padding: 14px 16px 4px; flex: 1; }
.card-body h3 { font-size: 19px; }
.card-body p { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tags span {
  font-size: 11px; color: #ffe9a8;
  background: rgba(244, 197, 66, 0.14);
  border: 1px solid rgba(244, 197, 66, 0.3);
  border-radius: 999px; padding: 2px 9px;
}
.card-cta {
  padding: 12px 16px; font-weight: bold; letter-spacing: 1px;
  color: var(--ink);
  background: linear-gradient(var(--accent, #ffd968), color-mix(in srgb, var(--accent) 70%, #b9101c));
}

.foot { text-align: center; color: var(--muted); margin-top: 34px; font-size: 13px; }
.foot code, code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 6px; }

/* ---------- Game view ---------- */
.gamebar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.gamebar h2 { font-size: 22px; }
.gamebar .spacer { flex: 1; }
.back {
  cursor: pointer; color: var(--ink); font-weight: bold;
  background: var(--gold); border: none; border-radius: 10px; padding: 9px 16px;
}
.back:hover { filter: brightness(1.08); }

.gamewrap {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  align-items: start;
}
.stage {
  /* fill as much space as possible while keeping the 900:640 ratio and fitting
     within both the available width AND the viewport height */
  width: min(100%, calc((100vh - 130px) * 900 / 640));
  aspect-ratio: 900 / 640;
  margin: 0 auto;
  background: #000; border-radius: 14px; overflow: hidden;
  border: 2px solid rgba(244,197,66,.35);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.stage iframe {
  width: 100%; height: 100%; border: 0; display: block;
}
/* fullscreen: fill the screen, game letterboxes itself inside */
.stage:fullscreen {
  width: 100vw; height: 100vh; aspect-ratio: auto;
  max-width: none; border: 0; border-radius: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
.stage:fullscreen iframe { width: 100%; height: 100%; }

.board {
  background: var(--panel);
  border: 2px solid rgba(244,197,66,.35);
  border-radius: 14px; padding: 14px 16px;
}
.board h3 { color: var(--gold); font-size: 17px; margin-bottom: 10px; }
.boardlist { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.boardlist .row {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center;
  gap: 8px; padding: 7px 8px; border-radius: 8px; font-size: 14px;
}
.boardlist .row:nth-child(odd) { background: rgba(255,255,255,.04); }
.boardlist .row.podium { background: rgba(244,197,66,.12); }
.boardlist .rank { font-weight: bold; }
.boardlist .name { font-weight: bold; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; }
.boardlist .score { color: var(--gold); font-weight: bold; }
.boardlist .empty { color: var(--muted); font-size: 13px; padding: 8px; }
.board-hint { color: var(--muted); font-size: 11px; margin-top: 10px; }

@media (max-width: 760px) {
  .gamewrap { grid-template-columns: 1fr; }
}

/* ---------- Score modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 10, 24, .8);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: min(420px, 100%); text-align: center;
  background: linear-gradient(180deg, #1a244a, #121a33);
  border: 2px solid var(--gold); border-radius: 18px; padding: 26px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-burst { font-size: 46px; }
.modal h3 {
  color: var(--gold); font-size: 26px; letter-spacing: 1px; margin-top: 4px;
  text-shadow: 2px 2px 0 #b9101c;
}
.modal p { color: var(--text); margin: 12px 0 16px; line-height: 1.5; }
.modal input {
  width: 100%; text-align: center; text-transform: uppercase;
  font-size: 22px; font-weight: bold; letter-spacing: 3px;
  padding: 12px; border-radius: 12px; border: 2px solid rgba(244,197,66,.5);
  background: #0c1226; color: #fff; outline: none;
}
.modal input:focus { border-color: var(--gold); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button {
  flex: 1; cursor: pointer; font-weight: bold; font-size: 15px;
  padding: 12px; border-radius: 12px; border: none;
}
.modal-actions .ghost { background: rgba(255,255,255,.1); color: var(--text); }
.modal-actions .primary { background: linear-gradient(#ffd968, #f4a623); color: var(--ink); }
.modal-actions .primary:disabled { opacity: .6; cursor: default; }
