:root {
  color-scheme: light;
  --ink: #07334d;
  --accent: #006fbb;
  --paper: #fcfffe;
  --mint: #83fae7;
  --lift: 0 5px 12px #07334d30;
  --gap: clamp(8px, 1.1vw, 16px);
  --radius: clamp(10px, 1.25vw, 17px);
  font-family: "Trebuchet MS", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--mint);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body:has(dialog[open]) { overflow: hidden; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a, button, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #124a85; outline-offset: 3px; }
svg { display: block; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.backdrop { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell { container-type: inline-size; width: min(100% - 2 * clamp(12px, 4.7vw, 70px), 1310px); margin: var(--gap) auto 0; }
.board {
  --columns: 10;
  --unit: calc((100cqw - (var(--columns) - 1) * var(--gap)) / var(--columns));
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  grid-auto-rows: var(--unit);
  grid-auto-flow: dense;
  gap: var(--gap);
}

.brand-tile, .game-tile {
  min-width: 0;
  aspect-ratio: 1;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--lift);
}
.brand-tile { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.wordmark {
  display: grid;
  place-content: center;
  justify-items: center;
  align-content: center;
  padding: 4px;
  gap: 2px;
  text-align: center;
  text-decoration: none;
  font-weight: 900;
  font-size: clamp(9px, 1.15vw, 15px);
  line-height: 1.05;
  border-radius: var(--radius) var(--radius) 0 0;
}
.wordmark svg { width: clamp(19px, 2.3vw, 31px); height: auto; }
.wordmark span { font-size: clamp(9px, 0.98vw, 13px); white-space: nowrap; }
.tile-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #e4eef4; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  color: var(--accent);
  border: 0;
  background: transparent;
}
.icon-button:hover { background: #e7f6ff; }
.icon-button svg, .search-bar > svg, .action svg {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile-actions button:first-child { border-radius: 0 0 0 var(--radius); }
.tile-actions button:last-child { border-radius: 0 0 var(--radius) 0; border-left: 1px solid #e4eef4; }
.tile-actions span { font-size: 10px; font-weight: 900; }

.game-tile { position: relative; display: block; overflow: hidden; isolation: isolate; text-decoration: none; background: var(--cover); }
.game-tile img, .stage-cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.game-tile img { position: absolute; inset: 0; border-radius: inherit; }
.game-tile[data-game="minesweeper"] img { transform: scale(1.68); }
.game-tile[data-game="parallel-world-cup"] img { object-position: 30% center; }
.game-tile[data-game="sonic"] img { object-position: 60% center; transform: scale(1.23); transform-origin: 60% 42%; }
.game-tile[data-game="tennis"] img { object-position: 68% center; }
.game-tile[data-game="guzheng"] img { object-position: 78% center; }
.game-tile[data-game="scrapshot"] img { object-position: 83% center; }
.game-tile[data-game="snake"] img { object-position: 65% center; }
.game-tile[data-game="vc"] img { object-position: 68% center; }
.game-tile[data-game="tideborn"] img { object-position: 76% center; }
.game-tile[data-game="wukong"] img { object-position: 70% center; }
.board .large { grid-column: span 2; grid-row: span 2; }
.board .hero { grid-column: span 3; grid-row: span 3; }
.game-label {
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(transparent, #041a2de8);
  color: white;
  padding: 25px 8px 8px;
  font-size: clamp(11px, 1.12vw, 15px);
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  opacity: 0;
}
.game-tile:hover, .game-tile:focus-visible { z-index: 2; box-shadow: 0 8px 16px #07334d55; }
.game-tile:hover .game-label, .game-tile:focus-visible .game-label, .result-grid .game-label { opacity: 1; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .game-tile, .game-label { transition: transform 130ms ease-out, opacity 130ms ease-out; }
  .game-tile:hover { transform: translateY(-3px); }
}
@media (hover: none) { .game-label { opacity: 1; } }

.browse { margin-top: clamp(24px, 4vw, 48px); padding: clamp(16px, 3vw, 30px); border-radius: var(--radius); background: #effffaca; }
.browse-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.browse-heading span { color: #365d6a; font-size: .875rem; font-weight: 700; }
h2, h3 { margin: 0 0 12px; font-weight: 900; line-height: 1.15; }
h2 { font-size: clamp(20px, 2.25vw, 30px); }
.categories { display: flex; flex-wrap: wrap; gap: 8px; }
.category {
  min-height: 44px;
  border: 1px solid #a2ded7;
  border-radius: 24px;
  padding: 5px 15px;
  background: var(--paper);
  font-weight: 800;
}
.category:hover { border-color: var(--ink); }
.category[aria-pressed="true"] { color: white; background: var(--ink); border-color: var(--ink); }
.category-results { margin-top: 22px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 106px), 1fr)); gap: var(--gap); }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 22px; padding: 24px 0; color: #244d5c; font-size: .875rem; font-weight: 700; }
.notice { padding: 12px; background: var(--paper); border-radius: var(--radius); }

.search-dialog {
  inset: 0 auto 0 0;
  height: 100%;
  max-height: 100%;
  width: min(690px, 100%);
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--mint);
  box-shadow: 10px 0 40px #07334d26;
}
.search-dialog::backdrop { background: #072d49aa; }
.search-inner { padding: clamp(14px, 3vw, 30px); }
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 0 8px 0 18px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  color: var(--accent);
}
.search-bar:focus-within { outline: 3px solid #1675b8; }
.search-bar input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  min-height: 52px;
  font-weight: 800;
  color: var(--ink);
  font-size: 1.125rem;
}
.search-bar input::placeholder { color: #547081; }
.search-bar button { min-width: 44px; border-radius: 50%; }
.search-content { margin-top: 20px; }
.search-categories { margin-bottom: 24px; }
.search-content h2 { font-size: 1.35rem; }
.search-content .result-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 103px), 1fr)); }
.empty { grid-column: 1 / -1; margin: 0; padding: 15px; border-radius: var(--radius); background: #effffa; }

.player-layout { display: grid; grid-template-columns: minmax(75px, 106px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.player-rail { display: grid; gap: var(--gap); }
.game-shell { overflow: hidden; border-radius: var(--radius); background: var(--paper); box-shadow: var(--lift); }
.stage { display: grid; position: relative; width: 100%; aspect-ratio: 16 / 9; isolation: isolate; background: #062945; overflow: hidden; }
.stage:fullscreen { width: 100%; height: 100%; aspect-ratio: auto; }
.stage iframe, .stage-cover { width: 100%; height: 100%; border: 0; position: absolute; inset: 0; }
.stage-cover { object-fit: cover; }
.stage-cover img { opacity: .63; }
.stage-cover::after { content: ""; position: absolute; inset: 0; background: #001a30a0; }
.launcher { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; color: #fff; }
.launcher strong { font-size: clamp(20px, 3vw, 42px); text-align: center; text-shadow: 0 2px 12px #000a; }
.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 7px 12px;
  border: 0;
  border-radius: 10px;
  background: #e4f5ff;
  color: #005b9a;
  font-weight: 800;
  text-decoration: none;
}
.action:hover { background: #ccecff; }
.action.primary { background: #faffff; color: var(--ink); padding-inline: 20px; }
.action.primary:hover { background: #a9ffed; }
.action.primary:focus-visible { outline-color: #a9ffed; }
.player-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px; }
.player-meta h2 { margin: 0 auto 0 0; font-size: clamp(18px, 2vw, 25px); }
.player-meta .action { font-size: .875rem; }
.player-meta .action[disabled] { cursor: default; opacity: .58; }
.player-meta .game-status:empty { display: none; }
.game-status { flex-basis: 100%; margin: 0; font-size: .875rem; }
.game-summary { margin: 16px 0 0; padding: 16px; background: #effffada; border-radius: var(--radius); }
.game-summary p { margin: 0; line-height: 1.5; }
.related { margin-top: 24px; }

@media (max-width: 1060px) { .board { --columns: 8; } }
@media (max-width: 780px) {
  .board { --columns: 6; }
  .board .hero { grid-column: span 2; grid-row: span 2; }
  .tile-actions svg { width: 17px; height: 17px; }
}
@media (max-width: 555px) {
  .board { --columns: 4; }
  .board .large:not([data-game="scrapshot"]):not([data-game="guzheng"]) { grid-column: span 1; grid-row: span 1; }
  .wordmark { padding: 2px; }
  .wordmark svg { width: 21px; }
  .player-layout { display: block; }
  .player-rail { display: flex; align-items: center; margin-bottom: var(--gap); }
  .player-rail .brand-tile { width: 88px; height: 86px; }
  .player-rail .game-tile { flex: 1; max-width: 86px; }
  .stage { aspect-ratio: 4 / 3; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 87px), 1fr)); }
}
@media (max-width: 360px) {
  .board { --columns: 3; }
  .player-meta .action { padding-inline: 8px; }
  .player-meta .action svg { width: 17px; height: 17px; }
}
.stage.with-controls:not(:fullscreen) { aspect-ratio: auto; container-type: inline-size; }
.stage.with-controls:not(:fullscreen) iframe {
  position: static;
  display: block;
  height: calc(min(56.25cqw, 528.75px) + 210px);
}
.stage.with-board:not(:fullscreen) iframe { height: 615px; }
@media (max-width: 630px) {
  .stage.with-board:not(:fullscreen) iframe { height: 665px; }
}
