/* ============================================
   KMS Reversi 3D - Premium Styling
   ============================================ */

:root {
  /* Color Palette - Emerald & Gold */
  --bg-primary: #0a0f0d;
  --bg-secondary: #0d1a14;
  --bg-card: rgba(13, 26, 20, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --emerald-primary: #2ecc71;
  --emerald-light: #55efc4;
  --emerald-dark: #1a7a42;
  --emerald-glow: rgba(46, 204, 113, 0.4);

  --gold-primary: #d4a853;
  --gold-light: #f0d78c;
  --gold-dark: #8b6914;
  --gold-glow: rgba(212, 168, 83, 0.4);

  --board-green: #1b6b3a;
  --board-green-light: #228b4a;
  --board-green-dark: #145228;
  --board-border: #d4a853;
  --board-line: rgba(0, 0, 0, 0.25);

  --white-piece: #f0ece4;
  --white-piece-light: #ffffff;
  --white-piece-dark: #c8c0b0;
  --white-glow: rgba(240, 236, 228, 0.5);

  --black-piece: #1a1a2e;
  --black-piece-light: #2d2d44;
  --black-piece-dark: #0d0d1a;
  --black-glow: rgba(26, 26, 46, 0.5);

  --text-primary: #f0f0f0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;

  --highlight-valid: rgba(46, 204, 113, 0.45);
  --highlight-hint: rgba(255, 215, 0, 0.6);
  --highlight-last: rgba(139, 92, 246, 0.4);
  --highlight-flip: rgba(59, 130, 246, 0.4);

  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hard: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-emerald: 0 0 30px rgba(46, 204, 113, 0.3);
  --shadow-glow-gold: 0 0 30px rgba(212, 168, 83, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  --font-display: "Cinzel", serif;
  --font-body: "Inter", sans-serif;

  --cell-size: 64px;
  --piece-size: 52px;
  --board-gap: 2px;
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: radial-gradient(ellipse at center, #0d1a14 0%, #0a0f0d 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
}

.loading-piece-container {
  margin-bottom: 30px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.loading-disc {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: relative;
  animation: loadingBounce 1.5s ease-in-out infinite;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.loading-disc-black {
  background: radial-gradient(circle at 35% 35%, #3d3d5c, #1a1a2e 60%, #0d0d1a);
  border: 3px solid #2d2d44;
  animation-delay: 0s;
}

.loading-disc-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #f0ece4 60%, #c8c0b0);
  border: 3px solid #e0d8c8;
  animation-delay: -0.75s;
}

@keyframes loadingBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-25px) scale(1.05);
  }
}

.loading-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--emerald-light),
    var(--emerald-primary),
    var(--emerald-dark)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 30px;
  letter-spacing: 3px;
}

.loading-bar-container {
  width: 240px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 0 auto 16px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--emerald-primary),
    var(--emerald-light)
  );
  border-radius: 2px;
  transition: width 0.3s ease;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ============================================
   Main Menu
   ============================================ */
.main-menu {
  background: radial-gradient(ellipse at 50% 30%, #0d1a14 0%, #0a0f0d 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.menu-bg-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.menu-bg-particles .particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--emerald-primary);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    opacity: 0;
    transform: translateY(-20vh) scale(1);
  }
}

.menu-content {
  text-align: center;
  z-index: 2;
  position: relative;
}

.menu-logo {
  margin-bottom: 50px;
}

.logo-pieces {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 24px;
}

.logo-disc {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  position: relative;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transform-style: preserve-3d;
}

.logo-disc-black {
  background: radial-gradient(circle at 35% 35%, #4d4d6c, #1a1a2e 60%, #0d0d1a);
  border: 3px solid #3d3d5c;
  animation: logoFloat 3s ease-in-out infinite;
}

.logo-disc-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #f0ece4 60%, #c8c0b0);
  border: 3px solid #e0d8c8;
  animation: logoFloat 3s ease-in-out infinite;
  animation-delay: -1.5s;
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0) rotateY(0deg);
  }
  25% {
    transform: translateY(-12px) rotateY(10deg);
  }
  75% {
    transform: translateY(-8px) rotateY(-10deg);
  }
}

