@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&display=swap");

:root {
  --ink: #0b2545;
  --ink-2: #4a5f7a;
  --ink-3: #8597ad;
  --card: #ffffff;
  --line: #e3ecf4;
  --soft: #f2f7fb;
  --brand: #0a84ff;
  --brand-2: #2bd2c4;
  --cell: 94px;            /* size of one grid square */
  --gap: 16px;
  --radius: 16px;
  --shadow: 0 6px 14px -4px rgba(11, 37, 69, .28);
  --shadow-lg: 0 14px 28px -8px rgba(11, 37, 69, .35);
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html {
  min-height: 100%;
  background:
    radial-gradient(900px 500px at 15% -5%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(800px 600px at 95% 30%, rgba(80, 160, 255, .35), transparent 60%),
    linear-gradient(160deg, #7ee8f2 0%, #43cfe6 45%, #3bb8e8 100%);
  background-color: #3bb8e8;
}
body {
  font-family: var(--font);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 12px; }

.page {
  max-width: calc(var(--cell) * 12 + var(--gap) * 11 + 48px);
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: var(--gap);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--cell); padding: 0 22px 0 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  font-weight: 900; font-size: 24px; letter-spacing: -.5px;
  transition: transform .15s;
}
.brand:hover { transform: translateY(-2px); }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #ffcf3f, #ff7a45);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.brand-mark svg { width: 28px; height: 28px; }
.brand b { color: var(--brand); font-weight: 900; }

.bar {
  flex: 1; min-width: 280px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  min-height: var(--cell); padding: 14px 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.search {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 220px; max-width: 340px; height: 46px; padding: 0 16px;
  background: var(--soft); border-radius: 999px; border: 2px solid transparent;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--brand); background: #fff; }
.search svg { flex: none; color: var(--ink-3); }
.search input { border: 0; outline: 0; background: none; font: inherit; font-weight: 700; color: var(--ink); width: 100%; }
.search input::placeholder { color: var(--ink-3); font-weight: 600; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 0; height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--soft); color: var(--ink-2); font-weight: 800; font-size: 15px;
  transition: background .15s, color .15s, transform .1s;
}
.chip:hover { background: #e4eef7; color: var(--ink); }
.chip:active { transform: scale(.96); }
.chip.active { background: var(--ink); color: #fff; }

/* ---------- Tile grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--cell));
  grid-auto-rows: var(--cell);
  grid-auto-flow: dense;
  gap: var(--gap);
  justify-content: center;
}
.tile {
  position: relative; display: block; overflow: hidden;
  border-radius: var(--radius);
  background: #cfe3ef;
  box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.3,1.5,.6,1), box-shadow .18s;
  isolation: isolate;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; user-select: none; }
.tile-large { grid-column: span 2; grid-row: span 2; border-radius: calc(var(--radius) + 4px); }
.tile-xl    { grid-column: span 3; grid-row: span 3; border-radius: calc(var(--radius) + 6px); }
.tile:hover { transform: scale(1.06); box-shadow: var(--shadow-lg); z-index: 2; }
.tile-large:hover, .tile-xl:hover { transform: scale(1.03); }
.tile:hover img { transform: scale(1.04); }

.tile-title {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 26px 10px 9px;
  color: #fff; font-weight: 800; font-size: 13px; line-height: 1.2; text-align: center;
  background: linear-gradient(transparent, rgba(5, 20, 40, .78));
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s, transform .18s;
}
.tile-large .tile-title { font-size: 17px; padding-bottom: 14px; }
.tile-xl .tile-title    { font-size: 22px; padding-bottom: 18px; }
.tile:hover .tile-title, .tile:focus-visible .tile-title { opacity: 1; transform: none; }

.empty {
  grid-column: 1 / -1; grid-row: span 2;
  display: grid; place-items: center; text-align: center;
  background: rgba(255,255,255,.75); border-radius: var(--radius);
  color: var(--ink-2); font-weight: 700;
}
.empty b { display: block; color: var(--ink); font-size: 20px; font-weight: 900; }

/* ---------- Content cards ---------- */
.card {
  background: var(--card); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow);
  padding: 24px 26px;
}
.card h2 { font-size: 18px; font-weight: 900; margin: 0 0 12px; letter-spacing: -.2px; }
.card p { margin: 0 0 10px; color: var(--ink-2); font-weight: 600; }
.card p:last-child { margin-bottom: 0; }

.section-title {
  color: #fff; font-weight: 900; font-size: 22px; letter-spacing: -.3px;
  margin: 34px 0 14px; text-shadow: 0 2px 8px rgba(11,37,69,.25);
}

.site-footer {
  margin-top: 34px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  color: rgba(11,37,69,.7); font-weight: 700; font-size: 14px;
}
.site-footer a:hover { color: var(--ink); }
code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: var(--soft); padding: 2px 6px; border-radius: 6px; color: var(--ink); }

/* ---------- Game page ---------- */
.play-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) calc(var(--cell) * 2 + var(--gap));
  gap: var(--gap);
  align-items: start;
}
.play-area.theater { grid-template-columns: minmax(0, 1fr); }
.play-area.theater .side-tiles { display: none; }

