/* ============ Theme tokens ============ */
:root {
  --bg: #0a0e1a;
  --bg-elev: #0f1629;
  --panel: #141b2d;
  --border: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --link: #60a5fa;
  --accent: #8b5cf6;
  --accent-2: #06b6d4;
  --ring: rgba(139, 92, 246, 0.4);

  --red: #ef4444;
  --red-glow: #ef444455;
  --yellow: #fbbf24;
  --yellow-glow: #fbbf2455;
  --win: #10b981;
  --win-glow: #10b98155;

  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --cell-size: clamp(48px, 9vmin, 72px);
  --gap: clamp(8px, 1.5vmin, 14px);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.2);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.25);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

:root[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --link: #3b82f6;
  --accent: #8b5cf6;
  --accent-2: #06b6d4;
  --ring: rgba(59, 130, 246, 0.3);
  
  --red-glow: #ef444433;
  --yellow-glow: #fbbf2433;
  --win-glow: #10b98133;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 20px 60px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.1);
}

/* ============ Base ============ */
* { 
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { 
  height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle 800px at 20% 30%, var(--accent) 0%, transparent 40%),
    radial-gradient(circle 600px at 80% 60%, var(--accent-2) 0%, transparent 40%),
    radial-gradient(circle 1000px at 50% 50%, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ============ Site Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(var(--bg-elev), 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.nav {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  transition: var(--transition-fast);
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: var(--radius);
}

.brand:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 12px var(--accent-2));
}

.brand .disc-icon { 
  font-size: 24px;
  animation: float 3s ease-in-out infinite;
}

.brand .disc-icon:nth-child(2) {
  animation-delay: 0.5s;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.nav-actions { 
  display: flex; 
  gap: 12px; 
}

/* ============ Buttons & Interactive Elements ============ */
.btn {
  position: relative;
  padding: 12px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1));
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:hover:not(:disabled)::before {
  opacity: 1;
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  font-weight: 700;
}

.btn.primary:hover:not(:disabled) {
  box-shadow: var(--shadow-lg), 0 0 30px var(--accent);
  transform: translateY(-3px) scale(1.02);
}

.btn.secondary {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--accent);
}

.btn.secondary:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent);
}

.btn.tertiary {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn.tertiary:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.1);
  transform: none;
}

.btn.small {
  padding: 8px 14px;
  font-size: 14px;
}

.btn.full-width {
  width: 100%;
}

.btn-icon {
  font-size: 18px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.2px;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.chip.action {
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
  box-shadow: var(--shadow-md);
}

.chip.action:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent);
}

.chip.disabled {
  opacity: 0.4;
  filter: grayscale(1);
}

/* ============ Game Header ============ */
.game-header {
  margin: 30px 0 20px;
  padding: 32px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(6, 182, 212, 0.05));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.game-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.03;
  animation: rotate 20s linear infinite;
}

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

.header-decoration {
  display: flex;
  gap: 12px;
  font-size: 32px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.header-decoration .disc-icon {
  animation: bounce 2s ease-in-out infinite;
}

.header-decoration .disc-icon:nth-child(2) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(180deg); }
}

.title {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 18px;
  margin-bottom: 20px;
}

.settings-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 20px 0;
  padding: 20px 0;
  border-top: 1px dashed rgba(139, 92, 246, 0.2);
  border-bottom: 1px dashed rgba(139, 92, 246, 0.2);
}

.toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 20px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.controls-hint {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 16px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.hint-icon {
  font-size: 18px;
}

/* ============ Status & Thinking ============ */
.status,
.thinking {
  margin: 16px 0;
  padding: 14px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(6, 182, 212, 0.1));
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thinking {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

/* ============ Game Board ============ */
.board {
  --cols: 7;
  --rows: 6;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  gap: var(--gap);
  width: max-content;
  margin: 30px auto;
  padding: clamp(16px, 2vmin, 24px);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, 
    rgba(139, 92, 246, 0.1) 0%, 
    rgba(6, 182, 212, 0.1) 100%);
  backdrop-filter: blur(20px);
  border: 2px solid var(--border);
  box-shadow: 
    var(--shadow-xl),
    inset 0 2px 4px rgba(255,255,255,0.1),
    0 0 60px rgba(139, 92, 246, 0.1);
  position: relative;
  transition: var(--transition);
}

.board:hover {
  box-shadow: 
    var(--shadow-xl),
    inset 0 2px 4px rgba(255,255,255,0.1),
    0 0 80px rgba(139, 92, 246, 0.15);
}

.board.shake {
  animation: shake 400ms cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Cell Styles */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 50%;
  background: linear-gradient(145deg, 
    rgba(20, 27, 45, 0.9) 0%, 
    rgba(10, 14, 26, 0.9) 100%);
  border: 2px solid rgba(30, 41, 59, 0.5);
  box-shadow:
    inset 0 4px 8px rgba(0,0,0,0.3),
    inset 0 -2px 4px rgba(255,255,255,0.05),
    0 2px 8px rgba(0,0,0,0.2);
  position: relative;
  overflow: visible;
  transition: var(--transition-fast);
  cursor: pointer;
}

.cell:hover:not(.red):not(.yellow) {
  transform: scale(1.05);
  box-shadow:
    inset 0 4px 8px rgba(0,0,0,0.3),
    inset 0 -2px 4px rgba(255,255,255,0.1),
    0 4px 12px rgba(139, 92, 246, 0.3);
}

.cell.col-highlight {
  animation: highlight 0.3s ease-out;
}

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

.cell.col-highlight::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px dashed var(--accent);
  opacity: 0.5;
  animation: rotate 3s linear infinite;
}

/* Disc Styles */
.cell.red,
.cell.yellow {
  cursor: default;
  border: none;
  transform: scale(1);
}

.cell.red {
  background: radial-gradient(circle at 30% 30%, 
    #ff7979 0%, 
    var(--red) 40%, 
    #991b1b 100%);
  box-shadow:
    0 8px 16px rgba(239, 68, 68, 0.4),
    inset 0 -4px 8px rgba(0,0,0,0.2),
    inset 0 2px 4px rgba(255,255,255,0.3);
}

.cell.yellow {
  background: radial-gradient(circle at 30% 30%, 
    #fde68a 0%, 
    var(--yellow) 40%, 
    #92400e 100%);
  box-shadow:
    0 8px 16px rgba(251, 191, 36, 0.4),
    inset 0 -4px 8px rgba(0,0,0,0.2),
    inset 0 2px 4px rgba(255,255,255,0.3);
}

/* Ghost Preview */
.cell.ghost {
  opacity: 0.4;
  transform: scale(0.95);
  animation: ghostPulse 1s ease-in-out infinite;
}

@keyframes ghostPulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 0.6; transform: scale(1); }
}

