/* =========================================================
   Super Fun Tic-Tac-Toe - Ultimate Tablet, PWA & Kids Edition Stylesheet
   Designed for Kids: Tactile 3D Buttons, Vibrant Colors, Neural TTS & Gashapon!
   ========================================================= */

:root {
  --font-family: 'Fredoka', 'Quicksand', 'Comic Sans MS', cursive, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Dreamy playful pastel palette */
  --bg-gradient: linear-gradient(135deg, #bbf2f6 0%, #fed8e5 45%, #e0e7ff 100%);
  --card-bg: rgba(255, 255, 255, 0.96);
  --card-shadow: 0 24px 60px rgba(0, 0, 0, 0.08), 0 8px 20px rgba(255, 64, 129, 0.06);
  
  --p1-color: #ff2a6d; /* Coral Rose */
  --p1-light: #fff0f5;
  --p1-border: #ff6584;
  --p1-shadow: #fda4af;
  
  --p2-color: #0284c7; /* Electric Sky Blue */
  --p2-light: #f0f9ff;
  --p2-border: #38bdf8;
  --p2-shadow: #7dd3fc;
  
  --accent-gold: #f59e0b;
  --accent-yellow: #fde047;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  
  --cell-bg: #ffffff;
  --cell-shadow: 0 7px 0 #cbd5e1;
  --cell-shadow-active: 0 2px 0 #cbd5e1;
  
  --text-dark: #1e293b;
  --text-muted: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation; /* Instant touch response without double-tap delay */
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-dark);
  overflow-x: hidden;
  position: relative;
  padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 16px);
  box-sizing: border-box;
}

/* Floating Dreamy Background Decorations */
.bg-floating-elements {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.floating-bubble {
  position: absolute;
  opacity: 0.38;
  filter: blur(0.5px);
  animation: floatDrift 14s infinite ease-in-out alternate;
}

.bubble-1 { top: 6%; left: 8%; font-size: 3rem; animation-duration: 12s; }
.bubble-2 { top: 15%; right: 10%; font-size: 2.2rem; animation-duration: 16s; animation-delay: -2s; }
.bubble-3 { bottom: 12%; left: 12%; font-size: 2.8rem; animation-duration: 18s; animation-delay: -5s; }
.bubble-4 { top: 75%; right: 8%; font-size: 2.6rem; animation-duration: 15s; animation-delay: -3s; }
.bubble-5 { top: 45%; left: 3%; font-size: 2rem; animation-duration: 20s; animation-delay: -7s; }
.bubble-6 { bottom: 5%; right: 28%; font-size: 2.4rem; animation-duration: 14s; animation-delay: -4s; }

/* Fullscreen Confetti Canvas */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1000;
}

/* Tablet Layout Outer Container */
.tablet-layout-container {
  width: min(98%, 1080px);
  max-width: 1080px;
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  border-radius: 34px;
  box-shadow: var(--card-shadow);
  padding: 16px 24px 22px 24px;
  border: 4px solid #ffffff;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 10;
  margin: auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Top App Header (Streamlined single-line layout) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px dashed #e2e8f0;
  padding-bottom: 10px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(255, 51, 102, 0.22);
  animation: floatBounce 2.6s ease-in-out infinite alternate;
}

.logo-text h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ff3366;
  text-shadow: 2px 2px 0px #fde047;
  letter-spacing: 0.5px;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-badge {
  display: inline-block;
  background: #fdf2f8;
  color: #db2777;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1.5px solid #fbcfe8;
  letter-spacing: 0;
  text-shadow: none;
}

/* Header Controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Quick Rule Switcher Pill in Header */
.rule-quick-pill {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  gap: 2px;
}

.rule-pill-option {
  font-family: var(--font-family);
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.rule-pill-option.active {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(139, 92, 246, 0.35);
}

.reward-pill-btn {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #fef08a 0%, #fcd34d 100%);
  border: 2px solid #f59e0b;
  color: #92400e;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 0 #d97706, 0 4px 10px rgba(245, 158, 11, 0.2);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  font-size: 0.94rem;
}

.reward-pill-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #d97706, 0 6px 14px rgba(245, 158, 11, 0.28);
}

