/* cf-pages-v2 */
:root {
  color-scheme: dark;
  --bg: #141210;
  --ink: #f4efe6;
  --muted: #b3a89c;
  --line: rgba(244, 239, 230, 0.1);
  --accent: #ef5c34;
  --accent-ink: #fff8f4;
  --gold: #e4c17a;
  --screen: #0c1c18;
  --card: #221e1b;
  --ok: #8fd0a4;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(239, 92, 52, 0.2), transparent 52%),
    radial-gradient(720px 420px at 100% 0%, rgba(228, 193, 122, 0.1), transparent 46%),
    var(--bg);
}

button, kbd { font-family: inherit; }

.app {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: 34px;
  letter-spacing: 0.06em;
  line-height: 1.1;
  font-weight: 760;
}

h2 {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: none;
  color: var(--muted);
}

.kicker {
  color: var(--gold);
  letter-spacing: 0.18em;
  font-size: 12px;
  margin-bottom: 4px;
}

.tagline {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: auto minmax(220px, 250px);
  grid-template-areas: "stage panel";
  gap: 16px;
  align-items: start;
}

.stage { grid-area: stage; }
.panel { grid-area: panel; }
.touch { grid-area: touch; }

.stage {
  position: relative;
  display: inline-block;
  padding: 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #3d362f, #2a2521);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16) inset,
    var(--shadow);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 1;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035),
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
}

#board {
  display: block;
  background: var(--screen);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45) inset;
}

.overlay {
  position: absolute;
  inset: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(6, 14, 12, 0.82);
  padding: 16px;
}

.overlay[hidden] { display: none; }

.overlay[data-mode="paused"] { background: rgba(6, 14, 12, 0.58); }
.overlay[data-mode="gameover"] { background: rgba(6, 14, 12, 0.74); }

.overlay-card {
  width: min(100%, 240px);
  text-align: center;
}

.overlay-card h2 {
  color: var(--ink);
  font-size: 30px;
  letter-spacing: 0.04em;
  margin: 2px 0 8px;
}

.overlay-card p {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

#overlay-text { margin-bottom: 6px; }
#overlay-sub {
  min-height: 1.2em;
  color: var(--gold);
  margin-bottom: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-previews {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card, .stats, .controls {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.card { padding: 12px 12px 10px; }

.card h2 { margin-bottom: 8px; }

.mini-canvas {
  width: 100%;
  height: 76px;
  display: block;
  border-radius: 10px;
}

.mini-canvas.tall { height: 228px; }

.mini {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}

.stat {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  padding: 8px 10px 10px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stat strong.bump {
  animation: bump 0.28s ease-out;
}

@keyframes bump {
  from { color: var(--gold); transform: translateY(-1px) scale(1.06); }
  to { color: inherit; transform: none; }
}

.row-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  appearance: none;
  border: 1px solid transparent;
  background: #3a312b;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  cursor: pointer;
  line-height: 1.2;
}

button:hover { background: #4a3e36; }

button:active { transform: translateY(1px); }

button:focus { outline: none; }

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  min-width: 9em;
}

button.primary:hover { background: #ff6d45; }

button.ghost {
  background: transparent;
  border-color: var(--line);
}

button.ghost:hover { background: rgba(255, 255, 255, 0.04); }

#mute {
  background: transparent;
  border-color: var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.controls {
  margin-top: 16px;
  padding: 14px 16px 16px;
}

.controls h2 { margin-bottom: 10px; }

.controls ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 18px;
  padding: 0;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 14px;
}

.rules {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 6px;
  margin-right: 2px;
  border-radius: 6px;
  border: 1px solid rgba(244, 239, 230, 0.16);
  border-bottom-width: 2px;
  background: #161311;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

.touch {
  display: none;
  width: 100%;
  margin: 0;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.touch button {
  min-height: 52px;
  font-size: 18px;
  background: #2c2622;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch button[data-act="hard"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  max-width: 40rem;
  margin: 24px auto;
  padding: 0 16px;
}

@media (max-width: 759px) {
  .layout {
    grid-template-columns: auto minmax(132px, 168px);
    grid-template-areas:
      "stage panel"
      "touch panel";
    gap: 10px;
  }
  .card { padding: 8px; }
  .card h2 { margin-bottom: 4px; }
  .mini-canvas { height: 64px; }
  .mini-canvas.tall { height: 148px; }
  .stat { padding: 6px 8px 8px; }
  .stat strong { font-size: 20px; }
  .stat span { letter-spacing: 0.06em; }
  .row-buttons { grid-template-columns: 1fr; }
}

@media (max-width: 419px) {
  .app { width: min(640px, calc(100% - 16px)); padding-top: 14px; }
  h1 { font-size: 28px; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stage"
      "touch"
      "panel";
    justify-items: center;
  }
  .panel { width: min(100%, 420px); }
  .panel-previews {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 10px;
  }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat strong { font-size: 18px; }
  .stat span { letter-spacing: 0.02em; font-size: 11px; }
  .row-buttons { grid-template-columns: 1fr 1fr; }
  .touch { width: min(420px, 100%); }
  .touch button { padding: 10px 4px; font-size: 16px; }
}

@media (pointer: coarse) and (min-width: 760px) {
  .layout {
    grid-template-areas:
      "stage panel"
      "touch panel";
  }
  .touch { max-width: 360px; }
}

@media (pointer: coarse), (max-width: 759px) {
  .touch { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  .stage::after { display: none; }
  .stat strong.bump,
  button:active { animation: none; transform: none; }
}

