:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #6b6f76;
  --line: #d9d5cd;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --success: #15803d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
a { color: inherit; }
button { font: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem min(4vw, 2rem);
  background: rgba(255,255,255,0.86);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.brand {
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.site-nav {
  display: flex;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.site-nav a { text-decoration: none; }

.hero-play {
  padding: 1.25rem min(4vw, 2rem) 2rem;
}
.hero-copy {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 1rem;
}
.eyebrow {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 0.2rem;
}
h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4rem);
  letter-spacing: -0.06em;
  line-height: 0.95;
}
.lede {
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.25rem);
  margin: 0.75rem 0 0;
}
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 430px) minmax(240px, 320px);
  justify-content: center;
  align-items: start;
  gap: 1rem;
}
.game-card,
.app-card,
.content-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.06);
}
.game-card {
  width: min(94vw, 430px);
  padding: 0.65rem;
  margin-inline: auto;
}
.game-card.sheet-open {
  padding-bottom: 1rem;
}
.game-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.25rem 0.25rem 0.75rem;
}
#ds-misses { color: var(--ink); font-weight: 700; }
#ds-misses.miss-pop {
  animation: miss-pop 420ms ease;
}
.game-container {
  width: 100%;
  aspect-ratio: 430 / 630;
  border-radius: 14px;
  overflow: hidden;
  background: #f5f7fb;
  touch-action: manipulation;
}
.game-actions, .result-actions, .result-sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.game-actions button,
.result-actions button,
.result-sheet-actions button,
.app-button {
  border: 0;
  border-radius: 14px;
  padding: 0.8rem 0.7rem;
  background: #eef2ff;
  color: #1e3a8a;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.result-panel {
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-align: center;
}
.result-panel h2 { margin: 0 0 0.5rem; }
.result-panel p { white-space: pre-line; }
.done-copy { color: var(--muted); }
.result-actions { grid-template-columns: 1fr; }
.result-actions button[hidden] { display: none; }
.result-actions #ds-share,
.result-sheet-actions #ds-sheet-share {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #dbe2ea;
}
.result-sheet {
  display: none;
}
.result-sheet[hidden] {
  display: none;
}
.app-card {
  padding: 1rem;
  position: sticky;
  top: 82px;
}
.app-card h2 { margin: 0 0 0.5rem; }
.app-card p { color: var(--muted); }
.qr-placeholder {
  display: grid;
  place-items: center;
  width: 130px;
  height: 130px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 800;
}
.small-note { font-size: 0.8rem; }
.content-section {
  width: min(94vw, 860px);
  margin: 1rem auto;
  padding: clamp(1rem, 3vw, 2rem);
}
.content-section h2,
.page-content h1 { margin-top: 0; }
.site-footer {
  width: min(94vw, 860px);
  margin: 2rem auto;
  padding: 1rem 0 2rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-footer nav { display: flex; gap: 1rem; }

@media (max-width: 840px) {
  .play-layout { grid-template-columns: 1fr; }
  .app-card { position: static; width: min(94vw, 430px); margin-inline: auto; }
  .qr-placeholder { display: none; }
  .site-nav a:not(:first-child) { display: none; }
  .hero-play { padding-top: 0.85rem; }
  .game-card.sheet-open {
    padding-bottom: calc(8rem + env(safe-area-inset-bottom));
  }
  .game-card.sheet-open .result-panel {
    display: none;
  }
  .result-sheet:not([hidden]) {
    position: fixed;
    left: 50%;
    bottom: calc(0.65rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 30;
    display: block;
    width: min(94vw, 430px);
    padding: 0.85rem;
    border: 1px solid rgba(203, 213, 225, 0.92);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(14px);
  }
  .result-sheet-copy h2 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.15;
  }
  .result-sheet-copy p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.25;
    white-space: pre-line;
  }
  .result-sheet[data-action-count="1"] .result-sheet-actions {
    grid-template-columns: 1fr;
  }
  .result-sheet[data-action-count="2"] .result-sheet-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .result-sheet[data-action-count="3"] .result-sheet-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .result-sheet-actions {
    margin-top: 0.65rem;
  }
  .result-sheet-actions button {
    min-height: 42px;
    padding: 0.68rem 0.45rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.05;
    white-space: nowrap;
  }
  .result-sheet-actions button[hidden] {
    display: none;
  }
}

@media (max-width: 460px) {
  .game-card { width: min(94vw, 430px); border-radius: 18px; padding: 0.55rem; }
  .game-status { font-size: 0.82rem; }
  .result-sheet-actions button {
    font-size: 0.86rem;
  }
}

@keyframes miss-pop {
  0% { color: var(--ink); transform: scale(1); }
  35% { color: var(--danger); transform: scale(1.08); }
  100% { color: var(--ink); transform: scale(1); }
}
