:root {
  --bg: #0c0d10;
  --bar: #13141a;
  --surface: #181a21;
  --text: #f3f3f5;
  --muted: #9ea2ad;
  --line: #262832;
  --accent: #c6f84a;
  --accent-ink: #12160a;
  --placeholder: linear-gradient(135deg, #22242d, #31343f);
  --radius: 16px;
  --gap: 12px;
  --gutter: clamp(16px, 1.2vw, 24px);
  --topbar: 76px;
  --foot: 56px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; }
h1, h2 { margin: 0; font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 calc(var(--gutter) + 12px);
  background: var(--bar);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%);
}
.search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1b1d24;
  border: 1px solid #30333d;
  border-radius: 12px;
  padding: 0 16px;
  width: min(340px, 42vw);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 16px; padding: 10px 0; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; }

/* Cover tiles: the art fills the tile, a genre pill on top, text over a dark fade */
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--placeholder);
  isolation: isolate;
  min-height: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition: box-shadow 0.2s, transform 0.2s;
}
.tile:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.tile-media { position: absolute; inset: 0; z-index: -1; background: var(--placeholder); }
.tile-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; }
.tile:hover .tile-media img { transform: scale(1.04); }
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 22%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.35) 40%, transparent 62%);
}
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 14px 14px 0; }
.tile-tag {
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(12, 13, 16, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}
.inputs { display: flex; gap: 6px; margin-left: auto; }
.input { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(12, 13, 16, 0.62); border: 1px solid rgba(255, 255, 255, 0.16); }
.input svg, .input-label svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-body { display: flex; flex-direction: column; align-items: flex-start; padding: 18px 20px; color: #fff; min-width: 0; max-width: 100%; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55); }
.start { text-shadow: none; }
.tile-title { font-size: clamp(20px, 1.7vw, 30px); font-weight: 800; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-desc { font-size: 19px; margin-top: 6px; opacity: 0.95; }
.tile-meta { font-size: 15px; margin-top: 4px; opacity: 0.9; font-variant-numeric: tabular-nums; }
.start {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  font-weight: 800;
  font-size: 18px;
  border-radius: 12px;
  padding: 10px 28px 10px 24px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(198, 248, 74, 0.25);
}
.start::before { content: ""; border-left: 13px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.tile:hover .start, .start:hover { background: #d6ff6e; }

/* First screen: a large featured game, a tall cover, two small covers and the dice */
.poster {
  height: calc(100svh - var(--topbar) - var(--foot));
  min-height: 520px;
  max-height: 1000px;
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr;
  grid-template-rows: 1fr 1fr auto;
  gap: var(--gap);
  padding: var(--gap) var(--gutter) 0;
}
.poster .hero { grid-row: 1 / -1; }
.poster .tall { grid-row: 1 / -1; }
.poster .hero .tile-top { padding: 22px 24px 0; }
.poster .hero .tile-tag { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 15px; }
.poster .hero .tile-body { padding: 0 32px 32px; }
.poster .hero .tile-title { font-size: clamp(36px, 3.6vw, 64px); }
.poster .tall .tile-title { font-size: clamp(22px, 1.9vw, 32px); }
.poster[data-cells="1"] { grid-template-columns: 1fr; }
.poster[data-cells="3"] { grid-template-columns: 2.2fr 1fr; grid-template-rows: 1fr auto; }
.poster[data-cells="4"] { grid-template-columns: 2.2fr 1fr 1fr; grid-template-rows: 1fr auto; }
.poster[data-cells="4"] .small { grid-row: 1; }
.poster[data-cells="4"] .dice, .poster[data-cells="5"] .dice { grid-column: 3; }

.dice {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  min-height: 92px;
}
.dice::before { display: none; }
.dice-face {
  flex: none;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  width: 52px;
  height: 52px;
  padding: 9px;
  border-radius: 12px;
  background: var(--accent);
  transition: transform 0.4s ease;
}
.dice-face i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); place-self: center; }
.dice-face i:nth-child(1) { grid-area: 1 / 1; }
.dice-face i:nth-child(2) { grid-area: 1 / 3; }
.dice-face i:nth-child(3) { grid-area: 2 / 2; }
.dice-face i:nth-child(4) { grid-area: 3 / 1; }
.dice-face i:nth-child(5) { grid-area: 3 / 3; }
.dice:hover .dice-face { transform: rotate(90deg); }
.dice-text { display: flex; flex-direction: column; min-width: 0; }
.dice-title { font-size: 20px; font-weight: 800; }
.dice-meta { color: var(--muted); font-size: 14px; }

.poster-foot {
  height: var(--foot);
  margin-top: var(--gap);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 calc(var(--gutter) + 16px);
  background: var(--bar);
  color: #cfd1d6;
}
.poster-foot .copyright { font-size: 14px; }
.more { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform 0.2s; }
.more:hover svg { transform: translateY(3px); }

/* Nothing published yet */
.soon {
  height: calc(100svh - var(--topbar) - var(--foot) - var(--gap));
  min-height: 360px;
  margin: var(--gap) var(--gutter) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  text-align: center;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 42%, rgba(198, 248, 74, 0.08), transparent 40%),
    var(--placeholder);
}
.soon-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  background: var(--accent);
  clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%);
}
.soon p { margin: 0; }
.soon-title { font-size: clamp(28px, 4vw, 48px); font-weight: 700; }
.soon-note { color: var(--muted); font-size: 16px; }