.menu-title {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 900;
  background: linear-gradient(
    135deg,
    var(--emerald-light) 0%,
    var(--emerald-primary) 50%,
    var(--gold-primary) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.menu-subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 6px;
  text-transform: uppercase;
  font-weight: 300;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.game-footer {
  position: absolute;
  bottom: 30px;
  left: 0;
  width: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-body);
  letter-spacing: 1px;
  pointer-events: none;
}

/* Buttons */
.menu-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 40px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 260px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.menu-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.menu-btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--emerald-dark),
    var(--emerald-primary)
  );
  color: #fff;
  box-shadow: 0 4px 20px rgba(46, 204, 113, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(46, 204, 113, 0.5);
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
  border-color: var(--emerald-primary);
}

.btn-icon {
  font-size: 1.3rem;
}

/* Language Toggle */
.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  padding: 4px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
}

.lang-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
}

.lang-btn.active {
  background: var(--emerald-primary);
  color: #fff;
}

/* ============================================
   Modal Screens
   ============================================ */
.modal-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-screen.hidden {
  display: none !important;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  min-width: 380px;
  max-width: 500px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-hard);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(
    135deg,
    var(--emerald-light),
    var(--emerald-primary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 24px;
}

.modal-close-btn {
  display: block;
  margin: 24px auto 0;
  padding: 10px 32px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Difficulty Selection */
.difficulty-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diff-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: left;
  color: var(--text-primary);
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--emerald-primary);
  transform: translateX(4px);
}

.diff-icon {
  font-size: 1.8rem;
}

.diff-label {
  font-size: 1.1rem;
  font-weight: 600;
  display: block;
}

.diff-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* Settings */
.settings-card {
  min-width: 400px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-label {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 26px;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: all var(--transition-normal);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--emerald-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Language Select in Settings */
.lang-select {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 3px;
}

.lang-option {
  padding: 6px 14px;
  border: none;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  background: transparent;
  transition: all var(--transition-fast);
}

.lang-option.active {
  background: var(--emerald-primary);
  color: #fff;
}

/* Tutorial */
.tutorial-card {
  min-width: 500px;
  max-width: 600px;
  max-height: 80vh;
}

.tutorial-content {
  min-height: 300px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.tutorial-content::-webkit-scrollbar {
  width: 6px;
}

.tutorial-content::-webkit-scrollbar-thumb {
  background: var(--emerald-dark);
  border-radius: 3px;
}

.tutorial-page {
  display: none;
}

.tutorial-page.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.tutorial-page h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--emerald-primary);
  margin-bottom: 12px;
}

.tutorial-page p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.tutorial-demo-board {
  display: inline-grid;
  grid-template-columns: repeat(4, 40px);
  gap: 2px;
  padding: 8px;
  background: var(--board-green-dark);
  border-radius: 6px;
  margin: 12px 0;
}

.tutorial-demo-cell {
  width: 40px;
  height: 40px;
  background: var(--board-green);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-mini-disc {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.tutorial-mini-disc.black {
  background: radial-gradient(circle at 35% 35%, #3d3d5c, #1a1a2e);
}

.tutorial-mini-disc.white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8e0d0);
}

.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tut-nav-btn {
  padding: 8px 20px;
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tut-nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.tut-page-indicator {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   Game Screen
   ============================================ */
.game-screen {
  background: radial-gradient(ellipse at 50% 40%, #0d1a14 0%, #0a0f0d 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  overflow-y: auto;
  padding-bottom: 80px; /* Space for the copyright footer */
}

/* Top Bar */
.game-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.game-title-bar {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--emerald-primary);
  letter-spacing: 2px;
}

.top-bar-controls {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--emerald-primary);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Player Info Panels */
.player-info {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all var(--transition-normal);
  min-width: 340px;
  flex-shrink: 0;
}

.player-info.active-player {
  border-color: var(--emerald-primary);
  box-shadow:
    0 0 20px rgba(46, 204, 113, 0.15),
    inset 0 0 20px rgba(46, 204, 113, 0.05);
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
}

.player-avatar-black {
  background: radial-gradient(circle at 35% 35%, #3d3d5c, #1a1a2e);
  border: 2px solid #2d2d44;
  color: #999;
}

.player-avatar-white {
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8e0d0);
  border: 2px solid #d4ccb8;
  color: #555;
}

.player-details {
  flex: 1;
}

.player-name {
  font-size: 0.95rem;
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.player-score-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.player-score {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--emerald-primary);
  min-width: 48px;
  text-align: center;
}

.players-container {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 12px 20px;
  flex-shrink: 0;
}

/* ============================================
   Game Board - 3D Effect
   ============================================ */
.board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  flex-shrink: 0;
}

.board-frame {
  position: relative;
  padding: 12px;
  background: linear-gradient(145deg, #c9982e, #8b6914);
  border-radius: 12px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(212, 168, 83, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: perspective(1200px) rotateX(4deg);
  transition: transform 0.5s ease;
}

.board-inner {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--board-gap);
  background: var(--board-green-dark);
  border-radius: 6px;
  padding: 4px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
}

.board-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--board-green);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.board-cell:hover {
  background: var(--board-green-light);
}

.board-cell.valid-move {
  cursor: pointer;
}

.board-cell.valid-move::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--highlight-valid);
  animation: validPulse 2s ease-in-out infinite;
}

@keyframes validPulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.board-cell.hint-cell::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--highlight-hint);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
  animation: hintGlow 1.5s ease-in-out infinite;
}

