/* =========================================================
   6x6 Othello Stylesheet
   Modern, Dark Aesthetic, Glassmorphism, Felt Board & 3D Discs
   ========================================================= */

:root {
  --bg-primary: #0d131a;
  --bg-secondary: #16202c;
  --bg-surface: rgba(26, 38, 52, 0.75);
  --bg-surface-hover: rgba(36, 52, 70, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(76, 175, 80, 0.4);

  --accent-green: #2ecc71;
  --accent-green-dark: #27ae60;
  --board-green: #1b5e3b;
  --board-green-dark: #14492e;
  --board-grid-line: rgba(0, 0, 0, 0.35);

  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --disc-black-grad: radial-gradient(circle at 35% 35%, #475569, #1e293b 45%, #090d13 90%);
  --disc-white-grad: radial-gradient(circle at 35% 35%, #ffffff, #e2e8f0 50%, #94a3b8 90%);
  --disc-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-main: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background: radial-gradient(circle at 50% 20%, #1a2736 0%, #0d131a 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-disc {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  transform: rotate(-25deg);
}

.half-disc {
  width: 50%;
  height: 100%;
}

.half-disc.black {
  background: #111827;
}

.half-disc.white {
  background: #f8fafc;
}

.title-meta {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-subtitle {
  font-size: 0.75rem;
  color: var(--accent-green);
  font-weight: 500;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

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

.icon-btn.active {
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.5);
}

/* Screens */
.main-content {
  position: relative;
  min-height: 520px;
}

.screen {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(8px);
}

.screen.active {
  display: block;
  opacity: 1;
  transform: none;
}

/* Screen 1: Color Selection */
.color-select-card {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #ffffff;
}

.section-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.color-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .color-options-grid {
    grid-template-columns: 1fr;
  }
}

.color-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  text-align: center;
  overflow: hidden;
  font-family: inherit;
}

.color-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(46, 204, 113, 0.12), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.color-card:hover {
  transform: translateY(-4px);
  border-color: rgba(46, 204, 113, 0.6);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4), 0 0 16px rgba(46, 204, 113, 0.2);
}

.color-card:hover::before {
  opacity: 1;
}

.color-card:active {
  transform: scale(0.98);
}

.disc-preview-container {
  margin-bottom: 16px;
}

.disc-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  position: relative;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.color-card:hover .disc-large {
  transform: scale(1.1) rotate(15deg);
}

.black-preview {
  background: var(--disc-black-grad);
  border: 2px solid #334155;
}

.white-preview {
  background: var(--disc-white-grad);
  border: 2px solid #cbd5e1;
}

.color-card-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.color-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.color-role-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.color-role-tag.primary {
  background: rgba(46, 204, 113, 0.18);
  color: var(--accent-green);
  border: 1px solid rgba(46, 204, 113, 0.35);
}

.color-role-tag.secondary {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.color-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

.card-action-cue {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-green);
  margin-top: auto;
}

.cue-arrow {
  transition: transform var(--transition-fast);
}

.color-card:hover .cue-arrow {
  transform: translateX(-4px);
}

/* Screen 2: Game Board */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.player-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  transition: all var(--transition-normal);
  position: relative;
  min-width: 110px;
}

.player-badge.active-turn {
  border-color: var(--accent-green);
  background: rgba(46, 204, 113, 0.12);
  box-shadow: 0 0 14px rgba(46, 204, 113, 0.35);
}

.badge-disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.badge-disc.black {
  background: var(--disc-black-grad);
  border: 1px solid #475569;
}

.badge-disc.white {
  background: var(--disc-white-grad);
  border: 1px solid #cbd5e1;
}

.badge-text {
  display: flex;
  flex-direction: column;
}

.badge-name {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.badge-score {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.turn-status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-grow: 1;
}

.turn-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 1.6s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.ai-thinking-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #38bdf8;
  font-weight: 500;
}

.ai-thinking-indicator.hidden {
  display: none;
}

.thinking-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast Container */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 40px));
}

.toast {
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-right: 4px solid var(--accent-green);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  max-width: 100%;
  word-break: break-word;
}

.toast.warning {
  border-right-color: #f59e0b;
}

.toast.fade-out {
  animation: toast-out 0.3s forwards ease-in;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(40px) scale(0.96);
  }
}

@media (max-width: 480px) {
  .toast-container {
    top: 14px;
    right: 14px;
    max-width: calc(100vw - 28px);
  }
}

