:root {
  --bg: #0a0a14;
  --surface: rgba(10, 10, 30, 0.75);
  --surface2: rgba(18, 18, 40, 0.8);
  --border: rgba(0, 255, 255, 0.15);
  --border-bright: rgba(0, 255, 255, 0.35);
  --text: #e0f0ff;
  --text-muted: #7b8aa6;
  --accent: #00f0ff;
  --accent2: #ff2d95;
  --p1: #00f0ff;
  --p2: #ff2d95;
  --p3: #ffdd00;
  --p4: #00ff88;
  --font: 'Rajdhani', sans-serif;
  --mono: 'Orbitron', sans-serif;
  --r: 22px;
  --r-sm: 14px;
  --glow: 0 0 18px;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Animated grid background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.06) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: 0;
  animation: gridShift 20s linear infinite;
}

@keyframes gridShift {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 50px 50px;
  }
}

/* Floating particles (added via JS canvas bg) - we'll add a canvas for background */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  transition: opacity 0.5s ease, transform 0.5s ease;
  z-index: 10;
}

.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px);
}

/* Glass panel with neon border */
.panel {
  background: rgba(8, 8, 25, 0.7);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 30px;
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(0, 240, 255, 0.05);
  animation: panelGlow 3s ease-in-out infinite alternate;
}

@keyframes panelGlow {
  0% {
    border-color: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.15);
  }

  100% {
    border-color: rgba(255, 45, 149, 0.3);
    box-shadow: 0 0 35px rgba(255, 45, 149, 0.2);
  }
}

.logo-wrap {
  margin-bottom: 30px;
}

.logo-mark {
  font-family: var(--mono);
  font-size: 3.8rem;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;

  background: linear-gradient(135deg,
      #ffffff 0%,
      #00f0ff 50%,
      #ff2d95 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

  /* 3D Border + Glow */
  filter:
    drop-shadow(1px 1px 0 #ffffff) drop-shadow(2px 2px 0 #7c6af7) drop-shadow(3px 3px 0 #4b2bd6) drop-shadow(4px 4px 0 rgba(0, 0, 0, .45)) drop-shadow(0 0 15px rgba(0, 240, 255, .6)) drop-shadow(0 0 30px rgba(255, 45, 149, .35));
}

.setting-group {
  margin-bottom: 24px;
  text-align: left;
}

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-left: 5px;
}

.seg {
  display: flex;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 12px;
  padding: 4px;
  gap: 3px;
}

.seg button {
  flex: 1;
  background: transparent;
  border: none;
  color: #7b8aa6;
  padding: 12px 4px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  letter-spacing: 0.5px;
}

.seg button.active {
  background: rgba(0, 240, 255, 0.15);
  color: #fff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
  border: 1px solid rgba(0, 240, 255, 0.6);
}

.seg button:hover:not(.active) {
  color: #ccc;
  background: rgba(255, 255, 255, 0.05);
}

.btn-prime {
  width: 100%;
  background: linear-gradient(135deg, #00f0ff 0%, #ff2d95 100%);
  color: #000;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.25);
  padding: 18px;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  border-radius: 14px;
  cursor: pointer;
  margin-top: 15px;
  font-family: var(--mono);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;

  /* 3D Border + Depth */
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.5),
    /* top highlight */
    inset 0 -3px 6px rgba(0, 0, 0, 0.35),
    /* bottom inner shadow */
    0 0 0 2px rgba(255, 255, 255, 0.12),
    /* outer border */
    0 6px 0 #8c1b63,
    /* hard bottom edge */
    0 12px 25px rgba(0, 240, 255, 0.35),
    /* glow */
    0 18px 35px rgba(0, 0, 0, 0.4);
  /* depth */

  text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.btn-prime:hover {
  transform: translateY(-3px);

  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.6),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    0 0 0 2px rgba(255, 255, 255, 0.2),
    0 9px 0 #8c1b63,
    0 18px 35px rgba(0, 240, 255, 0.5),
    0 25px 45px rgba(0, 0, 0, 0.45);
}

.btn-prime:active {
  transform: translateY(6px);

  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.4),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 0 0 2px rgba(255, 255, 255, 0.12),
    0 2px 0 #8c1b63,
    0 8px 15px rgba(0, 0, 0, 0.35);
}

