/* Hearts & O's — Tic Tac Toe styles */
:root {
  --ttt-p1: #ff5da2;
  --ttt-p2: #7c4dff;
  --ttt-brand: #ff5da2;
  --ttt-brand-2: #9b72f5;
  --ttt-ink: #2d1b4e;
  --ttt-muted: #9b8aad;
  --ttt-card: #ffffff;
  --ttt-bg: #fff0f7;
  --ttt-radius: 16px;
  --ttt-shadow: 0 8px 28px rgba(100,0,80,.10);
  --ttt-win-glow-p1: rgba(255,93,162,.35);
  --ttt-win-glow-p2: rgba(124,77,255,.35);
  --ttt-timer-warn: #ff8800;
  --ttt-timer-danger: #ff3030;
}

body {
  background: var(--ttt-bg);
  background-image:
    radial-gradient(circle at 12% 18%, #ffe0f0 0%, transparent 38%),
    radial-gradient(circle at 88% 82%, #e8d5ff 0%, transparent 38%);
}

.ttt-title {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 800;
  text-align: center;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--ttt-p1), var(--ttt-p2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* INSTRUCTIONS */
.ttt-instructions {
  background: var(--ttt-card);
  border: 2px solid #f0d6ff;
  border-radius: var(--ttt-radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  box-shadow: var(--ttt-shadow);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.ttt-instructions summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--ttt-brand-2);
  font-size: 1rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ttt-instructions ol {
  margin-top: 10px;
  padding-left: 20px;
  line-height: 1.9;
  color: var(--ttt-ink);
  font-size: .95rem;
}
.p1c { color: var(--ttt-p1); font-weight: 700; }
.p2c { color: var(--ttt-p2); font-weight: 700; }

/* SCOREBOARD */
.ttt-scoreboard {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.ttt-player-card {
  flex: 1;
  background: var(--ttt-card);
  border-radius: var(--ttt-radius);
  padding: 14px 16px;
  box-shadow: var(--ttt-shadow);
  border: 3px solid transparent;
  transition: border-color .3s, transform .25s, box-shadow .25s;
  text-align: center;
  position: relative;
}
.ttt-player-card.active { transform: translateY(-4px); }
.ttt-player-card.p1.active {
  border-color: var(--ttt-p1);
  box-shadow: 0 10px 28px var(--ttt-win-glow-p1);
}
.ttt-player-card.p2.active {
  border-color: var(--ttt-p2);
  box-shadow: 0 10px 28px var(--ttt-win-glow-p2);
}
.player-symbol { font-size: 2rem; line-height: 1; margin-bottom: 2px; }
.player-name { font-weight: 800; font-size: .95rem; }
.ttt-player-card.p1 .player-name { color: var(--ttt-p1); }
.ttt-player-card.p2 .player-name { color: var(--ttt-p2); }
.player-score { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.ttt-player-card.p1 .player-score { color: var(--ttt-p1); }
.ttt-player-card.p2 .player-score { color: var(--ttt-p2); }
.turn-badge {
  position: absolute;
  top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--ttt-p1);
  color: #fff;
  font-weight: 800;
  font-size: .7rem;
  padding: 2px 10px;
  border-radius: 99px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.ttt-player-card.p2 .turn-badge { background: var(--ttt-p2); }
.ttt-player-card.active .turn-badge { opacity: 1; }

.ttt-draws-card {
  background: var(--ttt-card);
  border-radius: var(--ttt-radius);
  padding: 14px 12px;
  box-shadow: var(--ttt-shadow);
  text-align: center;
  border: 3px solid transparent;
  min-width: 72px;
}
.draws-label { font-size: .75rem; font-weight: 700; color: var(--ttt-muted); text-transform: uppercase; letter-spacing: .06em; }
.draws-score { font-size: 2rem; font-weight: 800; color: var(--ttt-muted); }

/* FIRST NOTICE */
.ttt-first-notice {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ttt-muted);
  margin-bottom: 12px;
  min-height: 1.4em;
}
.ttt-first-notice.p1 { color: var(--ttt-p1); }
.ttt-first-notice.p2 { color: var(--ttt-p2); }

/* TIMER */
.ttt-timer-wrap {
  text-align: center;
  margin-bottom: 16px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.timer-label { font-size: .75rem; font-weight: 700; color: var(--ttt-muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 5px; }
.timer-bar-bg { width: 100%; height: 13px; background: #f0e0f8; border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
.timer-bar { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--ttt-brand), var(--ttt-brand-2)); transition: width .9s linear, background .3s; width: 100%; }
.timer-bar.warn { background: var(--ttt-timer-warn); }
.timer-bar.danger { background: var(--ttt-timer-danger); }
.timer-num { font-size: 1.3rem; font-weight: 800; color: var(--ttt-ink); transition: color .3s; }
.timer-num.warn { color: var(--ttt-timer-warn); }
.timer-num.danger { color: var(--ttt-timer-danger); }

/* GRID */
.ttt-grid-wrap { display: flex; justify-content: center; margin-bottom: 20px; }
.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2.5vw, 14px);
  width: min(360px, 92vw);
}
.ttt-cell {
  aspect-ratio: 1/1;
  background: #ffffff;
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(32px, 10vw, 52px);
  cursor: pointer;
  box-shadow: var(--ttt-shadow);
  border: 2px solid #f0d6ff;
  transition: transform .15s, box-shadow .15s, border-color .2s, background .2s;
  user-select: none;
}
.ttt-cell:hover:not(.taken):not(.game-over) {
  transform: scale(1.06);
  border-color: #d4aaff;
  box-shadow: 0 12px 32px rgba(150,80,200,.18);
}
.ttt-cell:active:not(.taken):not(.game-over) { transform: scale(.97); }
.ttt-cell.taken { cursor: default; }
.ttt-cell.winner-p1 {
  background: linear-gradient(135deg, #fff0f7, #ffe0ef);
  border-color: var(--ttt-p1);
  box-shadow: 0 0 0 4px var(--ttt-win-glow-p1), var(--ttt-shadow);
  animation: winPulse 1s ease-in-out infinite alternate;
}
.ttt-cell.winner-p2 {
  background: linear-gradient(135deg, #f3eeff, #e8d5ff);
  border-color: var(--ttt-p2);
  box-shadow: 0 0 0 4px var(--ttt-win-glow-p2), var(--ttt-shadow);
  animation: winPulse 1s ease-in-out infinite alternate;
}
@keyframes winPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}
.ttt-cell.pop { animation: cellPop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes cellPop {
  from { transform: scale(.7); opacity: .5; }
  to   { transform: scale(1); opacity: 1; }
}
.ttt-cell.draw-end { opacity: .55; filter: grayscale(.4); }

/* CONTROLS */
.ttt-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.ttt-btn {
  font-weight: 800;
  font-size: 1rem;
  padding: 11px 28px;
  border: none;
  border-radius: 99px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  letter-spacing: .02em;
}
.ttt-btn-primary {
  background: linear-gradient(135deg, var(--ttt-brand), var(--ttt-brand-2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(180,0,100,.28);
}
.ttt-btn-secondary {
  background: #f3e8ff;
  color: var(--ttt-brand-2);
  box-shadow: 0 2px 8px rgba(120,80,200,.12);
}
.ttt-btn:hover { transform: translateY(-2px); }
.ttt-btn:active { transform: translateY(0); }

/* OVERLAY */
#overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(45,27,78,.78);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#overlay.show { display: flex; }
.overlay-card {
  background: #fff;
  border-radius: 28px;
  padding: 42px 52px;
  text-align: center;
  box-shadow: 0 28px 72px rgba(0,0,0,.28);
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
  position: relative; z-index: 101;
  max-width: 380px; width: 92%;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.65); }
  to   { opacity: 1; transform: scale(1); }
}
.overlay-emoji { font-size: 4.5rem; margin-bottom: 6px; }
.overlay-title { font-size: 2.1rem; font-weight: 800; margin-bottom: 4px; }
.overlay-title.p1c { color: var(--ttt-p1); }
.overlay-title.p2c { color: var(--ttt-p2); }
.overlay-title.drawc { color: var(--ttt-muted); }
.overlay-sub { color: var(--ttt-muted); font-size: 1rem; margin-bottom: 22px; }
.overlay-scores { display: flex; gap: 12px; justify-content: center; margin-bottom: 26px; }
.os-item { background: var(--ttt-bg); border-radius: 12px; padding: 10px 18px; font-weight: 800; }
.os-name { font-size: .8rem; color: var(--ttt-muted); margin-bottom: 2px; }
.os-num { font-size: 1.9rem; }
.os-p1 .os-num { color: var(--ttt-p1); }
.os-p2 .os-num { color: var(--ttt-p2); }
.os-draw .os-num { color: var(--ttt-muted); }
.overlay-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* CONFETTI CANVAS */
#confettiCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 99; }

@media (max-width: 420px) {
  .overlay-card { padding: 28px 22px; }
  .ttt-scoreboard { gap: 7px; }
  .ttt-player-card { padding: 12px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .ttt-cell, .ttt-btn, .ttt-player-card, .timer-bar { transition: none; animation: none; }
}
@media (prefers-color-scheme: dark) {
  body { background-image: radial-gradient(circle at 12% 18%, #2a0f2a 0%, transparent 38%), radial-gradient(circle at 88% 82%, #1a0d30 0%, transparent 38%); }
  .ttt-instructions, .ttt-player-card, .ttt-draws-card { background: #1e1030; border-color: #3d1f6e; }
  .timer-bar-bg { background: #2a1545; }
  .overlay-card { background: #1e1030; }
  .os-item { background: #120820; }
  .ttt-btn-secondary { background: #2a1545; }
  .ttt-cell { background: #1e1030; border-color: #3d1f6e; }
}
