/* ===== Ultimate Tic-Tac-Toe styles ===== */

.app { max-width: 560px; }
.app .header { align-items: center; }

/* Status bar */
.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  text-align: center;
  transition: background .2s, color .2s;
}
.status-bar.x-turn   { border-left: 4px solid #3498db; }
.status-bar.o-turn   { border-left: 4px solid #e74c3c; }
.status-bar.win-x    { background: #3498db; color: #fff; border-color: transparent; }
.status-bar.win-o    { background: #e74c3c; color: #fff; border-color: transparent; }
.status-bar.draw     { background: var(--btn-bg); color: #f9f6f2; border-color: transparent; }
.status-bar.thinking { opacity: 0.75; }

/* ===== Macro board ===== */
.macro-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  border: 3px solid var(--text-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  box-shadow: var(--shadow-md);
}

/* ===== Macro cell ===== */
.macro-cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border: 1.5px solid var(--text-muted);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  transition: background .2s;
}

/* Outer grid thick borders */
.macro-cell:nth-child(1),
.macro-cell:nth-child(2),
.macro-cell:nth-child(3) { border-top: none; }
.macro-cell:nth-child(1),
.macro-cell:nth-child(4),
.macro-cell:nth-child(7) { border-left: none; }
.macro-cell:nth-child(3),
.macro-cell:nth-child(6),
.macro-cell:nth-child(9) { border-right: none; }
.macro-cell:nth-child(7),
.macro-cell:nth-child(8),
.macro-cell:nth-child(9) { border-bottom: none; }

/* Active (playable) macro cell */
.macro-cell.active {
  background: color-mix(in srgb, #3498db 10%, var(--surface));
  box-shadow: inset 0 0 0 2px #3498db88;
}
body.dark .macro-cell.active {
  background: color-mix(in srgb, #3498db 15%, var(--surface));
}

/* Inactive macro cell */
.macro-cell.inactive {
  background: color-mix(in srgb, var(--text-muted) 8%, var(--surface));
  opacity: 0.6;
}

/* Won / drawn macro cell overlay */
.macro-cell.won,
.macro-cell.drawn {
  pointer-events: none;
}

.macro-winner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(26px, 8vw, 52px);
  font-weight: 900;
  z-index: 5;
  border-radius: 2px;
  animation: winner-pop .35s cubic-bezier(.3,-0.1,.3,1.4) both;
  pointer-events: none;
}
.macro-winner-overlay.x-won {
  background: rgba(52, 152, 219, 0.18);
  color: #3498db;
}
.macro-winner-overlay.o-won {
  background: rgba(231, 76, 60, 0.18);
  color: #e74c3c;
}
.macro-winner-overlay.drawn {
  background: rgba(150, 150, 150, 0.15);
  color: var(--text-muted);
  font-size: clamp(14px, 4vw, 22px);
}
@keyframes winner-pop {
  0%   { transform: scale(0) rotate(-12deg); opacity: 0; }
  70%  { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ===== Mini cells (individual squares) ===== */
.mini-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: clamp(10px, 3vw, 20px);
  font-weight: 900;
  border: 0.5px solid color-mix(in srgb, var(--text-muted) 40%, transparent);
  transition: background .12s, color .1s;
  position: relative;
  line-height: 1;
}

/* Inner grid borders — thinner */
.mini-cell:nth-child(1),
.mini-cell:nth-child(2),
.mini-cell:nth-child(3) { border-top: none; }
.mini-cell:nth-child(1),
.mini-cell:nth-child(4),
.mini-cell:nth-child(7) { border-left: none; }
.mini-cell:nth-child(3),
.mini-cell:nth-child(6),
.mini-cell:nth-child(9) { border-right: none; }
.mini-cell:nth-child(7),
.mini-cell:nth-child(8),
.mini-cell:nth-child(9) { border-bottom: none; }

.mini-cell:empty:hover,
.mini-cell.playable:empty:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  cursor: pointer;
}

.mini-cell[data-val="X"] { color: #3498db; }
.mini-cell[data-val="O"] { color: #e74c3c; }

/* Winning cells get a subtle highlight */
.mini-cell.win-line { background: color-mix(in srgb, #f1c40f 30%, transparent) !important; }
.mini-cell.win-line[data-val="X"] { background: color-mix(in srgb, #3498db 22%, transparent) !important; }
.mini-cell.win-line[data-val="O"] { background: color-mix(in srgb, #e74c3c 22%, transparent) !important; }

/* Not playable */
.macro-cell.inactive .mini-cell,
.macro-cell.won .mini-cell,
.macro-cell.drawn .mini-cell {
  cursor: not-allowed;
}

/* ===== Game-over overlay ===== */
.game-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 50;
  animation: fadein .3s ease;
}
.game-overlay[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.game-overlay-text {
  font-size: clamp(36px, 9vmin, 60px);
  font-weight: 900;
  color: var(--text-strong);
  letter-spacing: -1px;
  text-align: center;
}

/* Score boxes — highlight active player */
#score-x { transition: transform .15s, box-shadow .15s; }
#score-o { transition: transform .15s, box-shadow .15s; }
#score-x.active-player { box-shadow: 0 0 0 2px #3498db; transform: scale(1.05); }
#score-o.active-player { box-shadow: 0 0 0 2px #e74c3c; transform: scale(1.05); }

/* Mode selector — hide AI-only options in 2p mode */
body.mode-2p #who-first { display: none; }
body.mode-2p #difficulty { display: none; }

/* ===== Mobile ===== */
@media (max-width: 420px) {
  .macro-board { max-width: 98vw; }
  .app .toolbar { gap: 6px; }
  .app .toolbar .select,
  .app .toolbar .btn { font-size: 12px; padding: 6px 10px; }
}