/* Game screen */
#game-screen {
  justify-content: flex-start;
  padding-top: 16px;
}

#game-hud {
  width: 100%;
  max-width: 580px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  z-index: 20;
  gap: 12px;
  margin-top: 5px;
}

.hud-scores {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.score-card {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 14px;
  padding: 5px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  transition: 0.3s;
  position: relative;
}

.score-card.active {
  border-color: rgba(255, 45, 149, 0.8);
  box-shadow: 0 0 20px rgba(255, 45, 149, 0.4);
  transform: translateY(-4px);
}

.score-card .name {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #7b8aa6;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.score-card .score {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
}

.hud-controls {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #7b8aa6;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: #00f0ff;
  color: #fff;
}

#turn-bar {
  width: 100%;
  max-width: 580px;
  margin-bottom: 10px;
  height: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  overflow: hidden;
  z-index: 20;
}

#turn-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s, background 0.3s;
  box-shadow: 0 0 15px currentColor;
}

#canvas-container {
  position: relative;
  width: 100%;
  max-width: 580px;
  aspect-ratio: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas#gameCanvas {
  background: rgba(5, 5, 20, 0.6);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.2);
}

#ai-thinking {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #ff2d95;
  border-radius: 20px;
  padding: 8px 20px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #ff2d95;
  letter-spacing: 2px;
  display: none;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  z-index: 50;
}

#ai-thinking.show {
  display: flex;
}

.think-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff2d95;
  animation: blink 1.2s infinite;
}

.think-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.think-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {

  0%,
  100% {
    opacity: 0.2
  }

  50% {
    opacity: 1
  }
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.4s;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.btn-ghost {
  width: 100%;
  background: transparent;
  color: #7b8aa6;
  border: 1px solid rgba(0, 240, 255, 0.4);
  padding: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  margin-top: 30px;
  font-family: var(--mono);
  letter-spacing: 2px;
  transition: 0.2s;
}

.btn-ghost:hover {
  background: rgba(0, 240, 255, 0.1);
  color: #fff;
}

.score-breakdown {
  display: flex;
  gap: 10px;
  margin: 20px 0 24px;
  justify-content: center;
}

.score-pill {
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid currentColor;
}

#toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid #00f0ff;
  border-radius: 30px;
  padding: 12px 28px;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 1px;
  color: #00f0ff;
  z-index: 999;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

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

/* ----------------------------
   PRELOADER
-----------------------------*/

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-track {
  width: 200px;
  height: 4px;
  margin: 0 auto 15px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, .1);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #00f0ff, #ff2d95);
  box-shadow: 0 0 12px #00f0ff;
}

.load-text {
  font-family: var(--mono);
  color: #7b8aa6;
  letter-spacing: 2px;
}


/* ----------------------------
   HOW TO PLAY
-----------------------------*/

.section-title {
  margin-bottom: 20px;
  font-size: 1.8rem;
  font-family: var(--mono);
  color: #00f0ff;
}

.howto-content {
  margin: 15px 0 25px;
  text-align: left;
  overflow-y: auto;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.step-title {
  margin: 0 0 3px;
}

.step-desc {
  color: #7b8aa6;
  margin: 0;
}

/* Number Colors */

.cyan {
  background: #00f0ff;
  color: #000;
}

.pink {
  background: #ff2d95;
  color: #fff;
}

.yellow {
  background: #ffdd00;
  color: #000;
}

.green {
  background: #00ff88;
  color: #000;
}


/* ----------------------------
   GAME OVER
-----------------------------*/

.win-emoji {
  font-size: 3rem;
  margin-bottom: 10px;
}

.win-title {
  font-family: var(--mono);
  font-weight: 900;
}

.win-subtitle {
  margin-bottom: 25px;
  color: #7b8aa6;
}