/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #111;
  display: flex; justify-content: center; align-items: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}

/* ── Wrapper ──────────────────────────────────────────────── */
#game-wrapper {
  position: relative;
  width:  min(430px, 100vw);
  height: min(800px, 100svh);
  background: #F5C59F;
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
@media (max-width: 430px) { #game-wrapper { border-radius: 0; } }

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 20px; z-index: 10;
}
.screen.active { display: flex; }
#start-screen, #result-screen { background: #F5C59F; }
#game-screen { background: #F5C59F; pointer-events: auto; gap: 28px; }

/* ── Turn banner ──────────────────────────────────────────── */
#turn-banner {
  font-size: 20px; font-weight: 800;
  letter-spacing: 1px; color: #3a2a1a;
  padding: 12px 32px;
  background: rgba(58,42,26,.10);
  border-radius: 50px;
  transition: opacity .2s;
}

/* ── Board ────────────────────────────────────────────────── */
#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 0 28px;
  width: 100%;
}

/* ── Cell ─────────────────────────────────────────────────── */
.cell {
  aspect-ratio: 1;
  border-radius: 22px;
  background: rgba(58,42,26,.10);
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(3rem, 14vw, 5rem);
  font-weight: 900;
  cursor: pointer;
  transition: background .15s, transform .1s;
  touch-action: manipulation;
  border: 2px solid rgba(58,42,26,.12);
}

.cell:hover:not(.taken) { background: rgba(58,42,26,.18); }
.cell:active:not(.taken) { transform: scale(.93); }
.cell.taken { cursor: default; }

.cell.x-mark { color: #3a2a1a; }
.cell.o-mark { color: #C4956A; }

.cell.winner {
  background: rgba(196,149,106,.3);
  border-color: #C4956A;
  animation: winPulse .6s ease infinite alternate;
}
@keyframes winPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.05); }
}

/* ── Logo ─────────────────────────────────────────────────── */
.logo {
  font-size: 5rem; line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(58,42,26,.3));
  animation: logoBounce 2s ease-in-out infinite;
}
@keyframes logoBounce {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ── Typography ───────────────────────────────────────────── */
.title {
  font-size: 52px; font-weight: 900;
  letter-spacing: -3px; color: #3a2a1a;
  text-align: center;
}
.subtitle {
  font-size: 18px; line-height: 1.5;
  color: #7a5a3a; text-align: center;
}
.subtitle strong { color: #3a2a1a; }

/* ── Score block ──────────────────────────────────────────── */
.score-block {
  background: rgba(0,0,0,.08);
  border-radius: 20px;
  padding: 16px 32px;
  display: flex; flex-direction: row; gap: 24px;
  text-align: center; align-items: center;
}
.score-row {
  display: flex; flex-direction: column; align-items: center;
}
.score-row.small { gap: 2px; }
.score-lbl {
  font-size: 11px; font-weight: 700;
  letter-spacing: 4px; color: #9a7a5a;
}
.score-val {
  font-size: 64px; font-weight: 900;
  line-height: 1; letter-spacing: -3px;
  color: #3a2a1a;
}
.score-val.sm { font-size: 44px; }
.score-val.accent { color: #C4956A; font-size: 44px; }

/* ── Button ───────────────────────────────────────────────── */
.btn {
  padding: 18px 52px;
  border: none; border-radius: 50px;
  background: #3a2a1a; color: #F5C59F;
  font-size: 17px; font-weight: 800;
  letter-spacing: 2px; cursor: pointer;
  transition: transform .1s, background .15s;
  touch-action: manipulation;
}
.btn:hover  { background: #5a4030; }
.btn:active { transform: scale(.95); }
