:root {
  --bg: #fff7fb;
  --ink: #2a1838;
  --muted: #6d5a78;
  --pink: #ff6fa8;
  --pink-deep: #d93d7f;
  --card: #ffffff;
  --line: #f1d7e6;
  --sky: #e9f6ff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1020;
    --ink: #f6eaf2;
    --muted: #c3b0cf;
    --card: #2a1c33;
    --line: #3d2a49;
    --sky: #22182b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--pink-deep); }
.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px 12px;
}
.hero-girl { image-rendering: pixelated; flex: none; }
.hero h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); line-height: 1.1; color: var(--pink-deep); }
.hero p { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }
main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; }
.games {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}
.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: var(--pink); outline: none; }
.card img { width: 100%; height: auto; aspect-ratio: 256 / 224; image-rendering: pixelated; display: block; background: #000; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.card h2 { margin: 0 0 4px; font-size: 19px; line-height: 1.25; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 15px; flex: 1; }
.go {
  align-self: flex-start;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 6px;
}
.help { margin-top: 40px; background: var(--sky); border-radius: 6px; padding: 18px 20px; }
.help h2 { margin: 0 0 8px; font-size: 22px; }
.help h3 { margin: 8px 0 4px; font-size: 16px; }
.help p { margin: 0; color: var(--muted); font-size: 15px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 4px;
  background: var(--card);
  font: 600 13px/1.6 ui-monospace, monospace;
  text-align: center;
}
footer { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 14px; }

/* game page */
body.play { background: #1a1020; color: #f6eaf2; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: #2a1c33;
  flex: none;
}
.bar .back { color: #fff; text-decoration: none; font-weight: 700; background: var(--pink-deep); padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.bar span { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stage { flex: 1; min-height: 0; display: flex; }
#game { width: 100%; height: 100%; }
@media (max-width: 600px) { .hero { flex-direction: column; text-align: center; } .hero-girl { width: 48px; height: 96px; } }
.bar .input { margin-left: auto; font-size: 14px; color: #c3b0cf; white-space: nowrap; }
.help-btn { flex: none; width: 34px; height: 34px; border: 0; border-radius: 6px; background: #3d2a49; color: #fff; font: 700 17px system-ui, sans-serif; cursor: pointer; }
#stage { position: relative; }
.toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; background: #2a1c33; color: #fff; border: 2px solid var(--pink); border-radius: 6px; padding: 8px 14px; font-weight: 700; pointer-events: none; }
.help-dialog { max-width: min(560px, calc(100vw - 32px)); border: 2px solid var(--pink); border-radius: 6px; background: #2a1c33; color: #f6eaf2; padding: 18px 20px; }
.help-dialog::backdrop { background: rgb(0 0 0 / .6); }
.help-dialog h2 { margin: 0 0 10px; }
.help-dialog table { width: 100%; border-collapse: collapse; font-size: 15px; }
.help-dialog th, .help-dialog td { text-align: left; padding: 5px 6px; border-bottom: 1px solid #3d2a49; }
.help-dialog p { color: #c3b0cf; font-size: 14px; }
.help-dialog kbd { background: #1a1020; border-color: #3d2a49; color: #fff; }
.help-dialog button { background: var(--pink-deep); color: #fff; border: 0; border-radius: 6px; padding: 8px 18px; font-weight: 700; cursor: pointer; }
@media (max-width: 600px) { .bar .input { display: none; } .help-btn { margin-left: auto; } }
