/* ============================================
   GAME PAGE & MULTIPLAYER ARENA -- Styles
   ============================================ */

.game-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: var(--spacing-lg) var(--spacing-xl);
  max-width: 1300px;
  margin: 0 auto;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* ============================================
   Game Header & Scoreboard
   ============================================ */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-xl);
  position: relative;
}

.game-page--boardgame .scoreboard {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: var(--spacing-2xl);
  background: rgba(10, 10, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-xl);
  padding: var(--spacing-sm) var(--spacing-2xl);
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
}

.score-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-player-name {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-xs);
}

.score-player-name--left {
  color: var(--accent-primary);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.score-player-name--right {
  color: var(--accent-secondary);
  text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.score-number {
  font-size: var(--font-size-3xl);
  font-weight: 900;
  font-family: monospace; /* Retro-Look */
  line-height: 1;
}

.score-divider {
  font-size: var(--font-size-xl);
  color: var(--text-muted);
  font-weight: 800;
}

.game-timer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

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

.game-timer-value {
  font-size: var(--font-size-xl);
  font-weight: 800;
  color: var(--text-primary);
  font-family: monospace;
}

.game-timer-value--sudden-death {
  color: var(--accent-error);
  animation: pulse-red-text 1s infinite;
}

@keyframes pulse-red-text {
  0% { text-shadow: 0 0 5px rgba(255, 51, 102, 0.5); }
  50% { text-shadow: 0 0 15px rgba(255, 51, 102, 0.9); }
  100% { text-shadow: 0 0 5px rgba(255, 51, 102, 0.5); }
}

/* ============================================
   Arena & Canvas Layout
   ============================================ */
.arena-container {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.game-canvas {
  background: #060613;
  border: 3px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 
              0 0 30px rgba(100, 140, 255, 0.1);
  max-width: 100%;
  height: auto;
  display: block;
}

/* ============================================
   Overlays (Countdown, Goal, Finished)
   ============================================ */
.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-lg);
  pointer-events: none; /* Klicks gehen durch auf das Canvas */
  z-index: 10;
  transition: all var(--transition-base);
}

.overlay-message {
  font-size: var(--font-size-4xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  transform: scale(0.8);
  opacity: 0;
  animation: pop-in-msg 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

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

.overlay-message--countdown {
  color: var(--accent-primary);
  text-shadow: 0 0 25px rgba(0, 240, 255, 0.8);
  font-size: 5rem;
}

.countdown-hint {
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 8px 13px;
  background: rgba(0, 0, 0, .62);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  font-size: .85rem;
}

.rematch-status {
  color: var(--text-secondary);
  font-size: .85rem;
  margin: 10px 0;
}

#rematch-btn {
  margin-right: 8px;
}

.overlay-message--goal {
  color: var(--accent-success);
  text-shadow: 0 0 25px rgba(0, 255, 136, 0.8);
  font-size: 4rem;
  background: rgba(0, 0, 0, 0.6);
  width: 100%;
  padding: var(--spacing-lg) 0;
}

.overlay-message--win {
  color: var(--accent-success);
  text-shadow: 0 0 25px rgba(0, 255, 136, 0.8);
}

.overlay-message--lose {
  color: var(--accent-error);
  text-shadow: 0 0 25px rgba(255, 51, 102, 0.8);
}

/* Endbildschirm */
.game-finished-screen {
  pointer-events: auto; /* Buttons wieder anklickbar machen */
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(10px);
}

.finished-card {
  text-align: center;
  max-width: 400px;
  padding: var(--spacing-2xl);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.finished-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  margin-bottom: var(--spacing-md);
}

.finished-stats {
  margin: var(--spacing-lg) 0;
  color: var(--text-secondary);
}

/* ============================================
   Matchmaking Ladebildschirm
   ============================================ */
.matchmaking-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  text-align: center;
}

.radar-spinner {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 2px dashed var(--accent-primary);
  position: relative;
  margin-bottom: var(--spacing-xl);
  animation: radar-rotate 4s linear infinite;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.15);
}

