:root {
  --bg-color: #0a0b12;
  --panel-bg: rgba(16, 18, 28, 0.88);
  --text-color: #ffffff;
  --primary-color: #ff3b6b;
  --primary-hover: #e60039;
  --cyan-color: #00e5ff;
  --secondary-color: #ff0055;
  --secondary-hover: #d50046;
  --accent-color: #ffb700;
  --card-bg: rgba(255, 255, 255, 0.05);
  --border-color: rgba(255, 255, 255, 0.12);
  --pixel-border: 4px solid #ff3b6b;
  --font-pixel: 'Press Start 2P', monospace;
  --font-sans: 'Outfit', sans-serif;
  --font-display: 'Jura', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #f9f8ec;
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  position: relative;
  background-image: url('./images/bg.jpg');
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.12);
  pointer-events: none;
  z-index: 1;
}

/* Background Particle Canvas */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
}

#app {
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 2;
  padding: 15px;
}

/* Orientation Warning */
#orientation-warning {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #07080f;
  color: #ff0055;
  font-family: var(--font-pixel), var(--font-sans);
  font-size: 1.1rem;
  z-index: 99999999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  gap: 16px;
}

#orientation-warning .phone-rotate-icon {
  color: #00e5ff;
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.6));
  animation: rotatePhone 2.2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

#orientation-warning p {
  letter-spacing: 1.5px;
  line-height: 1.5;
  text-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
}

@keyframes rotatePhone {
  0%, 15% { transform: rotate(0deg); }
  45%, 65% { transform: rotate(-90deg); }
  90%, 100% { transform: rotate(0deg); }
}

@media screen and (orientation: landscape) and (max-height: 650px) {
  #orientation-warning {
    display: flex !important;
  }
  #app {
    display: none !important;
  }
}

/* Screen Transitions */
.screen {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: screenFadeIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.screen.active {
  display: flex;
}

@keyframes screenFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Glass Screen Panel */
.screen-panel {
  background: linear-gradient(165deg, rgba(20, 25, 40, 0.96) 0%, rgba(11, 14, 24, 0.98) 100%);
  padding: 36px 30px;
  border-radius: 26px;
  border: 3px solid #00e5ff;
  box-shadow: 
    0 0 24px rgba(0, 229, 255, 0.45),
    0 25px 60px rgba(0, 0, 0, 0.95),
    inset 0 0 16px rgba(0, 229, 255, 0.15);
  width: 100%;
  max-width: 450px;
  text-align: center;
  position: relative;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.screen-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  border-radius: 2px;
}

.game-title {
  font-family: var(--font-pixel);
  font-size: 2.2rem;
  margin-bottom: 8px;
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2), 3px 3px 0px #000;
  letter-spacing: 4px;
}