.reward-pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #d97706;
}

.star-icon-bounce {
  font-size: 1.3rem;
  animation: starPulse 1.2s infinite ease-in-out;
}

.star-count-badge {
  background: #ffffff;
  color: #b45309;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid #f59e0b;
  min-width: 28px;
  text-align: center;
}

.reward-btn-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.pill-btn {
  font-family: var(--font-family);
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s ease;
}

/* Sound & Fullscreen Pure Icon Buttons */
.sound-icon-btn,
.icon-circle-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.35rem;
  background: #f1f5f9;
  border: 2.5px solid #cbd5e1;
  box-shadow: 0 4px 0 #cbd5e1;
  color: var(--text-dark);
}

.sound-icon-btn:hover,
.icon-circle-btn:hover {
  background: #e2e8f0;
}

.sound-icon-btn:active,
.icon-circle-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.sound-icon-btn.muted {
  background: #fee2e2;
  border-color: #fca5a5;
  box-shadow: 0 4px 0 #fca5a5;
}

/* Settings Button in Header */
.settings-header-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border: 2px solid #bfdbfe;
  padding: 8px 14px;
  font-size: 0.95rem;
  border-radius: 999px;
  box-shadow: 0 4px 0 #93c5fd;
}

.settings-header-btn:hover {
  background: #dbeafe;
}

.settings-header-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #93c5fd;
}

/* Tablet Dual-Column Grid */
.tablet-grid-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

@media (min-width: 768px) and (max-width: 879px) {
  .tablet-grid-layout {
    grid-template-columns: 320px 1fr;
    gap: 18px;
    align-items: center;
  }
}

@media (min-width: 880px) {
  .tablet-grid-layout {
    grid-template-columns: 350px 1fr;
    gap: 24px;
    align-items: center;
  }
}

/* Left Sidebar */
.tablet-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

/* Rank & Level Card */
.reward-summary-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2.5px solid #fde68a;
  border-radius: 22px;
  padding: 12px 14px;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.08);
}

.reward-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.rank-avatar {
  font-size: 2.3rem;
  background: #ffffff;
  border-radius: 16px;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  border: 2px solid #fde047;
}

.rank-details {
  flex: 1;
  min-width: 0;
}

.rank-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.rank-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: #92400e;
}

.voice-tag-mini {
  background: #ffffff;
  color: #be185d;
  border: 1.5px solid #fbcfe8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.rank-sub {
  font-size: 0.95rem;
  font-weight: 700;
  color: #d97706;
}

.progress-bar-container {
  height: 14px;
  background: #ffffff;
  border-radius: 999px;
  border: 1.5px solid #fcd34d;
  position: relative;
  overflow: hidden;
  margin-bottom: 5px;
}

.progress-bar-ticks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  pointer-events: none;
  z-index: 1;
}

.progress-bar-ticks span {
  width: 2px;
  height: 60%;
  background: rgba(217, 119, 6, 0.35);
  border-radius: 1px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  z-index: 2;
}

.progress-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: #b45309;
  text-align: right;
}

/* Scoreboard (3 Cards strictly constrained to 100% sidebar width, no overflow) */
.scoreboard {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.score-card {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  background: #f8fafc;
  border: 3px solid #e2e8f0;
  border-radius: 18px;
  padding: 8px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  box-sizing: border-box;
  transition: all 0.25s ease;
}

.avatar-badge {
  font-size: 1.85rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.score-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.player-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.score-number {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-dark);
}

.score-card.player-x {
  border-color: #fecdd3;
  background: #fff5f8;
}

.score-card.player-x.active {
  border-color: var(--p1-border);
  background: var(--p1-light);
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px rgba(255, 42, 109, 0.25), 0 6px 14px rgba(255, 42, 109, 0.18);
}

.score-card.player-x.active .avatar-badge {
  transform: scale(1.15) rotate(-5deg);
}

.score-card.player-o {
  border-color: #bae6fd;
  background: #f4faff;
}

.score-card.player-o.active {
  border-color: var(--p2-border);
  background: var(--p2-light);
  transform: translateY(-2px);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25), 0 6px 14px rgba(2, 132, 199, 0.18);
}

