/* ── Tic-Tac-Toe Game Styles ─────────────────────────────── */

.hidden { display: none !important; }

.ttt-game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 24px;
  padding: 36px 28px 40px;
}

.ttt-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ttt-header h1 {
  margin-top: 10px;
  font-size: clamp(36px, 6vw, 54px);
}

.ttt-header .lead {
  margin-top: 6px;
  font-size: 18px;
}

/* ── Menu Groups ─────────────────────────────────────────── */

.ttt-menu-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.ttt-group-label {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--page-accent);
}

/* ── Mode / Type Selector ────────────────────────────────── */

.ttt-modes {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.ttt-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 110px;
  padding: 14px 18px;
  border: 1px solid rgba(94, 248, 231, 0.16);
  border-radius: 0;
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.06), rgba(255, 86, 197, 0.03)),
    rgba(255, 255, 255, 0.04);
  color: var(--page-text);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.ttt-mode-btn:hover:not(.disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 86, 197, 0.32);
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.12), rgba(255, 86, 197, 0.08)),
    rgba(255, 255, 255, 0.06);
  box-shadow: var(--page-glow-pink);
}

.ttt-mode-btn.active {
  border-color: rgba(94, 248, 231, 0.4);
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.16), rgba(255, 86, 197, 0.1)),
    rgba(255, 255, 255, 0.08);
  box-shadow: var(--page-glow-cyan);
}

.ttt-mode-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ttt-mode-icon {
  font-size: 22px;
}

.ttt-mode-label {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.ttt-mode-hint {
  font-size: 12px;
  color: var(--page-text-muted);
}

/* ── Theme Selector ──────────────────────────────────────── */

.ttt-themes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.ttt-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 56px;
  height: 44px;
  border: 1px solid rgba(94, 248, 231, 0.14);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.ttt-theme-btn:hover {
  border-color: rgba(255, 86, 197, 0.3);
  box-shadow: var(--page-glow-pink);
}

.ttt-theme-btn.active {
  border-color: rgba(94, 248, 231, 0.4);
  background: rgba(94, 248, 231, 0.1);
  box-shadow: var(--page-glow-cyan);
}

.ttt-theme-x, .ttt-theme-o {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 18px;
}

/* ── Side Switch ─────────────────────────────────────────── */

.ttt-side-switch {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.ttt-side {
  display: flex;
  gap: 16px;
}

.ttt-side-player {
  font-size: 15px;
  color: var(--page-text-muted);
}

.ttt-side-player strong {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 18px;
  color: var(--page-text);
}

.ttt-switch-btn {
  min-width: auto;
  padding: 8px 16px;
  flex-direction: row;
  gap: 6px;
}

/* ── Custom Board Settings ───────────────────────────────── */

.ttt-custom-settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  padding: 18px 20px;
  border: 1px solid rgba(94, 248, 231, 0.12);
  background: rgba(255, 255, 255, 0.03);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.ttt-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ttt-setting-label {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--page-text);
}

.ttt-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ttt-stepper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(94, 248, 231, 0.2);
  border-radius: 0;
  background: rgba(94, 248, 231, 0.08);
  color: var(--page-accent);
  font-size: 20px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: background 120ms ease;
}

.ttt-stepper-btn:hover {
  background: rgba(94, 248, 231, 0.16);
}

.ttt-stepper-value {
  min-width: 100px;
  text-align: center;
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 16px;
  color: var(--page-text);
}

/* ── Start Button ────────────────────────────────────────── */

.ttt-start-btn {
  font-size: 22px;
  min-width: 200px;
  min-height: 56px;
}

/* ── Game Top Bar ────────────────────────────────────────── */

.ttt-game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
  flex-wrap: wrap;
}

.ttt-toolbar {
  display: flex;
  gap: 8px;
}

.ttt-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(94, 248, 231, 0.16);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--page-text);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: background 120ms ease, border-color 120ms ease;
}

.ttt-icon-btn:hover {
  background: rgba(94, 248, 231, 0.1);
  border-color: rgba(94, 248, 231, 0.3);
}

.ttt-icon-btn.muted {
  color: var(--page-text-muted);
  opacity: 0.5;
}

/* ── Timer ───────────────────────────────────────────────── */

.ttt-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: 1px solid rgba(94, 248, 231, 0.12);
  background: rgba(255, 255, 255, 0.03);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.ttt-timer-label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--page-text-muted);
}

.ttt-timer-value {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: var(--page-text);
  min-width: 52px;
  transition: color 200ms ease;
}

.ttt-timer-value.warning {
  color: var(--page-accent-strong);
  animation: ttt-timer-flash 1s ease-in-out infinite;
}

@keyframes ttt-timer-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ttt-timer-bar {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ttt-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--page-accent), var(--page-accent-strong));
  transition: width 1s linear;
  border-radius: 2px;
}

/* ── Scoreboard ──────────────────────────────────────────── */

