.sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }

#skip-nav:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 9999;
  width: auto;
  height: auto;
  padding: 8px 16px;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--egg-accent, #1a6b8a);
  color: #fff;
  border-radius: var(--egg-radius-sm, 8px);
  font-weight: 600;
  text-decoration: none;
}

:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

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

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

body {
  background: var(--egg-surface, #141420);
  color: var(--egg-text, #e8eaed);
  font-family: var(--egg-font, 'Pretendard', sans-serif);
  overflow: hidden;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout ─── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ─── Scoreboard ─── */
#scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--egg-surface-raised, #1e1e30);
  border-bottom: 1px solid var(--egg-border);
  font-size: 13px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.player {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.4;
  transition: all 0.25s ease;
  padding: 4px 10px;
  border-radius: var(--egg-radius-sm, 8px);
  font-weight: 500;
}

.player.active {
  opacity: 1;
  background: rgba(255,255,255,0.06);
}

.player strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  text-align: center;
}

.p1.active strong { color: #5bc0eb; }
.p2.active strong { color: #fde74c; }

.ball-icons {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
}

.ball-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 6px;
  line-height: 12px;
  text-align: center;
  color: #fff;
  font-weight: 700;
}

.ball-icon.potted {
  opacity: 0.3;
}

.turn-indicator {
  font-size: 10px;
  color: #5bc0eb;
  transition: color 0.25s ease;
}
.turn-indicator.p2-turn { color: #fde74c; }

.group-label {
  font-size: 10px;
  color: var(--egg-text-muted);
  margin-left: 2px;
}

/* ─── Game Container ─── */
#game-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 8px 4px;
  contain: layout style;
}

#canvas {
  border-radius: 4px;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  will-change: transform;
}

/* ─── Bottom Panel ─── */
#bottom-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 6px 16px;
  background: var(--egg-surface-raised, #1e1e30);
  border-top: 1px solid var(--egg-border);
  flex-shrink: 0;
}

#spin-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

#spin-canvas {
  cursor: pointer;
  border-radius: 50%;
}

#power-bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

#power-bar {
  flex: 1;
  min-width: 60px;
  height: 20px;
  background: var(--egg-surface, #141420);
  border-radius: 99px;
  border: 1px solid var(--egg-border);
  overflow: hidden;
  display: flex;
  cursor: pointer;
  touch-action: none;
}

#power-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #1a6b8a, #fde74c, #f4511e);
  border-radius: 99px 0 0 99px;
  transition: width 50ms;
}