@keyframes hintGlow {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.board-cell.last-move {
  box-shadow: inset 0 0 0 2px var(--highlight-last);
}

/* Coordinate Labels */
.board-coords-top,
.board-coords-bottom {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  gap: var(--board-gap);
  padding: 0 4px;
  margin-bottom: 4px;
}
.board-coords-bottom {
  margin-top: 4px;
  margin-bottom: 0;
}

.board-coords-left,
.board-coords-right {
  display: grid;
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--board-gap);
  padding: 4px 0;
}

.coord-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  user-select: none;
}

/* ============================================
   Game Pieces - 3D Discs
   ============================================ */
.game-piece {
  width: var(--piece-size);
  height: var(--piece-size);
  border-radius: 50%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  cursor: default;
}

.game-piece.piece-black {
  transform: rotateY(0deg);
}

.game-piece.piece-white {
  transform: rotateY(180deg);
}

.piece-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  backface-visibility: hidden;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.piece-face-black {
  background: radial-gradient(
    circle at 35% 35%,
    #4d4d6c,
    #1a1a2e 55%,
    #0d0d1a 85%
  );
  border: 2.5px solid #2d2d44;
  z-index: 2;
}

.piece-face-white {
  background: radial-gradient(
    circle at 35% 35%,
    #ffffff,
    #f0ece4 55%,
    #c8c0b0 85%
  );
  border: 2.5px solid #e0d8c8;
  transform: rotateY(180deg);
  z-index: 1;
}