.ttt-scoreboard {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.ttt-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 72px;
  padding: 10px 16px;
  border: 1px solid rgba(94, 248, 231, 0.12);
  background: rgba(255, 255, 255, 0.03);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.ttt-score-mark {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ttt-score-x .ttt-score-mark { color: var(--ttt-x-color, var(--page-accent)); }
.ttt-score-o .ttt-score-mark { color: var(--ttt-o-color, var(--page-accent-strong)); }
.ttt-score-draw .ttt-score-mark { color: var(--page-text-muted); }

.ttt-score-value {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--page-text);
}

.ttt-score-name {
  font-size: 11px;
  color: var(--page-text-muted);
  letter-spacing: 0.06em;
}

/* ── Status ──────────────────────────────────────────────── */

.ttt-status {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: clamp(20px, 3vw, 26px);
  letter-spacing: 0.04em;
  color: var(--page-accent);
  min-height: 36px;
  transition: color 200ms ease;
}

.ttt-status.status-win {
  color: var(--page-accent-strong);
  text-shadow: 0 0 18px rgba(255, 86, 197, 0.4);
}

.ttt-status.status-draw {
  color: var(--page-accent-warm);
}

.ttt-status.status-thinking {
  animation: ttt-pulse-text 1s ease-in-out infinite;
}

@keyframes ttt-pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Board Wrapper ───────────────────────────────────────── */

.ttt-board-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* ── Board ───────────────────────────────────────────────── */

.ttt-board {
  position: relative;
  display: grid;
  gap: 5px;
  width: min(400px, 85vw);
  max-width: 400px;
}

.ttt-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 1px solid rgba(94, 248, 231, 0.18);
  border-radius: 0;
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.04), rgba(255, 86, 197, 0.02)),
    rgba(9, 16, 32, 0.7);
  color: var(--page-text);
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 120ms ease;
  -webkit-user-select: none;
  user-select: none;
  padding: 0;
  line-height: 1;
}

/* Dynamic font sizing based on board size */
.ttt-board[data-size="3"] .ttt-cell { font-size: clamp(36px, 8vw, 54px); }
.ttt-board[data-size="4"] .ttt-cell { font-size: clamp(28px, 6vw, 42px); }
.ttt-board[data-size="5"] .ttt-cell { font-size: clamp(22px, 5vw, 34px); }
.ttt-board[data-size="6"] .ttt-cell { font-size: clamp(18px, 4vw, 28px); }
.ttt-board[data-size="7"] .ttt-cell { font-size: clamp(16px, 3.5vw, 24px); }
.ttt-board[data-size="8"] .ttt-cell { font-size: clamp(14px, 3vw, 20px); }

.ttt-cell:hover:not(.taken) {
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.12), rgba(255, 86, 197, 0.06)),
    rgba(9, 16, 32, 0.8);
  border-color: rgba(94, 248, 231, 0.3);
  box-shadow: var(--page-glow-cyan);
  transform: scale(1.03);
}

.ttt-cell.taken {
  cursor: default;
}

.ttt-cell.mark-x {
  color: var(--ttt-x-color, var(--page-accent));
  text-shadow: 0 0 14px var(--ttt-x-glow, rgba(94, 248, 231, 0.35));
}

.ttt-cell.mark-o {
  color: var(--ttt-o-color, var(--page-accent-strong));
  text-shadow: 0 0 14px var(--ttt-o-glow, rgba(255, 86, 197, 0.35));
}

.ttt-cell.win-cell {
  border-color: rgba(255, 86, 197, 0.5);
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.18), rgba(255, 86, 197, 0.12)),
    rgba(9, 16, 32, 0.9);
  box-shadow: var(--page-glow-pink);
  animation: ttt-pulse 600ms ease-in-out 2;
}

@keyframes ttt-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Placement pop animation */
.ttt-cell.pop {
  animation: ttt-pop 200ms ease-out;
}

@keyframes ttt-pop {
  0% { transform: scale(0.7); opacity: 0.6; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Result Screen ───────────────────────────────────────── */

.ttt-result-scores {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.ttt-result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 100px;
  padding: 18px 24px;
  border: 1px solid rgba(94, 248, 231, 0.14);
  background: rgba(255, 255, 255, 0.04);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.ttt-result-label {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page-accent);
}

.ttt-result-value {
  font-family: "DigitFusionDisplay", "Impact", sans-serif;
  font-size: 36px;
  color: var(--page-text);
}

/* ── Exit Overlay ────────────────────────────────────────── */

.ttt-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 13, 0.85);
  backdrop-filter: blur(8px);
  animation: ttt-fade-in 200ms ease-out;
}

@keyframes ttt-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ttt-popup {
  text-align: center;
  max-width: 400px;
  padding: 36px 32px;
  border: 1px solid var(--page-surface-border);
  background:
    linear-gradient(135deg, rgba(94, 248, 231, 0.08), transparent 26%),
    var(--page-surface);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 24px 100%, 0 calc(100% - 24px));
  box-shadow: var(--page-shadow), var(--page-glow-pink);
}

.ttt-popup h2 {
  margin: 0 0 12px;
}

.ttt-popup p {
  margin: 0 0 20px;
  font-size: 16px;
}

.ttt-popup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Actions ─────────────────────────────────────────────── */

.ttt-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.ttt-btn {
  min-width: 140px;
}

/* ── Footer Links ────────────────────────────────────────── */

.ttt-footer-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 720px) {
  .ttt-game-card {
    padding: 24px 16px 28px;
    gap: 18px;
  }

  .ttt-modes {
    gap: 8px;
  }

  .ttt-mode-btn {
    min-width: 90px;
    padding: 10px 14px;
  }

  .ttt-scoreboard {
    gap: 10px;
  }

  .ttt-score {
    min-width: 60px;
    padding: 8px 12px;
  }

  .ttt-score-value {
    font-size: 22px;
  }

  .ttt-game-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .ttt-toolbar {
    justify-content: center;
  }

  .ttt-timer {
    justify-content: center;
  }
}