.radar-spinner::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--accent-primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 15px var(--accent-primary);
}

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

.matchmaking-timer {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  font-family: monospace;
}

/* ============================================
   Header Audio & Global Controls
   ============================================ */
.global-audio-control {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  margin-right: var(--spacing-md);
}

.mute-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  font-size: var(--font-size-md);
}

.mute-btn:hover {
  color: var(--text-primary);
}

/* Der Volume Slider selbst */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 75px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.volume-slider:hover {
  background: rgba(255, 255, 255, 0.25);
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
  transition: transform var(--transition-fast);
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ============================================
   Modal Overlays
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 3, 10, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-card {
  background: rgba(10, 10, 30, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 240, 255, 0.15);
  min-width: 320px;
}

/* Minimal arena treatment */
.game-page {
  background: transparent;
}

.game-header {
  background: #080808;
  border-color: var(--surface-border);
}

.scoreboard {
  background: #050505;
  border-color: var(--surface-border);
  box-shadow: none;
}

.score-player-name--left,
.score-player-name--right {
  color: var(--text-secondary);
  text-shadow: none;
}

.game-canvas {
  background: #030303;
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.modal-overlay,
.game-finished-screen {
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(4px);
}

.modal-card,
.finished-card {
  background: #090909;
  box-shadow: none;
  border-color: var(--surface-border);
}

.score-player-name.rank-noob,
.score-player-name.rank-amateur,
.score-player-name.rank-semi_pro,
.score-player-name.rank-pro,
.score-player-name.rank-grandmaster,
.score-player-name.rank-lunatic,
.score-player-name.rank-hyperlunatic {
  text-shadow: none;
}

.game-page--boardgame {
  box-sizing: border-box;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  padding: var(--spacing-lg) var(--spacing-xl) 14px;
  justify-content: flex-start;
}

.game-page--boardgame .game-header {
  width: min(1300px, 100%);
  margin: 0 auto var(--spacing-md);
  flex-shrink: 0;
}

.game-page--boardgame .game-hint-text {
  display: none !important;
}

.boardgame-layout {
  --board-size: clamp(280px, min(560px, calc(100dvh - 230px), calc(100vw - 580px)), 560px);
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.boardgame-stage {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
}

.boardgame-layout--connect-four .boardgame-stage,
.boardgame-layout--connect-four .boardgame-sidebar {
  height: calc(var(--board-size) * 6 / 7);
}

.board-turn-banner {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 43px);
  min-height: 28px;
  text-align: center;
  color: var(--text-primary);
  font-size: 1.3rem;
  line-height: 1.25;
  font-weight: 700;
}

.board-timers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 13px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  color: var(--text-secondary);
  font-family: monospace;
}

.board-timers > span:nth-child(2) {
  color: var(--text-primary);
  align-self: end;
}

.board-player-time {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-player-time b {
  color: var(--text-muted);
  font: 600 10px/1.2 inherit;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.board-player-time b::before {
  content: attr(data-margin);
  display: block;
  min-height: 12px;
  font: 800 11px/1.1 inherit;
}

.board-player-name--leading::before {
  color: #78f5ad;
}

.board-player-name--trailing::before {
  color: #ff5169;
}

.board-player-time em {
  color: var(--text-primary);
  font-style: normal;
}

.board-player-time--right {
  text-align: right;
}

.board-score-summary {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 78px);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.reversi-game-view,
.connect-four-game-view {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.reversi-board {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  background: #123a29;
  border: 2px solid #304f42;
  border-radius: 10px;
  overflow: hidden;
}

.reversi-square {
  position: relative;
  background: #174c35;
  border: 1px solid rgba(4, 22, 14, .48);
  cursor: pointer;
}

.reversi-square:hover:not(:disabled) {
  background: #1d6043;
}

.reversi-disk {
  display: block;
  position: absolute;
  inset: 12%;
  border-radius: 50%;
}

.reversi-disk--black {
  background: radial-gradient(circle at 35% 28%, #3d3d3d, #070707 65%);
}

.reversi-disk--white {
  background: radial-gradient(circle at 35% 28%, #fff, #cfcfcf 68%);
}

.boardgame-sidebar {
  box-sizing: border-box;
  position: absolute;
  top: 50%;
  left: calc(50% + (var(--board-size) / 2) + 16px);
  transform: translateY(-50%);
  width: 270px;
  height: var(--board-size);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.connect-four-color-tools {
  position: absolute;
  left: calc(-1 * var(--board-size) - 194px);
  top: 50%;
  transform: translateY(-50%);
  width: 168px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 10px;
  background: rgba(7, 7, 8, .85);
}

.connect-four-color-tools label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 11px;
}

.connect-four-color-tools input {
  width: 28px;
  height: 20px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.reversi-rules-tools {
  flex-shrink: 0;
  padding: 10px;
  background: #080808;
}

.reversi-rules-panel {
  max-width: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 10px 3px 1px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.42;
}

.reversi-rules-panel .btn {
  margin-top: 9px;
}

.connect-four-board {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: linear-gradient(142deg, rgba(43, 43, 46, .8), rgba(9, 9, 10, .94));
  border: 1px solid rgba(146, 146, 150, .22);
  border-radius: 16px;
  padding: 10px;
  gap: 6px;
  backdrop-filter: blur(13px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .08),
              inset 0 -18px 40px rgba(0, 0, 0, .27),
              0 18px 46px rgba(0, 0, 0, .5);
}

.connect-four-square {
  position: relative;
  border-radius: 50%;
  border: 1px solid rgba(187, 187, 192, .12);
  background: radial-gradient(circle at 42% 34%, #151517, #050506 68%);
  cursor: pointer;
}

.connect-four-square:hover:not(:disabled) {
  border-color: rgba(236, 236, 236, .6);
  background: radial-gradient(circle at 42% 34%, #1f1f22, #070708 68%);
  box-shadow: 0 0 10px rgba(242, 242, 242, .23);
}

.connect-four-disk {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
}

.connect-four-disk--player1 {
  background: var(--connect-player1, #bd28b8);
}

.connect-four-disk--player2 {
  background: var(--connect-player2, #00ffae);
}

.connect-four-square--winner {
  border-color: rgba(255, 255, 255, .78);
  box-shadow: 0 0 16px rgba(255, 255, 255, .42);
}

.connect-four-disk--winner {
  animation: connect-four-winner-glow .78s ease-in-out infinite alternate;
}

@keyframes connect-four-winner-glow {
  from {
    transform: scale(.94);
    filter: brightness(1.05);
    box-shadow: 0 0 8px rgba(255, 255, 255, .35);
  }
  to {
    transform: scale(1.04);
    filter: brightness(1.3);
    box-shadow: 0 0 25px rgba(255, 255, 255, .94), 0 0 42px rgba(255, 255, 255, .34);
  }
}

.match-chat-panel {
  box-sizing: border-box;
  padding: 14px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.match-chat-panel h3 {
  margin-bottom: 10px;
}

.match-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-chat-message {
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 7px;
}

.match-chat-message span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.match-chat-message p {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.match-chat-form {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.match-chat-form .input-field {
  flex: 1;
  min-width: 0;
}

@media (max-width: 1180px), (max-height: 820px) {
  .game-page--boardgame {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    padding: 12px;
  }

  .game-page--boardgame .game-header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .game-page--boardgame .scoreboard {
    position: static;
    transform: none;
    order: 3;
    width: min(100%, 520px);
    justify-content: center;
  }

  .boardgame-layout {
    --board-size: clamp(260px, min(90vw, 520px, calc(100dvh - 260px)), 520px);
    flex-direction: column;
    justify-content: flex-start;
    gap: 18px;
    margin-top: 72px;
  }

  .boardgame-sidebar {
    position: static;
    transform: none;
    width: var(--board-size);
    height: 320px;
  }

  .connect-four-color-tools {
    position: static;
    transform: none;
    width: var(--board-size);
    max-width: calc(100vw - 48px);
  }
}
