@font-face {
  font-family: 'Big Shoulders';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/big-shoulders-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Big Shoulders';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('assets/fonts/big-shoulders-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/public-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/public-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/public-sans-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/ibm-plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/ibm-plex-mono-600.woff2') format('woff2');
}

:root {
  --bg: #FBF6EC;
  --surface: #FFFFFF;
  --surface-2: #F2E9D8;
  --ink: #2A2118;
  --ink-soft: #6B5D4C;
  --ink-faint: #9C8D78;
  --border: #E4D9C4;
  --accent: #E8A33D;
  --accent-strong: #C97C1E;
  --accent-on: #2A1B04;
  --crate: #8C5A34;
  --crate-dark: #6B4324;
  --crate-line: #D64545;
  --danger: #C0392B;
  --shadow: 0 1px 2px rgba(42,33,24,0.08), 0 16px 36px -18px rgba(42,33,24,0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140F;
    --surface: #221D16;
    --surface-2: #2C2519;
    --ink: #F3ECE0;
    --ink-soft: #C4B7A2;
    --ink-faint: #85795F;
    --border: #3A3226;
    --accent: #F0B860;
    --accent-strong: #F5C878;
    --accent-on: #241703;
    --crate: #4A3320;
    --crate-dark: #2E2013;
    --crate-line: #E8776A;
    --danger: #E8776A;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 16px 36px -18px rgba(0,0,0,0.7);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Public Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Screen management ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
}

.screen.active { display: flex; }

/* ---------- Menu ---------- */

.screen-menu {
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(232,163,61,0.16), transparent 45%),
    radial-gradient(circle at 82% 85%, rgba(140,90,52,0.14), transparent 50%),
    var(--bg);
}

.menu-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin: 0 0 14px;
}

.logo {
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 800;
  font-size: clamp(2.6rem, 13vw, 3.6rem);
  line-height: 0.94;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  text-wrap: balance;
}

.logo span { color: var(--accent-strong); }

.tagline {
  font-size: 1rem;
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.25rem;
}

.stat-label {
  font-size: 11px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border-radius: 12px;
  border: none;
  padding: 16px 20px;
  margin-bottom: 12px;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(155deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--accent-on);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-title {
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.1;
}

.btn-sub {
  font-size: 0.82rem;
  opacity: 0.75;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.link-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 0.88rem;
  text-decoration: underline;
  padding: 8px;
}

/* ---------- How to play ---------- */

.screen-howto {
  justify-content: center;
  padding: 24px;
  background: rgba(42,33,24,0.55);
  backdrop-filter: blur(2px);
}

.howto-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.howto-card h2 {
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  margin: 0 0 16px;
}

.howto-card ol {
  margin: 0 0 18px;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.howto-card li {
  font-size: 0.94rem;
  color: var(--ink-soft);
}

.howto-note {
  font-size: 0.86rem;
  color: var(--ink-faint);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 20px;
}

.howto-note b { color: var(--ink-soft); }

/* ---------- Game screen ---------- */

.screen-game {
  justify-content: flex-start;
  background: var(--bg);
  padding: 14px 16px 20px;
  gap: 10px;
}

.game-hud {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-mode {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.hud-score {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.hud-score-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.hud-score-value {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.8rem;
  color: var(--accent-strong);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#game-canvas {
  background: linear-gradient(180deg, var(--crate) 0%, var(--crate-dark) 100%);
  border-radius: 18px;
  box-shadow: var(--shadow);
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

.next-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(251,246,236,0.9);
  border-radius: 12px;
  padding: 8px 10px;
}

@media (prefers-color-scheme: dark) {
  .next-preview { background: rgba(34,29,22,0.9); }
}

.next-preview-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.next-preview-fruit {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
}

.game-hint {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin: 0;
  text-align: center;
}

/* ---------- Result screen ---------- */

.screen-result {
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.result-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.share-mock {
  width: 100%;
  background: linear-gradient(165deg, #FBE7C6 0%, #F6C97D 42%, #E8A33D 100%);
  border-radius: 18px;
  padding: 22px;
  color: #2A1B04;
  box-shadow: 0 20px 40px -18px rgba(201, 124, 30, 0.5);
}

.share-mock-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 14px;
}

.share-mock-title {
  font-family: 'Big Shoulders', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  line-height: 1;
  margin: 0 0 4px;
}

.share-mock-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  opacity: 0.8;
  margin: 0 0 18px;
}

.fruit-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-bottom: 18px;
  min-height: 12px;
}

.fruit-grid span {
  aspect-ratio: 1;
  border-radius: 50%;
  display: block;
}

.share-mock-score {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid rgba(42,27,4,0.18);
  padding-top: 14px;
}

.share-mock-score .num {
  font-family: 'IBM Plex Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 2rem;
  line-height: 1;
}

.share-mock-score .num-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
  display: block;
  margin-bottom: 3px;
}

.share-mock-cta {
  font-family: 'Public Sans', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
}

.share-caption {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 14px 0 22px;
}

.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.copy-toast {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--accent-strong);
  font-weight: 600;
  margin: 4px 0 0;
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