.cell.ghost-red {
  background: radial-gradient(circle at 30% 30%, 
    #ff7979 0%, 
    var(--red) 40%, 
    #991b1b 100%);
  box-shadow: 0 0 20px var(--red-glow);
}

.cell.ghost-yellow {
  background: radial-gradient(circle at 30% 30%, 
    #fde68a 0%, 
    var(--yellow) 40%, 
    #92400e 100%);
  box-shadow: 0 0 20px var(--yellow-glow);
}

/* Winning Animation */
.cell.win {
  animation: winCelebrate 1.5s ease-in-out infinite;
  box-shadow:
    0 0 0 4px var(--win),
    0 0 30px var(--win-glow),
    0 8px 16px rgba(16, 185, 129, 0.4),
    inset 0 -4px 8px rgba(0,0,0,0.2),
    inset 0 2px 4px rgba(255,255,255,0.3);
}

@keyframes winCelebrate {
  0%, 100% { 
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
  25% { 
    transform: scale(1.1) rotate(5deg);
    filter: brightness(1.2);
  }
  50% {
    transform: scale(1.05) rotate(-5deg);
    filter: brightness(1.1);
  }
  75% {
    transform: scale(1.1) rotate(3deg);
    filter: brightness(1.2);
  }
}

/* Drop Animation */
.animate-drop {
  animation: dropBounce 350ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform-origin: center;
}

@keyframes dropBounce {
  0% {
    transform: translateY(var(--from-y, -300px)) scale(1.1);
    opacity: 0.8;
  }
  70% {
    transform: translateY(5px) scale(0.95);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ============ Cards & Panels ============ */
.card {
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.03) 0%, 
    rgba(255, 255, 255, 0.01) 100%);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(139, 92, 246, 0.5), 
    transparent);
}

/* Scoreboard */
.scoreboard {
  animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scoreboard-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition-fast);
}

.score-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.player-name {
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge {
  min-width: 48px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 20px;
  transition: var(--transition-fast);
}

.red-badge {
  background: linear-gradient(135deg, var(--red), #dc2626);
  color: white;
  box-shadow: 0 4px 12px var(--red-glow);
}

.yellow-badge {
  background: linear-gradient(135deg, var(--yellow), #f59e0b);
  color: white;
  box-shadow: 0 4px 12px var(--yellow-glow);
}

.draw-badge {
  background: linear-gradient(135deg, #64748b, #475569);
  color: white;
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}

.badge:hover {
  transform: scale(1.1);
}

.score-actions {
  display: flex;
  justify-content: center;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

/* Settings Panel */
.panel details {
  width: 100%;
}

.panel summary {
  list-style: none;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  padding: 16px 20px;
  margin: -24px -24px 0;
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-weight: 700;
  font-size: 18px;
  transition: var(--transition-fast);
  user-select: none;
}

.panel summary:hover {
  background: rgba(139, 92, 246, 0.1);
}

.panel summary::-webkit-details-marker {
  display: none;
}

.summary-icon {
  font-size: 24px;
  animation: spin 4s linear infinite;
}

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

.settings-content {
  margin-top: 24px;
  animation: expandIn 0.3s ease-out;
}

@keyframes expandIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.label-icon {
  font-size: 20px;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  transition: var(--transition-fast);
  outline: none;
}

.field input:hover,
.field select:hover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.05);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.1);
  box-shadow: 0 0 0 4px var(--ring);
}

.size-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.size-separator {
  color: var(--muted);
  font-weight: 700;
  font-size: 18px;
}

.size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.size-presets .chip {
  cursor: pointer;
  transition: var(--transition-fast);
}

.size-presets .chip:hover {
  transform: translateY(-2px);
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent);
}

/* ============ Footer ============ */
.site-footer {
  margin-top: 40px;
  padding: 0;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, 
    transparent 0%, 
    rgba(139, 92, 246, 0.05) 100%);
}

.footer-inner {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 14px;
}

.footer-left,
.footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-left a {
  color: var(--link);
  text-decoration: none;
  transition: var(--transition-fast);
}

.footer-left a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.brand-mini {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ============ Utilities ============ */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

/* ============ Responsive Design ============ */
@media (max-width: 768px) {
  :root {
    --cell-size: clamp(42px, 11vw, 56px);
    --gap: clamp(6px, 1.2vw, 10px);
  }

  .container {
    padding: 0 16px;
  }

  .nav {
    height: 64px;
  }

  .brand {
    font-size: 18px;
  }

  .brand .disc-icon {
    font-size: 20px;
  }

  .game-header {
    padding: 24px 20px;
    margin: 20px 0 16px;
  }

  .title {
    font-size: clamp(28px, 8vw, 36px);
  }

  .subtitle {
    font-size: 16px;
  }

  .settings-summary {
    gap: 8px;
  }

  .chip {
    padding: 8px 12px;
    font-size: 13px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .toolbar-left {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
  }

  .controls-hint {
    text-align: center;
    font-size: 13px;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-icon {
    font-size: 16px;
  }

  .status,
  .thinking {
    font-size: 16px;
    padding: 12px 16px;
  }

  .board {
    padding: clamp(12px, 2vw, 20px);
    margin: 20px auto;
  }

  .card {
    padding: 20px;
    margin: 20px 0;
  }

  .scoreline {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .score-item {
    flex-direction: row;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .panel summary {
    padding: 12px 16px;
    font-size: 16px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    padding: 20px 0;
    min-height: auto;
  }
}

@media (max-width: 480px) {
  :root {
    --cell-size: clamp(38px, 12vw, 48px);
    --gap: clamp(4px, 1vw, 8px);
  }

  .nav {
    height: 56px;
  }

  .game-header {
    padding: 20px 16px;
  }

  .title {
    font-size: clamp(24px, 9vw, 32px);
  }

  .settings-summary {
    flex-direction: column;
    align-items: stretch;
  }

  .chip {
    justify-content: center;
  }

  .board {
    padding: clamp(10px, 1.5vw, 16px);
  }

  .toolbar-left {
    grid-template-columns: 1fr;
  }

  .btn.primary {
    grid-column: 1 / -1;
  }
}

/* ============ Print Styles ============ */
@media print {
  .site-header,
  .site-footer,
  .toolbar,
  .settings-summary,
  .panel {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .board {
    box-shadow: none;
    border: 2px solid black;
  }
}

/* ============ Accessibility ============ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --border: #4b5563;
  }

  .btn {
    border-width: 2px;
  }

  .cell {
    border-width: 3px;
  }
}