.player {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.screen {
  position: relative; width: 100%;
  aspect-ratio: var(--aspect, 16/9);
  max-height: min(72vh, 760px);
  background: #0d1420;
  overflow: hidden;
}
.screen iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }

.start {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff;
  overflow: hidden;
}
.start[hidden] { display: none; }
.start.ready { cursor: pointer; }
.start-bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(1.2); transform: scale(1.1); }
.start-bg::after { content: ""; position: absolute; inset: 0; background: rgba(8, 20, 38, .45); }
.start-inner { position: relative; display: grid; justify-items: center; gap: 16px; padding: 20px; }
.start-thumb { width: clamp(90px, 18vw, 150px); aspect-ratio: 1; border-radius: 26px; box-shadow: 0 16px 40px -10px rgba(0,0,0,.55); }
.start h1 { margin: 0; font-size: clamp(22px, 3vw, 34px); font-weight: 900; letter-spacing: -.5px; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.play-btn {
  display: inline-flex; align-items: center; gap: 10px;
  border: 0; height: 56px; padding: 0 34px 0 28px; border-radius: 999px;
  background: #fff; color: var(--ink); font-weight: 900; font-size: 20px;
  box-shadow: 0 10px 24px -6px rgba(0,0,0,.45), inset 0 -4px 0 rgba(11,37,69,.1);
  transition: transform .15s;
}
.play-btn:hover { transform: scale(1.06); }
.play-btn svg { width: 22px; height: 22px; color: var(--brand); }
.start .note { max-width: 42ch; margin: 0; font-weight: 700; opacity: .9; }
.start .note code { background: rgba(255,255,255,.18); color: #fff; }

.player-bar {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 12px;
}
.player-bar img { width: 52px; height: 52px; border-radius: 14px; flex: none; }
.player-bar .t { min-width: 0; flex: 1; }
.player-bar .t b { display: block; font-size: 18px; font-weight: 900; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .t small { color: var(--ink-3); font-weight: 700; font-size: 14px; }
.icon-btns { display: flex; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; display: grid; place-items: center;
  background: var(--soft); color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: #e4eef7; color: var(--ink); }
.icon-btn.on { background: var(--ink); color: #fff; }
.icon-btn svg { width: 20px; height: 20px; }

.side-tiles {
  display: grid; grid-template-columns: repeat(2, var(--cell)); grid-auto-rows: var(--cell);
  gap: var(--gap); grid-auto-flow: dense;
}

.info-grid {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--gap); margin-top: var(--gap);
}
.info-grid .stack { display: grid; gap: var(--gap); align-content: start; }
.game-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.game-head img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); }
.game-head h1 { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -.5px; line-height: 1.15; }
.pill {
  display: inline-block; margin-top: 6px; padding: 3px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 800; color: #fff; background: var(--accent, var(--brand));
}
.lede { font-size: 18px; color: var(--ink) !important; font-weight: 700 !important; }

.controls { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.controls li { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; }
.controls li > span:last-child { color: var(--ink-2); text-align: right; }
kbd {
  display: inline-block; font-family: var(--font); font-weight: 800; font-size: 13px; color: var(--ink);
  background: var(--soft); border: 1px solid var(--line); border-bottom-width: 3px;
  padding: 3px 9px; border-radius: 8px; margin-right: 4px; white-space: nowrap;
}
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.facts div { background: var(--soft); border-radius: 12px; padding: 10px 12px; }
.facts dt { font-size: 12px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; }
.facts dd { margin: 0; font-weight: 800; }

.crumbs { display: flex; gap: 8px; color: rgba(11,37,69,.7); font-weight: 800; font-size: 14px; margin: 0 4px 12px; }
.crumbs a:hover { color: var(--ink); }

.player:fullscreen { border-radius: 0; display: flex; flex-direction: column; }
.player:fullscreen .screen { flex: 1; max-height: none; aspect-ratio: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .play-area { grid-template-columns: minmax(0, 1fr); }
  .side-tiles { grid-template-columns: repeat(auto-fill, var(--cell)); justify-content: center; }
  .info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  :root { --gap: 10px; --cell: calc((100vw - 32px - 3 * var(--gap)) / 4); --radius: 14px; }
  .page { padding: 12px 16px 30px; }
  .brand { height: 64px; font-size: 20px; padding: 0 16px 0 10px; }
  .brand-mark { width: 40px; height: 40px; }
  .bar { min-width: 100%; min-height: 0; padding: 10px; }
  .search { max-width: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -10px; padding: 0 10px; scrollbar-width: none; }
  .chip { flex: none; }
  .tile-xl { grid-column: span 4; grid-row: span 4; }
  .tile-title { opacity: 1; transform: none; font-size: 11px; padding: 18px 4px 6px; }
  .tile-small .tile-title { display: none; }
  .player-bar .t small { display: none; }
  .icon-btn { width: 40px; height: 40px; }
  .card { padding: 20px; }
  .facts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