.score-card.player-o.active .avatar-badge {
  transform: scale(1.15) rotate(5deg);
}

.score-ties {
  background: #f1f5f9;
  border-color: #cbd5e1;
  opacity: 0.95;
}

/* Match Info Card & Smart Coach Button */
.match-info-card {
  background: #f8fafc;
  border: 2.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-info-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.match-info-icon {
  font-size: 2.1rem;
  background: #ffffff;
  border-radius: 14px;
  padding: 4px;
  border: 2px solid #e2e8f0;
  flex-shrink: 0;
}

.match-info-text-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.match-info-title {
  font-size: 1.04rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-info-desc {
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  line-height: 1.3;
}

.match-card-btn-row {
  display: flex;
  gap: 8px;
}

.hint-coach-btn {
  flex: 1;
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  color: #92400e;
  border: 2px solid #f59e0b;
  padding: 9px 10px;
  font-size: 0.95rem;
  border-radius: 14px;
  box-shadow: 0 3px 0 #d97706;
}

.hint-coach-btn:hover {
  background: #fde047;
}

.hint-coach-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d97706;
}

.change-partner-btn {
  flex: 1.15;
  background: #eff6ff;
  color: #2563eb;
  border: 2px solid #bfdbfe;
  padding: 9px 10px;
  font-size: 0.95rem;
  border-radius: 14px;
  box-shadow: 0 3px 0 #93c5fd;
}

.change-partner-btn:hover {
  background: #dbeafe;
}

.change-partner-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #93c5fd;
}

/* Sidebar Action Buttons */
.sidebar-actions {
  display: flex;
  gap: 8px;
}

.primary-action-btn {
  flex: 2;
  background: #10b981;
  color: #ffffff;
  padding: 14px 14px;
  font-size: 1.08rem;
  box-shadow: 0 5px 0 #059669;
}

.primary-action-btn:hover {
  background: #059669;
}

.primary-action-btn:active {
  box-shadow: 0 2px 0 #059669;
  transform: translateY(3px);
}

.secondary-action-btn {
  flex: 1;
  background: #e2e8f0;
  color: #475569;
  padding: 14px 10px;
  font-size: 1rem;
  box-shadow: 0 5px 0 #cbd5e1;
}

.secondary-action-btn:hover {
  background: #cbd5e1;
}

.secondary-action-btn:active {
  box-shadow: 0 2px 0 #cbd5e1;
  transform: translateY(3px);
}

/* Right Main Arena (Vertically Centered with Left Sidebar) */
.tablet-main-arena {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Turn Status Banner (Color synchronized with active player) */
.status-banner {
  background: #fff1f2;
  border: 3px solid #fecdd3;
  color: #be123c;
  border-radius: 20px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: all 0.25s ease;
}

.status-banner.turn-p1 {
  background: #fff1f2;
  border-color: #ff6584;
  color: #be123c;
  box-shadow: 0 4px 14px rgba(255, 42, 109, 0.16);
}

.status-banner.turn-p2 {
  background: #f0f9ff;
  border-color: #38bdf8;
  color: #0369a1;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.16);
}

.status-banner.bot-thinking {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.16);
}

.status-icon {
  font-size: 1.65rem;
  animation: wiggle 1.2s infinite ease-in-out;
  flex-shrink: 0;
}

.status-text {
  flex: 1;
  text-align: center;
}

.banner-voice-btn {
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.banner-voice-btn:hover {
  transform: scale(1.1);
}

.banner-voice-btn:active {
  transform: scale(0.95);
}

/* 3x3 Toy Touch Board (Enlarged to 85%-90% Arena width, ~480px, cells >120px) */
.board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 2px 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 14px;
  width: min(100%, 480px);
  height: min(480px, 80vw);
  aspect-ratio: 1 / 1;
  padding: 14px;
  border-radius: 30px;
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.08), 0 12px 28px rgba(0, 0, 0, 0.05);
  border: 4px solid #cbd5e1;
  background: #e8ecf4;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  position: relative;
}