/* Board Outer Container */
.board-outer-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.board-frame {
  background: #11271b;
  border: 10px solid #0a1710;
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 2px 6px rgba(255, 255, 255, 0.1);
  padding: 6px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

/* Coordinates (Strictly LTR) */
.col-labels-top,
.col-labels-bottom {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  width: 100%;
  padding: 4px 22px; /* aligns with middle board grid */
  text-align: center;
}

.row-labels-left,
.row-labels-right {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  height: 100%;
  padding: 0 6px;
  align-items: center;
  text-align: center;
}

.coord-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-middle-row {
  display: flex;
  align-items: center;
}

/* 6x6 Board Grid */
.board-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  background: var(--board-grid-line);
  padding: 3px;
  border-radius: 6px;
  width: clamp(280px, 86vw, 480px);
  height: clamp(280px, 86vw, 480px);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* Square Cell */
.board-cell {
  background: linear-gradient(135deg, var(--board-green) 0%, var(--board-green-dark) 100%);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  transition: background var(--transition-fast);
}

.board-cell.valid-move {
  cursor: pointer;
}

.board-cell.valid-move:hover {
  background: linear-gradient(135deg, #24754a 0%, #1a5b3a 100%);
}

.board-cell.invalid-shake {
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Hint Dot on Valid Move Squares */
.hint-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
  transition: all var(--transition-fast);
  pointer-events: none;
}

.board-cell.valid-move:hover .hint-dot {
  transform: scale(1.6);
  background: rgba(46, 204, 113, 0.8);
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.9);
}

.board-grid.hide-hints .hint-dot {
  display: none;
}

/* 3D Discs */
.disc-wrapper {
  width: 86%;
  height: 86%;
  perspective: 800px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  box-shadow: var(--disc-shadow);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.disc.placed-pop {
  animation: pop-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.disc-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.black-face {
  background: var(--disc-black-grad);
  border: 1.5px solid #334155;
}

.white-face {
  background: var(--disc-white-grad);
  border: 1.5px solid #e2e8f0;
  transform: rotateY(180deg);
}

/* Disc Color States */
.disc.is-black {
  transform: rotateY(0deg);
}

.disc.is-white {
  transform: rotateY(180deg);
}

.disc.flip-to-white {
  animation: flip-white 0.22s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

.disc.flip-to-black {
  animation: flip-black 0.22s forwards cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes flip-white {
  from { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(90deg) scale(1.12); }
  to { transform: rotateY(180deg) scale(1); }
}

@keyframes flip-black {
  from { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(90deg) scale(1.12); }
  to { transform: rotateY(0deg) scale(1); }
}

/* Footer info */
.game-footer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 8px;
}

.info-pill {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon-badge {
  font-size: 3rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.final-score-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-bottom: 24px;
}

.final-player-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.score-user-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.score-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: #ffffff;
}

.score-vs {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: center;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-green) 0%, var(--accent-green-dark) 100%);
  color: #062412;
  box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* =========================================================
   Mode Switcher Bar
   ========================================================= */
.mode-switcher-bar {
  display: flex;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.mode-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab-btn.active {
  background: var(--bg-secondary);
  color: var(--accent-green);
  border-color: rgba(46, 204, 113, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.mode-icon {
  font-size: 1.1rem;
}

/* =========================================================
   Coach Panel & Pattern Presentation
   ========================================================= */
.coach-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fade-slide 0.3s ease;
}

.coach-panel.hidden {
  display: none;
}

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.coach-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.coach-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-badge-icon {
  font-size: 1.5rem;
}

.coach-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.coach-category-tag {
  font-size: 0.75rem;
  color: var(--accent-green);
  font-weight: 600;
}

.tool-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.coach-quick-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.switch-container {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: background var(--transition-fast);
}

.switch-container:hover {
  background: rgba(255, 255, 255, 0.08);
}

.switch-container input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  width: 32px;
  height: 18px;
  background-color: #334155;
  border-radius: 20px;
  position: relative;
  transition: background-color var(--transition-fast);
  flex-shrink: 0;
}

.switch-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.switch-container input:checked + .switch-slider {
  background-color: var(--accent-green);
}

.switch-container input:checked + .switch-slider::before {
  transform: translateX(14px);
}

.switch-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* Coach Opening Selector */
.opening-selector-container {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fade-slide 0.25s ease;
}

.opening-selector-container.hidden {
  display: none;
}

.opening-selector-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: #38bdf8;
}

.opening-current-badge {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #bae6fd;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.opening-buttons-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.opening-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.opening-btn:hover {
  background: var(--bg-surface-hover);
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.5);
}

.opening-btn.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

/* Opponent analysis banner */
.opponent-analysis-box {
  background: rgba(15, 23, 42, 0.7);
  border-right: 3px solid #38bdf8;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.opp-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
}

.opp-desc {
  font-size: 0.86rem;
  color: var(--text-primary);
  line-height: 1.45;
}

/* Pattern card */
.pattern-recommendation-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pattern-top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pattern-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.pattern-name {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.best-move-tag {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #f59e0b;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.pattern-summary {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.pattern-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
}

.pattern-text {
  font-size: 0.84rem;
  color: #cbd5e1;
  line-height: 1.55;
}

.coach-advice-box {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.advice-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-green);
}

.advice-text {
  font-size: 0.84rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Actions in coach panel */
.coach-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.btn-apply-coach {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #1e1b4b;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-apply-coach:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
}

.btn-secondary-coach {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
}

.btn-secondary-coach:hover {
  background: var(--bg-surface-hover);
  color: #ffffff;
}

/* Ranked moves container */
.ranked-moves-container {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 6px;
}

.ranked-moves-container.hidden {
  display: none;
}

.ranked-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.ranked-moves-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ranked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.ranked-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ranked-item.is-best {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.ranked-coord {
  font-weight: 700;
  font-family: monospace;
  font-size: 0.9rem;
  color: #ffffff;
}

.ranked-tag {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.ranked-tag.best {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.ranked-tag.great {
  background: rgba(46, 204, 113, 0.25);
  color: #4ade80;
}

.ranked-tag.good {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
}

.ranked-tag.poor {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

/* =========================================================
   Board Special Cell Styling for Coach Mode
   ========================================================= */
/* Opponent move hints (Amber dot) */
.board-cell.opponent-move .hint-dot {
  background: rgba(245, 158, 11, 0.5);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

.board-cell.opponent-move:hover .hint-dot {
  background: rgba(245, 158, 11, 0.9);
  box-shadow: 0 0 14px rgba(245, 158, 11, 1);
}

/* Recommended move cell (Pulsing golden star) */
.board-cell.coach-recommended {
  box-shadow: inset 0 0 0 2.5px #f59e0b, 0 0 14px rgba(245, 158, 11, 0.7);
  animation: pulse-gold 1.8s infinite ease-in-out;
  cursor: pointer;
}

@keyframes pulse-gold {
  0%, 100% {
    box-shadow: inset 0 0 0 2.5px #f59e0b, 0 0 14px rgba(245, 158, 11, 0.6);
  }
  50% {
    box-shadow: inset 0 0 0 3px #fbbf24, 0 0 22px rgba(245, 158, 11, 0.95);
  }
}

.coach-star-indicator {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.85rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  z-index: 5;
  animation: star-bounce 1s infinite alternate ease-in-out;
}

@keyframes star-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-3px) scale(1.1); }
}

/* =========================================================
   Coach analysis panel (engine facts, opponent profile, verdicts)
   ========================================================= */
.coach-thinking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

.coach-thinking.hidden { display: none; }

.thinking-spinner.small {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

/* Verdict on the opponent's last move */
.opp-grade {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.45;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-top: 2px;
}

.opp-grade.hidden,
.opponent-style-box.hidden,
.coach-pv-row.hidden,
.user-move-verdict.hidden { display: none; }

.opp-grade.tag-best { background: rgba(46, 204, 113, 0.15); color: #4ade80; }
.opp-grade.tag-good { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.opp-grade.tag-poor { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* Opponent profile + counter plan */
.opponent-style-box {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.style-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: #c084fc;
}

.style-summary {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.style-plan {
  font-size: 0.82rem;
  color: #e9d5ff;
  line-height: 1.5;
}

/* Engine evaluation line */
.coach-eval-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eval-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-full);
  padding: 2px 9px;
  white-space: nowrap;
}

.eval-badge.is-exact {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.5);
}

.eval-text {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
}

/* Measured reasons for the recommended move */
.reasons-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reasons-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-green);
}

.reasons-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 16px;
  margin: 0;
}

.reasons-list li {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.coach-pv-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--border-color);
  padding-top: 6px;
}

.pv-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pv-text {
  font-family: monospace;
  font-size: 0.82rem;
  color: #7dd3fc;
  direction: ltr;
  unicode-bidi: embed;
}

/* Verdict on a move the learner played themselves */
.user-move-verdict {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}

.user-move-verdict.tag-best { background: rgba(46, 204, 113, 0.15); color: #4ade80; border: 1px solid rgba(46, 204, 113, 0.35); }
.user-move-verdict.tag-great { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.35); }
.user-move-verdict.tag-good { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.user-move-verdict.tag-poor { background: rgba(239, 68, 68, 0.14); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }

.engine-info-row {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Richer ranked move rows */
.ranked-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ranked-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}