.panel-label {
  font-size: 10px;
  color: var(--egg-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ─── Message Toast ─── */
#message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--egg-surface-raised, #1e1e30);
  color: var(--egg-text, #e8eaed);
  padding: 16px 32px;
  border-radius: var(--egg-radius, 12px);
  border: 1px solid var(--egg-border);
  font-size: 18px;
  font-weight: 700;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: fadeInOut 2.5s ease forwards;
  text-align: center;
  max-width: 85vw;
}

.hidden { display: none !important; }

@keyframes fadeInOut {
  0%  { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
  70% { opacity: 1; }
  100%{ opacity: 0; transform: translate(-50%,-50%) scale(0.95); }
}

/* ─── Controls ─── */
#controls {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--egg-surface-raised, #1e1e30);
  border-top: 1px solid var(--egg-border);
  flex-shrink: 0;
}

#controls button {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--egg-border);
  background: var(--egg-surface, #141420);
  color: var(--egg-text, #e8eaed);
  border-radius: var(--egg-radius-sm, 8px);
  font-family: var(--egg-font, 'Pretendard', sans-serif);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

#controls button:active {
  background: var(--egg-surface-raised, #1e1e30);
  transform: scale(0.97);
}

#controls button:disabled {
  opacity: 0.25;
  cursor: default;
  transform: none;
}

/* ─── Start Screen ─── */
#start-screen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#start-modal {
  background: var(--egg-surface-raised, #1e1e30);
  border: 1px solid var(--egg-border);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  max-width: 320px;
  width: 90%;
}

.start-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

#start-modal h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--egg-accent, #1a6b8a);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

#start-modal p {
  font-size: 14px;
  color: var(--egg-text-muted);
  margin-bottom: 24px;
}

#player-select {
  display: flex;
  gap: 12px;
}

.player-btn {
  flex: 1;
  padding: 20px 12px;
  background: var(--egg-surface, #141420);
  border: 1px solid var(--egg-border);
  border-radius: var(--egg-radius, 12px);
  color: var(--egg-text, #e8eaed);
  font-family: var(--egg-font, 'Pretendard', sans-serif);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.player-btn span {
  font-size: 12px;
  font-weight: 400;
  color: var(--egg-text-muted);
}

.player-btn:hover, .player-btn:active {
  border-color: var(--egg-accent, #1a6b8a);
  background: rgba(26,107,138,0.1);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26,107,138,0.15);
}

@media (max-width: 480px) {
  #scoreboard {
    padding: 6px 10px;
    font-size: 11px;
    gap: 8px;
  }
  .player { padding: 3px 6px; }
  #bottom-panel { gap: 12px; padding: 5px 10px; }
  #start-modal,
  #game-over-modal { padding: 20px; }
  .start-icon { font-size: 36px; }
  #start-modal h2 { font-size: 20px; }
  #start-modal p { font-size: 12px; }
  .player-btn { padding: 14px 8px; font-size: 20px; }
  #controls button { font-size: 12px; padding: 8px; }
  .ball-icon { width: 10px; height: 10px; font-size: 5px; line-height: 10px; }
}

@media (max-height: 560px) {
  #scoreboard {
    padding: 3px 8px;
    font-size: 10px;
    gap: 6px;
  }
  .player { padding: 2px 5px; }
  .ball-icon { width: 9px; height: 9px; font-size: 5px; line-height: 9px; }
  .group-label { font-size: 9px; }
  #game-container { padding: 4px 4px 2px; }
  #bottom-panel { gap: 10px; padding: 3px 8px; }
  #power-bar { height: 16px; }
  #power-bar-wrap { gap: 4px; }
  #controls { padding: 4px 8px; gap: 6px; }
  #controls button { padding: 6px; font-size: 11px; }
  .panel-label { font-size: 9px; }
  #start-modal,
  #game-over-modal { padding: 20px 24px; max-width: 280px; }
  .start-icon { font-size: 32px; }
  #start-modal h2 { font-size: 18px; }
  #start-modal p { margin-bottom: 16px; font-size: 12px; }
  .player-btn { padding: 12px 8px; font-size: 18px; }
  #game-over-modal h2 { font-size: 22px; }
  #game-over-modal button { padding: 10px 24px; font-size: 14px; }
}

@media (max-width: 360px) {
  #scoreboard { font-size: 9px; gap: 4px; padding: 3px 6px; }
  .player { padding: 2px 4px; gap: 2px; }
  .ball-icon { width: 8px; height: 8px; font-size: 4px; line-height: 8px; }
  #bottom-panel { gap: 6px; padding: 4px 6px; }
  #power-bar { min-width: 40px; }
  #controls { padding: 6px 8px; gap: 4px; }
  #controls button { font-size: 11px; padding: 7px 4px; }
  #start-modal,
  #game-over-modal { padding: 18px; max-width: 240px; }
  .player-btn { padding: 12px 6px; font-size: 16px; }
}

@media (min-width: 768px) {
  #scoreboard {
    font-size: 14px;
    padding: 10px 20px;
    gap: 16px;
  }
  .player { padding: 5px 12px; }
  #bottom-panel { gap: 24px; padding: 8px 20px; }
}

@media (min-width: 1024px) {
  #scoreboard { font-size: 16px; }
  #start-modal,
  #game-over-modal { max-width: 400px; }
  #controls button { font-size: 15px; }
}

@media (min-width: 1440px) {
  #scoreboard {
    font-size: 18px;
    padding: 12px 24px;
    gap: 24px;
  }
  .player { padding: 6px 14px; }
  #bottom-panel { gap: 28px; padding: 10px 24px; }
  #start-modal,
  #game-over-modal { max-width: 440px; padding: 40px 44px; }
  #controls button { font-size: 16px; padding: 12px; }
}

/* ─── Game Over Overlay ─── */
#game-over {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.3s ease;
}

#game-over-modal {
  background: var(--egg-surface-raised, #1e1e30);
  border: 1px solid var(--egg-border);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  max-width: 320px;
  width: 90%;
}

#game-over-modal h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

#game-over-modal p {
  font-size: 14px;
  color: var(--egg-text-muted);
  margin-bottom: 20px;
}

#game-over-modal button {
  padding: 12px 32px;
  background: var(--egg-accent, #1a6b8a);
  border: none;
  border-radius: var(--egg-radius-sm, 8px);
  color: #fff;
  font-family: var(--egg-font, 'Pretendard', sans-serif);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

#game-over-modal button:active {
  transform: scale(0.97);
}