/* Dynamic Winning Laser Line SVG Overlay */
.win-line-svg {
  position: absolute;
  top: 14px;
  left: 14px;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  pointer-events: none;
  z-index: 20;
  overflow: visible;
}

.win-laser-line {
  stroke: url(#winLaserGrad);
  stroke-width: 14;
  stroke-linecap: round;
  filter: drop-shadow(0 0 12px rgba(245, 158, 11, 0.85));
  stroke-dasharray: 450;
  stroke-dashoffset: 450;
  opacity: 0;
  transition: stroke-dashoffset 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.win-laser-line.active {
  opacity: 1;
  stroke-dashoffset: 0;
}

/* Dynamic Themed Board Colors */
.board.theme-pets {
  background: #fef3c7;
  border-color: #fde68a;
}

.board.theme-space {
  background: #e0e7ff;
  border-color: #c7d2fe;
}

.board.theme-dino {
  background: #dcfce7;
  border-color: #bbf7d0;
}

.board.theme-magic {
  background: #fce7f3;
  border-color: #fbcfe8;
}

.board.theme-sweet {
  background: #fff1f2;
  border-color: #fecdd3;
}

.board.theme-sea {
  background: #e0f2fe;
  border-color: #bae6fd;
}

.board.theme-classic {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Tactile 3D Cells (> 120px on tablet, high responsiveness) */
.cell {
  background: var(--cell-bg);
  border: 3.5px solid #cbd5e1;
  border-radius: 22px;
  box-shadow: var(--cell-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.8rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.25s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  outline: none;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Empty Cell Ghost Preview (Tactile feedback for kids) */
.cell:empty::before {
  content: attr(data-preview);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  font-size: 3.3rem;
  transform: scale(0.85);
  pointer-events: none;
}

.cell:empty:hover::before,
.cell:empty:focus::before {
  opacity: 0.36;
  transform: scale(1);
}

.cell:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: #94a3b8;
  background: #f8fafc;
}

.cell:active:not(:disabled) {
  transform: translateY(5px);
  box-shadow: var(--cell-shadow-active);
}

.cell.pop-in {
  animation: popScale 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Smart Coach Recommended Hint Highlight */
.cell.coach-hint-cell {
  border-color: #f59e0b !important;
  background: #fffbeb !important;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.45), 0 7px 0 #d97706 !important;
  animation: coachPulse 0.85s infinite alternate ease-in-out;
}

.cell.coach-hint-cell::after {
  content: '💡 推荐下这';
  position: absolute;
  bottom: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  background: #f59e0b;
  color: #ffffff;
  padding: 1px 8px;
  border-radius: 999px;
  pointer-events: none;
}

/* Infinite 3-Piece Mode: Oldest piece about to vanish on next move */
.cell.fading-next {
  opacity: 0.62;
  border-style: dashed !important;
  animation: fadePulse 1.1s infinite alternate ease-in-out;
}

.cell.fading-next::after {
  content: '💨 下步消失';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 999px;
  pointer-events: none;
}

/* Player-specific colors: Pink for X, Blue for O */
.cell.cell-x {
  background: #fff0f5 !important;
  border-color: #ff6584 !important;
  box-shadow: 0 6px 0 #fda4af !important;
  color: #ff1464 !important;
  font-weight: 700;
}

.cell.cell-o {
  background: #f0f9ff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 6px 0 #7dd3fc !important;
  color: #0284c7 !important;
  font-weight: 700;
}

.cell.cell-x:active:not(:disabled) {
  box-shadow: 0 2px 0 #fda4af !important;
}

.cell.cell-o:active:not(:disabled) {
  box-shadow: 0 2px 0 #7dd3fc !important;
}

.cell.winning-cell {
  background: #fef08a !important;
  border-color: #f59e0b !important;
  color: #b45309 !important;
  animation: winBounce 0.6s infinite alternate ease-in-out;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.7) !important;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  box-sizing: border-box;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 34px;
  padding: 24px 22px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
  border: 6px solid #ffd166;
  animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-decoration {
  font-size: 4.4rem;
  margin-bottom: 6px;
  animation: bounceEmoji 1s infinite alternate ease-in-out;
}

.modal-title {
  font-size: 1.8rem;
  color: #ff3366;
  margin-bottom: 6px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 1.12rem;
  color: #4b5563;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.reward-gain-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #fcd34d;
  border-radius: 20px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 18px;
}

.gain-stars {
  font-size: 1.4rem;
  font-weight: 700;
  color: #b45309;
}

.gain-sub {
  font-size: 0.94rem;
  font-weight: 600;
  color: #d97706;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-btn {
  font-family: var(--font-family);
  font-size: 1.15rem;
  font-weight: 700;
  padding: 13px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.modal-btn.main-btn {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 6px 0 #059669;
}

.modal-btn.main-btn:hover {
  background: #059669;
}

.modal-btn.main-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #059669;
}

/* Settings Modal Card Styles */
.settings-modal-card {
  max-width: 640px;
  padding: 20px 22px;
  text-align: left;
  border-color: #38bdf8;
  max-height: 92vh;
  overflow-y: auto;
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.settings-modal-icon {
  font-size: 2rem;
}

.header-title-box h2 {
  font-size: 1.5rem;
  color: #0369a1;
  font-weight: 700;
}

.settings-section {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
}

/* High-Contrast Mode Toggle Buttons */
.mode-toggles-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-btn-large {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #edf2f7;
  border: 2.5px solid #cbd5e1;
  border-radius: 18px;
  padding: 10px 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  color: #475569;
}

.mode-btn-large .mode-emoji {
  font-size: 1.9rem;
}

.mode-btn-large .mode-text {
  font-size: 0.98rem;
  font-weight: 700;
}

.mode-btn-large:hover {
  background: #e2e8f0;
}

.mode-btn-large.active {
  background: linear-gradient(135deg, #ff3366 0%, #ff5e62 100%);
  color: #ffffff;
  border-color: #d81b60;
  box-shadow: 0 4px 0 #be123c, 0 6px 14px rgba(255, 51, 102, 0.28);
  transform: translateY(-2px);
}

/* Rule Variant Cards in Settings */
.rule-toggles-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rule-card-btn {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 16px;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
  gap: 2px;
}

.rule-card-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #1e293b;
}

.rule-card-desc {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
}

.rule-card-btn.active {
  background: linear-gradient(135deg, #f3e8ff 0%, #fce7f3 100%);
  border-color: #9333ea;
  box-shadow: 0 3px 0 #7e22ce;
}

.rule-card-btn.active .rule-card-title {
  color: #6b21a8;
}

/* Difficulty Selector in Settings */
.diff-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diff-dynamic-tag {
  font-size: 0.85rem;
  font-weight: 700;
  background: #fef08a;
  color: #854d0e;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid #facc15;
}

.mini-pill-btn {
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 700;
  background: #fdf2f8;
  color: #db2777;
  border: 1.5px solid #f472b6;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.mini-pill-btn:hover {
  background: #fce7f3;
}

.diff-buttons-settings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.diff-btn-large {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 2px solid #fde047;
  padding: 9px 4px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 3px 0 #fcd34d;
  gap: 2px;
}

.diff-btn-large .btn-emoji {
  font-size: 1.7rem;
}

.diff-btn-large .btn-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: #78350f;
}

.diff-btn-large .btn-desc {
  font-size: 0.78rem;
  font-weight: 600;
  color: #92400e;
  opacity: 0.9;
}

.diff-btn-large:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
}

.diff-btn-large.active {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: #b45309;
  box-shadow: 0 4px 0 #92400e;
  transform: translateY(-2px);
}

.diff-btn-large.active .btn-title,
.diff-btn-large.active .btn-desc {
  color: #ffffff;
}

.diff-btn-large[data-diff="auto"].active {
  background: linear-gradient(135deg, #f59e0b 0%, #ec4899 100%);
  border-color: #be185d;
  box-shadow: 0 4px 0 #9d174d;
}

.dynamic-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 7px 12px;
  border-radius: 14px;
  border: 1.5px solid #fef08a;
  font-size: 0.88rem;
  color: #92400e;
  font-weight: 600;
  line-height: 1.35;
}

.dynamic-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  animation: wiggle 2s infinite ease-in-out;
}

.dynamic-hint {
  flex: 1;
}

/* AI Neural Voice Selection Grid in Settings */
.voice-grid-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.voice-chip-btn {
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.voice-chip-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.voice-chip-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.voice-chip-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-chip-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-chip-btn.active {
  background: linear-gradient(135deg, #fff0f5 0%, #fce7f3 100%);
  border-color: #ec4899;
  box-shadow: 0 3px 0 #db2777;
}

.voice-chip-btn.active .voice-chip-name {
  color: #be185d;
}

/* Balanced 4+3 Themes Grid */
.themes-grid-settings {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
}

.themes-grid-settings .theme-card-btn:nth-child(1),
.themes-grid-settings .theme-card-btn:nth-child(2),
.themes-grid-settings .theme-card-btn:nth-child(3),
.themes-grid-settings .theme-card-btn:nth-child(4) {
  grid-column: span 3;
}

.themes-grid-settings .theme-card-btn:nth-child(5),
.themes-grid-settings .theme-card-btn:nth-child(6),
.themes-grid-settings .theme-card-btn:nth-child(7) {
  grid-column: span 4;
}

.theme-card-btn {
  font-family: var(--font-family);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 2.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 3px 0 #cbd5e1;
  gap: 3px;
}

.theme-card-emoji {
  font-size: 1.35rem;
}

.theme-card-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-dark);
}

.theme-card-btn:hover {
  transform: translateY(-2px);
  border-color: #f472b6;
  background: #fdf2f8;
}

.theme-card-btn.active {
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border-color: #f59e0b;
  box-shadow: 0 4px 0 #d97706, 0 4px 12px rgba(245, 158, 11, 0.25);
  transform: translateY(-2px);
}

.theme-card-btn.active .theme-card-name {
  color: #92400e;
}

/* Settings Bottom Tools Row */
.settings-tools-row {
  display: flex;
  gap: 10px;
}

.tool-pill-btn {
  flex: 1;
  font-family: var(--font-family);
  font-size: 0.92rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  border: 2px solid #cbd5e1;
  padding: 9px 12px;
  border-radius: 14px;
  cursor: pointer;
}

.tool-pill-btn:hover {
  background: #e2e8f0;
}

/* Child-Safe Confirm Reset Modal */
.confirm-modal-card {
  max-width: 440px;
  border-color: #cbd5e1;
}

/* Reward, Gashapon & Sticker Book Modal */
.reward-modal-card {
  max-width: 620px;
  padding: 20px 22px;
  text-align: left;
  max-height: 92vh;
  overflow-y: auto;
}

.reward-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.header-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title-box h2 {
  font-size: 1.5rem;
  color: #b45309;
  font-weight: 700;
}

.trophy-big {
  font-size: 2rem;
}

.close-icon-btn {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  color: #64748b;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.close-icon-btn:hover {
  background: #e2e8f0;
}

.reward-stats-banner {
  display: flex;
  gap: 8px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-val {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ff3366;
}

.stat-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Reward Tabs */
.reward-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.reward-tab-btn {
  flex: 1;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: 16px;
  border: 2.5px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: all 0.18s ease;
}

.reward-tab-btn.active {
  background: linear-gradient(135deg, #fef08a 0%, #fcd34d 100%);
  color: #92400e;
  border-color: #f59e0b;
  box-shadow: 0 4px 0 #d97706;
}

.reward-tab-panel.hidden {
  display: none;
}

/* Gashapon Machine Stage */
.gashapon-stage-box {
  background: linear-gradient(135deg, #fdf2f8 0%, #f3e8ff 100%);
  border: 2.5px solid #f472b6;
  border-radius: 22px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.gashapon-machine-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.gashapon-ORB {
  font-size: 3.4rem;
  line-height: 1.1;
  animation: floatBounce 1.8s infinite alternate ease-in-out;
}

.gashapon-ORB.rolling {
  animation: spinOrb 0.45s infinite linear;
}

.gashapon-msg {
  font-size: 0.94rem;
  font-weight: 700;
  color: #9d174d;
}

.gashapon-draw-btn {
  background: linear-gradient(135deg, #ff3366 0%, #ec4899 100%);
  color: #ffffff;
  font-size: 1.05rem;
  padding: 11px 24px;
  box-shadow: 0 5px 0 #be185d;
}

.gashapon-draw-btn:disabled {
  background: #cbd5e1;
  color: #64748b;
  box-shadow: 0 3px 0 #94a3b8;
  cursor: not-allowed;
}

.stickers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}

.sticker-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: transform 0.18s ease;
}

.sticker-card.unlocked {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.15);
}

.sticker-card.unlocked:hover {
  transform: translateY(-2px) scale(1.03);
}

.sticker-card.locked {
  opacity: 0.55;
  filter: grayscale(0.9);
  border-style: dashed;
}

.sticker-emoji {
  font-size: 2rem;
}

.sticker-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dark);
}

.badges-scroll-area {
  max-height: 310px;
  overflow-y: auto;
  padding-right: 4px;
}

.badges-tip-banner {
  font-size: 0.88rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border-radius: 10px;
  padding: 7px 10px;
  margin-bottom: 8px;
  text-align: center;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 10px;
}

.badge-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.badge-card.unlocked {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.15);
}

.badge-card.unlocked:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25);
}

.badge-card.locked {
  opacity: 0.65;
  filter: grayscale(0.85);
  border-style: dashed;
}

.badge-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.badge-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-dark);
}

