:root {
  --bg: #111418;
  --fg: #f5f3ee;
  --muted: #a3acb6;
  --line: #3a4048;
  --go: #1f9d55;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ---------- Start ---------- */

#start {
  overflow-y: auto;
  justify-content: safe center;
  gap: clamp(14px, 4vh, 32px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  text-align: center;
  touch-action: pan-y;
}

h1 {
  font-size: clamp(1.5rem, 6vmin, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.start-btn {
  font-size: clamp(2.2rem, 11vmin, 4.5rem);
  font-weight: 900;
  padding: 0.3em 1.8em;
  border: 0;
  border-radius: 999px;
  background: var(--go);
  color: #fff;
  box-shadow: 0 6px 0 #146b39;
  transition: transform 0.08s, box-shadow 0.08s;
}
.start-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #146b39; }
.start-btn:disabled { background: var(--line); color: #7d858e; box-shadow: none; cursor: default; }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 780px;
}

.chip {
  font-size: clamp(0.95rem, 3.2vmin, 1.15rem);
  font-weight: 700;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  border: 2px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.chip[aria-pressed="false"] {
  background: transparent;
  color: #6f7883;
  border-color: var(--line);
}

.rule { font-size: clamp(1rem, 3.4vmin, 1.25rem); color: var(--muted); font-weight: 600; }
.status { color: #ff8a80; font-weight: 600; }
.status:empty { display: none; }

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: underline;
  padding: 0.5em;
}

/* ---------- Credits ---------- */

#credits {
  display: block;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}
#credits .end-btn { position: sticky; top: 0; background: var(--bg); }
.credits-body { max-width: 720px; margin: 16px auto 0; }
.credits-body h2 { font-size: 1.6rem; margin-bottom: 8px; }
.credits-intro { color: var(--muted); margin-bottom: 16px; }
.credits-list { padding-left: 1.2em; line-height: 1.45; font-size: 0.95rem; }
.credits-list li { margin-bottom: 6px; overflow-wrap: anywhere; }
.credits-list a { color: var(--fg); }

/* ---------- Countdown ---------- */

#countdown { background: var(--bg); touch-action: none; }

.cd-num {
  font-size: min(62vh, 45vw);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cd-num.pop { animation: pop 0.9s ease-out; }
@keyframes pop {
  from { transform: scale(1.4); opacity: 0.15; }
  35%  { transform: scale(1);   opacity: 1; }
}

.cd-hint { font-size: clamp(1rem, 6vh, 2.2rem); font-weight: 800; color: var(--muted); }

.end-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  font-size: 1rem;
  font-weight: 700;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  border: 2px solid #5a626d;
  background: transparent;
  color: var(--fg);
}
.end-btn:active { background: #2a3037; }

/* ---------- Play ---------- */

#play {
  background: var(--bg);
  touch-action: none;
  gap: 2vh;
  padding-bottom: 6vh;
}

.photo {
  display: block;
  height: 68vh;
  max-width: 88vw;
  object-fit: contain;
  border-radius: 10px;
  pointer-events: none;
}

.name {
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  line-height: 1;
}

.play-hint {
  position: absolute;
  bottom: max(1.5vh, env(safe-area-inset-bottom));
  font-size: clamp(0.7rem, 3vh, 0.95rem);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
}

/* ---------- Portrait hint (iOS cannot lock orientation) ---------- */

.rotate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--bg);
  font-size: clamp(1.6rem, 8vw, 2.6rem);
  font-weight: 800;
  text-align: center;
  padding: 16px;
  touch-action: none;
}
.rotate-icon { width: 96px; height: 96px; color: var(--fg); animation: turn 2s ease-in-out infinite; }
@keyframes turn {
  0%, 25%  { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (orientation: portrait) {
  body.in-game .rotate { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .cd-num.pop, .rotate-icon { animation: none; }
}