/* All games */
.all { padding: 40px var(--gutter) 24px; scroll-margin-top: 8px; }
.filters { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; margin-bottom: 20px; padding: 0 4px; }
.filters h2 { font-size: 28px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { background: #1b1d24; border: 1px solid #30333d; border-radius: 10px; padding: 5px 18px; cursor: pointer; }
.chip:hover { border-color: #6b6e78; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.grid .tile { aspect-ratio: 3 / 4; }
.grid .tile-title { font-size: 22px; }
.grid .tile-meta { font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }
.empty a { text-decoration: underline; }

.footer { color: var(--muted); font-size: 14px; text-align: center; padding: 16px var(--gutter) 28px; }
body[data-page="home"] .footer { display: none; }

/* Play page */
.back { display: none; width: 28px; height: 28px; margin-right: -8px; }
.back svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; }
.page { flex: 1; width: 100%; padding: 18px calc(var(--gutter) + 12px) 16px; }
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 26%); gap: 32px; align-items: start; }
.play-main { display: flex; flex-direction: column; min-width: 0; }
.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - var(--topbar) - 120px);
  margin: 0 auto;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}
.stage:fullscreen { max-height: none; border-radius: 0; aspect-ratio: auto; }
.game-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #000; }
.stage-cover { position: absolute; inset: 0; display: grid; place-items: center; }
.stage-art, .stage-media { position: absolute; inset: 0; }
.stage-media { background: var(--placeholder); }
.stage-media img { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.55) saturate(1.1); }
.stage-start { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; text-align: center; }
.stage-start .start { margin: 0; font-size: 22px; padding: 14px 40px 14px 34px; }
.stage-note { margin: 0; font-size: 16px; background: rgba(12, 13, 16, 0.7); border-radius: 10px; padding: 6px 14px; }
.stage-bar { display: flex; align-items: center; gap: 10px; padding: 12px 2px 0; }
.inputs-line { display: flex; gap: 14px; margin-right: auto; color: var(--muted); font-size: 14px; }
.input-label { display: inline-flex; align-items: center; gap: 6px; }
.bar-btn { background: #1b1d24; border: 1px solid #30333d; border-radius: 10px; padding: 6px 16px; cursor: pointer; }
.bar-btn:hover:not(:disabled) { border-color: var(--accent); }
.bar-btn:disabled { opacity: 0.45; cursor: default; }
.info { padding-top: 14px; }
.title { font-size: clamp(28px, 2.3vw, 38px); line-height: 1.2; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.meta-part { padding: 3px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); color: #d4d6db; }
.meta-part:first-child { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.info-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; margin-top: 8px; }
.info h2 { font-size: 18px; margin-top: 10px; margin-bottom: 6px; }
.description { margin: 0; font-size: 16px; color: #e4e5e8; }
.controls { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.controls li { display: flex; align-items: center; gap: 12px; }
.keys { display: inline-flex; gap: 4px; min-width: 96px; }
kbd {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 7px;
  background: #22242d;
  border: 1px solid #3a3d48;
  box-shadow: 0 2px 0 #3a3d48;
}
.does { color: #d4d6db; }

.side { display: flex; flex-direction: column; gap: 12px; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.side-head h2 { font-size: 22px; }
.side-all { color: var(--muted); }
.side-all:hover { color: var(--accent); }
.others { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.others .tile { aspect-ratio: 16 / 7; }
.others .tile-top { padding: 10px 10px 0; }
.others .tile-body { padding: 10px 16px 12px; }
.others .tile-title { font-size: 22px; }
.others .tile-meta { font-size: 14px; }
body[data-page="play"] .footer { text-align: left; background: var(--bar); padding: 12px calc(var(--gutter) + 12px); margin-top: 12px; }

/* Tablet */
@media (max-width: 1100px) {
  .poster, .poster[data-cells] { grid-template-columns: 1fr 1fr; grid-template-rows: auto; height: auto; max-height: none; }
  .poster .hero { grid-column: 1 / -1; grid-row: auto; aspect-ratio: 16 / 9; }
  .poster .tall { grid-row: span 2; }
  .poster .small { aspect-ratio: 4 / 3; }
  .poster[data-cells="4"] .small { grid-row: auto; }
  .poster .dice, .poster[data-cells] .dice { grid-column: 1 / -1; }
  .poster[data-cells="2"] .dice, .poster[data-cells="3"] .dice { grid-column: auto; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .play-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .others { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phone */
@media (max-width: 720px) {
  :root { --topbar: 60px; --gap: 10px; --gutter: 12px; --radius: 14px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .brand { font-size: 23px; gap: 8px; }
  .brand-mark { width: 17px; height: 17px; }
  .search { flex: 1; width: auto; max-width: 210px; padding: 0 12px; }
  .search input { font-size: 15px; padding: 8px 0; }
  .poster .hero { aspect-ratio: 4 / 5; }
  .poster .hero .tile-top { padding: 14px 14px 0; }
  .poster .hero .tile-body { padding: 0 20px 22px; }
  .poster .hero .tile-title { font-size: 34px; }
  .poster .tall { grid-row: auto; aspect-ratio: 3 / 4; }
  .poster .small { aspect-ratio: 3 / 4; }
  .poster[data-cells="5"] .small:last-of-type { display: none; }
  .tile-desc { font-size: 16px; }
  .tile-meta { font-size: 13px; }
  .start { margin-top: 14px; font-size: 16px; padding: 8px 22px 8px 18px; }
  .tile-top { padding: 10px 10px 0; }
  .tile-tag { font-size: 12px; padding: 5px 8px; }
  .input { width: 24px; height: 24px; }
  .tile-body { padding: 12px 14px; }
  .tile-title { font-size: 19px; }
  .poster .tall .tile-title { font-size: 19px; }
  .dice { min-height: 76px; }
  .poster-foot { grid-template-columns: 1fr; justify-items: center; height: auto; padding: 14px 16px; background: transparent; margin-top: 0; }
  .poster-foot .copyright { display: none; }
  body[data-page="home"] .footer { display: block; }
  .all { padding-top: 16px; }
  .filters { gap: 12px; }
  .filters h2 { font-size: 22px; width: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .chip { white-space: nowrap; padding: 4px 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid .tile-title { font-size: 17px; }
  .grid .tile-meta { font-size: 12px; }
  .grid .inputs { display: none; }
  body[data-page="play"] .search { display: none; }
  .back { display: block; }
  .page { padding: 0 16px 16px; }
  .stage { margin: 0 -16px; width: calc(100% + 32px); border-radius: 0; }
  .stage-start .start { font-size: 18px; padding: 10px 28px 10px 24px; }
  .stage-bar { padding-top: 10px; }
  .info-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .title { font-size: 28px; }
  .others { grid-template-columns: minmax(0, 1fr); }
  body[data-page="play"] .footer { background: none; border-top: 1px solid var(--line); margin: 16px 16px 0; padding: 14px 0 24px; }
}