.badge-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* PWA Guide Steps */
.pwa-steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.pwa-step-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f0f9ff;
  border: 2px solid #bae6fd;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 0.96rem;
  font-weight: 600;
  color: #0369a1;
}

.pwa-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Flying Star Animation */
.star-fly-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 3000;
}

.flying-star {
  position: absolute;
  font-size: 2.2rem;
  animation: flyToStarCounter 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Keyframe Animations */
@keyframes flyToStarCounter {
  0% { transform: scale(0.5); opacity: 0; }
  20% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(0.3); opacity: 0; }
}

@keyframes floatBounce {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-6px) rotate(6deg); }
}

@keyframes floatDrift {
  0% { transform: translateY(0px) translateX(0px); }
  100% { transform: translateY(-20px) translateX(15px); }
}

@keyframes starPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.22); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-8deg) scale(1.08); }
  75% { transform: rotate(8deg) scale(1.08); }
}

@keyframes popScale {
  0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  70% { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes winBounce {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

@keyframes coachPulse {
  0% { transform: scale(0.97); }
  100% { transform: scale(1.04); }
}

@keyframes fadePulse {
  0% { opacity: 0.48; transform: scale(0.95); }
  100% { opacity: 0.78; transform: scale(1); }
}

@keyframes spinOrb {
  0% { transform: rotate(0deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1.25); }
  100% { transform: rotate(360deg) scale(1.1); }
}

@keyframes bounceEmoji {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-12px) scale(1.12); }
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Mobile & Small Screen Tweaks */
@media (max-width: 767px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }
  .tablet-layout-container {
    padding: 14px 12px 18px 12px;
    border-radius: 26px;
    gap: 12px;
  }
  .logo-text h1 {
    font-size: 1.4rem;
  }
  .board {
    width: min(100%, 340px);
    height: 340px;
    gap: 10px;
    padding: 10px;
    border-radius: 24px;
  }
  .cell {
    font-size: 2.8rem;
    border-radius: 18px;
  }
  .reward-btn-label {
    display: none;
  }
  .themes-grid-settings,
  .voice-grid-settings,
  .stickers-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .themes-grid-settings .theme-card-btn {
    grid-column: span 1 !important;
  }
  .diff-buttons-settings,
  .rule-toggles-settings {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-tools-row {
    flex-direction: column;
  }
}