.game-subtitle {
  color: #9499b0;
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.screen-title {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  color: #ffffff;
  margin-bottom: 20px;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

/* Menu Buttons Stack */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.btn {
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
}

/* Premium 3D Crimson Red Start Button */
.primary-btn {
  background: linear-gradient(180deg, #ff3b6b 0%, #cc0033 100%);
  color: #ffffff;
  border: 1px solid #ff668c;
  border-radius: 16px;
  font-family: var(--font-pixel);
  font-size: 1rem;
  letter-spacing: 1px;
  padding: 16px 24px;
  box-shadow: 
    0 6px 0 #880022,
    0 8px 15px rgba(255, 59, 107, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #ff4d7a 0%, #e60039 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 8px 0 #880022,
    0 10px 20px rgba(255, 59, 107, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #880022,
    0 4px 10px rgba(255, 59, 107, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.secondary-btn {
  background: linear-gradient(135deg, #ff0055 0%, #ff5500 100%);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(ff, 0, 85, 0.4);
  font-family: var(--font-display);
  font-weight: 700;
}

.secondary-btn:hover {
  background: linear-gradient(135deg, #ff3377 0%, #ff7733 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(255, 0, 85, 0.6);
}

.bot-btn {
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
  font-family: var(--font-display);
  font-weight: 700;
}

.bot-btn:hover {
  background: linear-gradient(135deg, #b866ff 0%, #7578ff 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(168, 85, 247, 0.6);
}

.text-btn {
  background: transparent;
  color: #a0a0c0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.text-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}

/* Setup Form Elements */
.setup-group {
  margin-bottom: 20px;
  text-align: left;
}

.setup-label {
  display: block;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  margin-bottom: 10px;
  letter-spacing: 0.8px;
}

.leader-badge {
  display: inline-block;
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--accent-color);
  background: rgba(255, 230, 0, 0.15);
  border: 1px dashed var(--accent-color);
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.side-status-tag {
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 8px;
  color: #a0a0c0;
}

.side-btn.taken-by-other {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.1);
}

.size-selector.disabled {
  pointer-events: none;
  opacity: 0.75;
}

.side-summary-badge {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(217, 0, 255, 0.16) 0%, rgba(138, 43, 226, 0.28) 100%);
  border: 1.5px solid #d900ff;
  box-shadow: 0 0 12px rgba(217, 0, 255, 0.2);
  padding: 10px 16px;
  border-radius: 12px;
  margin-top: 14px;
  text-align: center;
  line-height: 1.5;
}

.side-summary-badge strong {
  color: #ffffff;
  font-weight: 700;
}

.side-selector {
  display: flex;
  gap: 14px;
}

.side-btn {
  flex: 1;
  padding: 16px 12px;
  background: linear-gradient(180deg, rgba(42, 52, 78, 0.85) 0%, rgba(24, 31, 48, 0.92) 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.side-btn:hover:not(.taken-by-other) {
  background: linear-gradient(180deg, rgba(56, 70, 104, 0.95) 0%, rgba(32, 42, 66, 0.98) 100%);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.side-btn:active:not(.taken-by-other) {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.side-btn[data-side="X"].active {
  border-color: #00e5ff;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.25) 0%, rgba(0, 130, 175, 0.4) 100%);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.side-btn[data-side="O"].active {
  border-color: #ff0055;
  background: linear-gradient(180deg, rgba(255, 0, 85, 0.25) 0%, rgba(180, 0, 60, 0.4) 100%);
  box-shadow: 0 0 12px rgba(255, 0, 85, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.pixel-symbol {
  font-family: var(--font-pixel);
  font-size: 1.8rem;
  transition: transform 0.2s ease;
}

.side-btn.active .pixel-symbol {
  transform: scale(1.15);
}

.sym-x {
  color: #00e5ff;
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.35);
}

.sym-o {
  color: #ff0055;
  text-shadow: 0 0 6px rgba(255, 0, 85, 0.35);
}

.size-selector {
  display: flex;
  gap: 12px;
}

.size-btn {
  flex: 1;
  padding: 14px 8px;
  background: linear-gradient(180deg, rgba(40, 50, 75, 0.85) 0%, rgba(22, 28, 44, 0.92) 100%);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.size-btn:hover {
  background: linear-gradient(180deg, rgba(54, 68, 100, 0.95) 0%, rgba(30, 40, 62, 0.98) 100%);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.size-btn:active {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.size-btn.active {
  border-color: #00e5ff;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.22) 0%, rgba(0, 130, 175, 0.35) 100%);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.size-title {
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  color: #ffffff;
}

.size-btn.active .size-title {
  color: #00e5ff;
  text-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

.size-desc {
  font-size: 0.7rem;
  color: #a0a0c0;
  margin-top: 5px;
  font-weight: 500;
}

.size-btn.active .size-desc {
  color: #ffffff;
  font-weight: 600;
}

.input-group {
  margin-bottom: 10px;
}

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-group input:focus {
  border-color: var(--primary-color);
}

/* Online Waiting Room */
.room-code-badge {
  background: rgba(0, 229, 255, 0.1);
  border: 2px dashed var(--primary-color);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1rem;
}

.room-code-badge strong {
  font-family: var(--font-pixel);
  color: var(--accent-color);
  font-size: 1.3rem;
  letter-spacing: 2px;
}

.room-code-badge button {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.room-code-badge button:hover {
  transform: scale(1.2);
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.pulse-text {
  font-size: 0.9rem;
  color: #a0a0c0;
  animation: pulseOpacity 1.5s infinite ease-in-out;
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Game Screen Elements */
#game-screen {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.game-header-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 440px;
  margin: 0 auto 12px auto;
  background: linear-gradient(165deg, rgba(20, 25, 40, 0.96) 0%, rgba(11, 14, 24, 0.98) 100%);
  padding: 14px 20px;
  border-radius: 20px;
  border: 3px solid #00e5ff;
  box-shadow: 
    0 0 20px rgba(0, 229, 255, 0.4),
    0 15px 35px rgba(0, 0, 0, 0.85),
    inset 0 0 12px rgba(0, 229, 255, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.player-symbol {
  font-family: var(--font-pixel);
  font-size: 1.6rem;
  line-height: 1;
}

.player-card.card-o {
  justify-content: flex-end;
}

.player-info {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.player-score {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.35rem;
  color: #ffffff;
}

.turn-status-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  position: relative;
}

.sound-toggle-btn {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.22) 0%, rgba(0, 120, 160, 0.35) 100%);
  border: 1.5px solid #00e5ff;
  color: #00e5ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 
    0 2px 0 #007799,
    0 0 8px rgba(0, 229, 255, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 5;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.sound-toggle-btn:hover {
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.38) 0%, rgba(0, 150, 200, 0.5) 100%);
  border-color: #66f5ff;
  transform: scale(1.12);
  box-shadow: 
    0 3px 0 #007799,
    0 0 14px rgba(0, 229, 255, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.sound-toggle-btn:active {
  transform: translateY(1px);
  box-shadow: 
    0 1px 0 #007799,
    0 2px 5px rgba(0, 0, 0, 0.5);
}

.sound-toggle-btn.muted {
  background: linear-gradient(180deg, rgba(45, 18, 26, 0.95) 0%, rgba(22, 10, 15, 0.98) 100%);
  border-color: #ff0055;
  color: #ff0055;
  box-shadow: 
    0 2px 0 #880022,
    0 0 8px rgba(255, 0, 85, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.sound-toggle-btn.muted:hover {
  background: linear-gradient(180deg, rgba(65, 22, 35, 0.98) 0%, rgba(35, 12, 22, 1) 100%);
  border-color: #ff3377;
  transform: scale(1.12);
  box-shadow: 
    0 3px 0 #880022,
    0 0 14px rgba(255, 0, 85, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.turn-label {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.7rem;
  color: #9499b0;
  letter-spacing: 1.5px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.turn-badge {
  font-family: var(--font-pixel);
  font-size: 1.6rem;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  line-height: 1;
}

.turn-badge.turn-x {
  color: #00e5ff;
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.turn-badge.turn-o {
  color: #ff0055;
  text-shadow: 0 0 8px rgba(255, 0, 85, 0.4);
}

.rule-reminder-bar {
  text-align: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8rem;
  color: #a0a0c0;
  margin-bottom: 14px;
  letter-spacing: 0.5px;
}

/* Board Wrapper & Dynamic Grid */
.board-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 440px;
  margin: 0 auto 20px auto;
  padding: 10px;
  background: var(--panel-bg);
  border-radius: 20px;
  border: 3px solid #00e5ff;
  box-shadow: 
    0 0 24px rgba(0, 229, 255, 0.45),
    0 15px 35px rgba(0, 0, 0, 0.8),
    inset 0 0 16px rgba(0, 229, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#xox-board {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 8px;
}

#xox-board.grid-3x3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

#xox-board.grid-5x5 {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 5px;
}

#xox-board.grid-7x7 {
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
}

.cell {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

#xox-board.grid-5x5 .cell { border-radius: 8px; }
#xox-board.grid-7x7 .cell { border-radius: 6px; }

.cell:hover:not(.taken) {
  background: rgba(255, 255, 255, 0.12);
  border-color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.cell.taken {
  cursor: not-allowed;
}

.cell .symbol-x {
  font-family: var(--font-pixel);
  color: #00e5ff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.8);
  animation: popSymbol 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.cell .symbol-o {
  font-family: var(--font-pixel);
  color: var(--secondary-color);
  text-shadow: 0 0 12px rgba(255, 0, 85, 0.8);
  animation: popSymbol 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#xox-board.grid-3x3 .cell { font-size: 2.5rem; }
#xox-board.grid-5x5 .cell { font-size: 1.5rem; }
#xox-board.grid-7x7 .cell { font-size: 1.05rem; }

@keyframes popSymbol {
  from {
    transform: scale(0.2) rotate(-15deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.cell.winning-cell {
  background: linear-gradient(180deg, rgba(217, 0, 255, 0.28) 0%, rgba(138, 43, 226, 0.38) 100%) !important;
  border-color: #d900ff !important;
  box-shadow: 0 0 16px rgba(217, 0, 255, 0.5) !important;
  animation: winPulse 0.8s infinite alternate;
}

@keyframes winPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.game-controls {
  display: flex;
  gap: 14px;
  width: 100%;
  max-width: 440px;
  justify-content: center;
  margin-top: 5px;
}

.btn-control {
  flex: 1;
  padding: 13px 18px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Yeniden Başlat (Solid 3D Cyan Blue Button - No Neon Glow) */
#btn-restart-game {
  background: linear-gradient(180deg, #00b4d8 0%, #0077b6 100%);
  color: #ffffff;
  border: 1px solid #73d2de;
  border-radius: 16px;
  padding: 15px 20px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 
    0 6px 0 #004b72,
    0 8px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  opacity: 1;
}

#btn-restart-game:hover {
  background: linear-gradient(180deg, #00c4e8 0%, #0088cc 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 8px 0 #004b72,
    0 12px 16px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#btn-restart-game:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #004b72,
    0 4px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Ayarlar (Solid 3D KanziGames Purple Button - No Neon Glow) */
#btn-exit-game {
  background: linear-gradient(180deg, #a855f7 0%, #7e22ce 100%);
  color: #ffffff;
  border: 1px solid #c084fc;
  border-radius: 16px;
  padding: 15px 20px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 
    0 6px 0 #581c87,
    0 8px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  opacity: 1;
}

#btn-exit-game:hover {
  background: linear-gradient(180deg, #b565f8 0%, #8e2de2 100%);
  transform: translateY(-2px);
  box-shadow: 
    0 8px 0 #581c87,
    0 12px 16px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#btn-exit-game:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 0 #581c87,
    0 4px 6px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Toast Notification */
.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(15, 15, 27, 0.95);
  border: 2px solid var(--primary-color);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── OYUN SONU MODALI ── */
.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 14, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeInOverlay 0.3s ease forwards;
}

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

.game-over-box {
  background: linear-gradient(165deg, rgba(18, 22, 38, 0.98) 0%, rgba(10, 12, 22, 0.99) 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  padding: 36px 32px 32px;
  max-width: 340px;
  width: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: slideUpBox 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  position: relative;
  overflow: hidden;
}

.game-over-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

@keyframes slideUpBox {
  from { transform: translateY(30px) scale(0.94); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}

.game-over-symbol-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-pixel);
  font-size: 2.2rem;
  margin-bottom: 16px;
  position: relative;
  flex-shrink: 0;
  border: 3px solid;
  animation: ringPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.game-over-symbol-ring.ring-x {
  color: #00e5ff;
  border-color: rgba(0, 229, 255, 0.6);
  background: radial-gradient(circle at 35% 35%, rgba(0, 229, 255, 0.18) 0%, rgba(0, 100, 160, 0.12) 100%);
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.25), inset 0 0 16px rgba(0, 229, 255, 0.08);
}

.game-over-symbol-ring.ring-o {
  color: #ff0055;
  border-color: rgba(255, 0, 85, 0.6);
  background: radial-gradient(circle at 35% 35%, rgba(255, 0, 85, 0.18) 0%, rgba(160, 0, 50, 0.12) 100%);
  box-shadow: 0 0 28px rgba(255, 0, 85, 0.25), inset 0 0 16px rgba(255, 0, 85, 0.08);
}

.game-over-symbol-ring.ring-draw {
  color: #ffb700;
  border-color: rgba(255, 183, 0, 0.6);
  background: radial-gradient(circle at 35% 35%, rgba(255, 183, 0, 0.15) 0%, rgba(140, 100, 0, 0.10) 100%);
  box-shadow: 0 0 28px rgba(255, 183, 0, 0.2), inset 0 0 16px rgba(255, 183, 0, 0.06);
  font-size: 2rem;
}

@keyframes ringPop {
  from { transform: scale(0.4) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0deg);  opacity: 1; }
}

.game-over-emoji-wrap {
  display: none;
}

.game-over-title {
  font-family: var(--font-pixel);
  font-size: 1.3rem;
  color: #ffffff;
  letter-spacing: 2px;
  margin-bottom: 6px;
  line-height: 1.3;
}

.game-over-subtitle {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: #9499b0;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Score Summary Cards */
.score-summary-box {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 24px;
}

.summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.summary-item.summary-x {
  background: rgba(0, 229, 255, 0.07);
  border-color: rgba(0, 229, 255, 0.2);
}

.summary-item.summary-o {
  background: rgba(255, 0, 85, 0.07);
  border-color: rgba(255, 0, 85, 0.2);
}

.summary-item.summary-draw {
  background: rgba(255, 183, 0, 0.06);
  border-color: rgba(255, 183, 0, 0.18);
}

.summary-item span {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #7a7f9a;
}

.summary-item.summary-x span { color: rgba(0, 229, 255, 0.7); }
.summary-item.summary-o span { color: rgba(255, 0, 85, 0.7); }
.summary-item.summary-draw span { color: rgba(255, 183, 0, 0.7); }

.summary-item strong {
  font-family: var(--font-pixel);
  font-size: 1.4rem;
  color: #ffffff;
}

.summary-item.summary-x strong { color: #00e5ff; }
.summary-item.summary-o strong { color: #ff0055; }
.summary-item.summary-draw strong { color: #ffb700; }

/* Tekrar Oyna Butonu */
.game-over-play-btn {
  width: 100%;
  margin-top: 0;
  padding: 15px 20px !important;
  font-size: 1rem !important;
  letter-spacing: 1px;
}



/* Helper hidden class */
.hidden {
  display: none !important;
}

/* ── ULTRA-PREMIUM FLOATING (i) BUTTON & MODAL (SABİT KANZI STANDARDI) ── */
.global-how-to-btn {

  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: calc(20px + env(safe-area-inset-left, 0px));
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3b165c 0%, #1b092b 70%, #0d0317 100%);
  border: 2px solid #a855f7;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.75),
    inset 0 1px 2px rgba(255, 255, 255, 0.35),
    inset 0 -2px 6px rgba(0, 0, 0, 0.8),
    0 0 16px rgba(168, 85, 247, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999999;
  outline: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease, border-color 0.25s ease;
  user-select: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.how-to-btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a855f7;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
  transition: color 0.25s ease, transform 0.25s ease;
}

.how-to-icon {
  stroke: #a855f7;
  transition: stroke 0.25s ease, transform 0.25s ease;
}

.global-how-to-btn:hover {
  transform: translateY(-3px) scale(1.1);
  border-color: #ffffff;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.85),
    inset 0 1px 2px rgba(255, 255, 255, 0.5),
    0 0 25px rgba(168, 85, 247, 0.6);
}

.global-how-to-btn:hover .how-to-icon {
  stroke: #ffffff;
  transform: scale(1.1);
}

.global-how-to-btn:active {
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

.btn-glow-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid rgba(168, 85, 247, 0.35);
  animation: auraPulse 2.8s infinite cubic-bezier(0.45, 0, 0.55, 1);
  pointer-events: none;
}

@keyframes auraPulse {
  0% { transform: scale(0.92); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 0.15; }
  100% { transform: scale(0.92); opacity: 0.85; }
}

.global-how-to-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999999;
  padding: 15px;
  animation: fadeInHowToModal 0.25s ease-out forwards;
}

.global-how-to-modal.hidden {
  display: none !important;
}

.global-how-to-box {
  background: linear-gradient(165deg, #1c0a30 0%, #0c0416 100%);
  border: 2px solid #a855f7;
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.9), inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 0 18px rgba(168, 85, 247, 0.25);
  color: #f8fafc;
  padding: 26px 28px;
  border-radius: 20px;
  width: min(92vw, 530px);
  position: relative;
  max-height: calc(88vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: 'Outfit', 'Inter', 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.global-how-to-box::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
.global-how-to-box::-webkit-scrollbar-thumb {
  display: none !important;
}

.global-how-to-close {
  position: absolute;
  top: 14px;
  z-index: 10;
  right: 18px;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  color: #a855f7;
  font-size: 2rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.global-how-to-close:hover {
  color: #ffffff;
  transform: scale(1.15);
}

.global-how-to-title {
  color: #a855f7;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  margin: 0 0 4px 0;
  padding: 0 35px;
  letter-spacing: 0.4px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  font-family: inherit;
}

.global-how-to-subtitle {
  color: #cbd5e1;
  font-size: 0.88rem;
  text-align: center;
  margin: 0 0 20px 0;
  font-weight: 500;
  letter-spacing: 0.2px;
  opacity: 0.95;
  font-family: inherit;
}

.global-how-to-content .rules-section {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.global-how-to-content h4 {
  color: #a855f7;
  font-size: 1.02rem;
  margin: 0 0 10px 0;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-family: inherit;
}

.global-how-to-content p {
  font-size: 0.93rem;
  line-height: 1.65;
  color: #f1f5f9;
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.15px;
  font-family: inherit;
}

.global-how-to-content ul, .global-how-to-content ol {
  margin: 0;
  padding-left: 22px;
  font-size: 0.92rem;
  color: #f1f5f9;
  line-height: 1.68;
  font-weight: 400;
  letter-spacing: 0.15px;
  font-family: inherit;
}

.global-how-to-content li {
  margin-bottom: 8px;
}

.global-how-to-content li strong {
  color: #ffffff;
  font-weight: 700;
}

.global-how-to-content li:last-child {
  margin-bottom: 0;
}

@keyframes fadeInHowToModal {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ── MOBİL UYUMLULUK ── */
@media (max-width: 600px) {
  .global-how-to-btn {
    width: 44px;
    height: 44px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: calc(14px + env(safe-area-inset-left, 0px));
  }
  .how-to-icon {
    width: 20px;
    height: 20px;
  }
  .global-how-to-box {
    padding: 20px 20px;
    border-radius: 16px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .global-how-to-title {
    font-size: 1.2rem;
  }
  .global-how-to-content .rules-section {
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .global-how-to-content p, .global-how-to-content ul, .global-how-to-content ol {
    font-size: 0.88rem;
    line-height: 1.6;
  }
}

@media (max-height: 500px) {
  .global-how-to-btn {
    width: 40px;
    height: 40px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
  }
  .how-to-icon {
    width: 18px;
    height: 18px;
  }
  .global-how-to-box {
    max-height: 90vh;
    padding: 16px 18px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* ── BER SKORU (turn-status-box içinde, turn-badge altında) ── */
.draw-score-center {
  font-size: 0.6rem;
  color: #ffffff;
  letter-spacing: 0.06em;
  text-align: center;
  margin-top: 2px;
}

.draw-score-center strong {
  color: var(--accent-color);
  font-weight: 700;
  margin-left: 2px;
}


/* ── KURAL ÇUBUĞU ── */
.rule-reminder-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid #000000;
  border-radius: 6px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.35);
  margin: 6px auto;
  width: fit-content;
}

#win-condition-text {
  color: #ffffff;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