/* Piece edge / thickness */
.piece-edge {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  transform: translateZ(-3px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

.game-piece.piece-black .piece-edge {
  background: linear-gradient(180deg, #2a2a44, #15152a);
}

.game-piece.piece-white .piece-edge {
  background: linear-gradient(180deg, #d4ccb8, #b8b0a0);
}

/* Flip animation */
.game-piece.flipping {
  animation: flipPiece 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes flipPiece {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  30% {
    transform: rotateY(90deg) scale(1.15) translateY(-6px);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

.game-piece.flipping-reverse {
  animation: flipPieceReverse 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes flipPieceReverse {
  0% {
    transform: rotateY(180deg) scale(1);
  }
  30% {
    transform: rotateY(90deg) scale(1.15) translateY(-6px);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

/* Place animation */
.game-piece.placing {
  animation: placePiece 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes placePiece {
  0% {
    transform: scale(0) rotateY(0deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.game-piece.placing-white {
  animation: placePieceWhite 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes placePieceWhite {
  0% {
    transform: scale(0) rotateY(180deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotateY(180deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotateY(180deg);
    opacity: 1;
  }
}

/* ============================================
   Turn Indicator
   ============================================ */
.turn-indicator {
  text-align: center;
  padding: 8px 24px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--emerald-primary);
  min-width: 200px;
  flex-shrink: 0;
  margin: 6px 0;
}

.turn-indicator.pass-alert {
  border-color: #e74c3c;
  color: #e74c3c;
  animation: passFlash 0.5s ease 3;
}

@keyframes passFlash {
  0%,
  100% {
    background: var(--bg-glass);
  }
  50% {
    background: rgba(231, 76, 60, 0.15);
  }
}

/* ============================================
   Game Over Overlay
   ============================================ */
.game-over-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
}

.game-over-card {
  text-align: center;
  padding: 48px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-hard), var(--shadow-glow-emerald);
  animation: gameOverIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 360px;
}

@keyframes gameOverIn {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(40px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.game-over-crown {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: crownBounce 1s ease-in-out infinite;
}

@keyframes crownBounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(5deg);
  }
}

.game-over-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(
    135deg,
    var(--emerald-light),
    var(--gold-primary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.game-over-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.game-over-score {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: var(--font-display);
  margin-bottom: 28px;
}

.game-over-score .score-black {
  color: #999;
}

.game-over-score .score-white {
  color: #f0ece4;
}

.game-over-score .score-separator {
  color: var(--text-muted);
  margin: 0 12px;
}

.game-over-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* Game Menu */
.game-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   Confetti
   ============================================ */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 650;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  opacity: 0.9;
  animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-10px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  :root {
    --cell-size: 48px;
    --piece-size: 40px;
  }

  .board-frame {
    padding: 8px;
    transform: perspective(1200px) rotateX(2deg);
  }

  .player-info {
    min-width: 260px;
    padding: 10px 14px;
  }

  .players-container {
    gap: 10px;
    padding: 8px 12px;
  }

  .menu-title {
    font-size: 2.2rem;
  }

  .modal-card {
    min-width: 320px;
    padding: 24px;
  }

  .tutorial-card {
    min-width: 340px;
    max-width: 95vw;
  }

  .settings-card {
    min-width: 320px;
  }
}

@media (max-width: 600px) {
  :root {
    --cell-size: 40px;
    --piece-size: 32px;
  }

  .board-frame {
    padding: 6px;
    transform: none;
  }

  .players-container {
    flex-direction: column;
    align-items: center;
  }

  .player-info {
    min-width: auto;
    width: 100%;
    max-width: 320px;
  }

  .menu-title {
    font-size: 1.8rem;
    letter-spacing: 3px;
  }

  .menu-subtitle {
    letter-spacing: 3px;
    font-size: 0.8rem;
  }

  .logo-disc {
    width: 50px;
    height: 50px;
  }

  .game-top-bar {
    padding: 8px 12px;
  }

  .turn-indicator {
    font-size: 0.8rem;
    padding: 6px 16px;
  }
}

@media (max-height: 750px) {
  :root {
    --cell-size: 44px;
    --piece-size: 36px;
  }

  .players-container {
    padding: 6px 20px;
  }

  .player-info {
    padding: 8px 14px;
  }

  .board-container {
    padding: 4px;
  }

  .board-frame {
    padding: 8px;
  }

  .turn-indicator {
    margin: 4px 0;
    padding: 5px 20px;
  }
}
