* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: #f8f1e4;
  background:
    linear-gradient(rgba(12, 20, 28, 0.78), rgba(12, 20, 28, 0.92)),
    radial-gradient(circle at top, #2b6f8f, transparent 34%),
    #10151b;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  width: min(100%, 880px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  gap: 16px;
}

.title-block {
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
}

#status {
  min-height: 28px;
  margin: 6px 0 0;
  color: #d6c3a4;
  font-weight: 800;
}

.back-link,
#resetBtn {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #f8f1e4;
  background: rgba(22, 34, 47, 0.82);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.back-link:hover,
#resetBtn:hover {
  background: rgba(37, 83, 106, 0.9);
}

#board {
  width: min(92vw, 760px);
  aspect-ratio: 7 / 6;
  margin: 0 auto;
  padding: clamp(10px, 2vw, 18px);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: clamp(6px, 1.2vw, 12px);
  border-radius: 8px;
  background: linear-gradient(135deg, #225ea8, #103d78);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.48), inset 0 0 0 4px rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
  user-select: none;
}

.ai-toggle {
  width: fit-content;
  margin: 0 auto;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f8f1e4;
  background: rgba(22, 34, 47, 0.82);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.ai-toggle input {
  width: 18px;
  height: 18px;
  accent-color: #f0c94a;
}

.slot {
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  padding: 8%;
  background: radial-gradient(circle, #071a31 58%, rgba(255, 255, 255, 0.18) 60%, rgba(0, 0, 0, 0.38) 72%);
  cursor: pointer;
  touch-action: manipulation;
}

.disc {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: rgba(8, 20, 34, 0.82);
  box-shadow: inset 0 8px 10px rgba(255, 255, 255, 0.12), inset 0 -10px 18px rgba(0, 0, 0, 0.32);
}

.disc.red {
  background: radial-gradient(circle at 35% 28%, #ff9a8d, #c72626 68%);
}

.disc.yellow {
  background: radial-gradient(circle at 35% 28%, #fff0a1, #d8a51e 68%);
}

.winner {
  outline: 4px solid #f8df74;
  outline-offset: -4px;
}

@media (max-width: 620px) {
  .game-shell {
    padding: 14px;
    justify-content: start;
  }

  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .title-block {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .back-link,
  #resetBtn {
    grid-row: 2;
  }
}
