:root {
  --bg-dark: #0014a7;
  --panel: #081426;
  --neon-cyan: #57cfff;
  --neon-pink: #ff355a;
  --neon-yellow: #ffffff;
  --muted: #fff;
  --accent: #00d1b2;
  --tile: #0b1a2a;
  --glass: rgba(255, 255, 255, 0.03);
  --danger: #ff6b6b;
  --good: #4ce1a3;
  --glow: 0 6px 30px rgba(0, 255, 200, 0.06);
}

* {
  box-sizing: border-box;
}
/* zoom prevention: don't allow text-size adjust to cause zoom-like behavior */
html,
body {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  background: linear-gradient(
    180deg,
    rgba(2, 6, 23, 1) 0%,
    rgba(8, 12, 22, 1) 100%
  );
  background: linear-gradient(180deg, #0014a7 0%, #0014a7 100%);
  color: var(--neon-yellow);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  -ms-touch-action: manipulation;
  touch-action: manipulation;
  font-family: var(--font-family);
}

button,
input {
  font-family: var(--font-family);
}

/* overall wrapper with subtle padding */
.game-wrapper {
  width: 100%;
  max-width: 440px;
  position: relative;
}

/* retro animated background */
.retro-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(
      1000px 400px at 10% 10%,
      rgba(0, 85, 70, 0.06),
      transparent 10%
    ),
    radial-gradient(
      800px 300px at 90% 90%,
      rgba(255, 70, 120, 0.03),
      transparent 8%
    ),
    linear-gradient(180deg, rgba(6, 8, 15, 0.9), rgba(3, 6, 10, 0.95));
  z-index: -3;
  pointer-events: none;
  filter: blur(14px);
  opacity: 0.9;
}

/* scanlines overlay */
.scanlines {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px
  );
  background-size: 100% 4px;
  z-index: -1;
  pointer-events: none;
  mix-blend-mode: overlay;
}

#reveal {
  display: none;
}

/* main panel */
.container {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), var(--glow);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

/* hide settings panel and footer as requested */
#settingsPanel {
  display: none !important;
}
.game-footer {
  display: none !important;
}

/* HUD top: enforce two-line layout: title first line, hud-stats second */
.hud-top {
  display: flex;
  flex-direction: column; /* title-wrap on first line, hud-stats on second */
  gap: 8px;
  margin-bottom: 10px;
}
.title-wrap {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  gap: 2px;
}
.logo {
  font-family: var(--font-family), sans-serif;
  font-size: 1rem;
  color: var(--neon-pink);
  text-shadow: 0 0 12px rgba(255, 77, 166, 0.25),
    0 0 28px rgba(0, 255, 213, 0.03);
  letter-spacing: 1.6px;
}

/* hud-stats full width */
.hud-stats {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.stat-block {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  min-height: 5rem;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.stat-label {
  font-size: 1rem;
  color: var(--muted);
  letter-spacing: 1px;
}
.stat-number {
  font-size: 2rem;
  color: var(--neon-cyan);
  font-weight: 700;
  text-shadow: 0 6px 18px rgba(0, 255, 213, 0.06);
}

/* life block */
.life-block {
  padding: 6px 10px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.01),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.03);
  text-align: center;
  min-height: 5rem;
}
.life-label {
  font-size: 1rem;
  color: var(--muted);
}
.life-bar {
  height: 2.5rem;
  color: var(--neon-pink);
  font-weight: 800;
  text-shadow: 0 6px 14px rgba(255, 77, 166, 0.04);
  font-size: 1.5rem;
  line-height: 2.5rem;
}

/* main area */
.game-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

/* masked answer - big HUD */
.masked-wrap {
  display: flex;
  justify-content: center;
}
.masked-answer {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.18),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: #fff;
  font-family: "Press Start 2P", "Orbitron", monospace;
  font-size: 1rem;
  letter-spacing: 6px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(0, 255, 213, 0.03) inset;
  text-transform: uppercase;
}

/* grid of tiles */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tile {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.01),
    rgba(0, 0, 0, 0.12)
  );
  border-radius: 10px;
  padding: 12px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--neon-yellow);
  font-size: 0.8rem;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6),
    0 0 26px rgba(255, 209, 102, 0.02) inset;
  transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.12s linear,
    background 0.18s ease;
  position: relative;
  overflow: hidden;
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    600px 200px at 10% 10%,
    rgba(0, 255, 200, 0.03),
    transparent 15%
  );
  pointer-events: none;
}
.tile:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), 0 0 36px rgba(0, 255, 213, 0.04);
}
.tile.pop {
  transform: scale(1.04);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}
.tile.correct {
  background: linear-gradient(
    90deg,
    rgba(76, 225, 163, 0.08),
    rgba(0, 0, 0, 0.06)
  );
  color: var(--good);
  box-shadow: 0 10px 40px rgba(76, 225, 163, 0.06),
    0 0 26px rgba(76, 225, 163, 0.06) inset;
}
.tile.incorrect {
  background: linear-gradient(
    90deg,
    rgba(255, 110, 110, 0.04),
    rgba(0, 0, 0, 0.06)
  );
  color: var(--danger);
  transform: translateY(-4px) rotate(-1deg);
}

/* controls area */
.controls-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}
.timer-label {
  font-size: 1rem;
  color: var(--muted);
}
.timer-bar {
  background: rgba(255, 255, 255, 0.02);
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.02);
}
.timer-progress {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), #8ee7cc);
  transition: width 0.25s linear;
}
.timer-seconds {
  font-size: 1rem;
  color: var(--muted);
  text-align: right;
}

/* guess area */
.guess-area {
  display: block;
  gap: 8px;
  align-items: center;
  text-align: center;
}
#guessInput {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: 1rem;
  box-shadow: inset 0 -2px 8px rgba(0, 0, 0, 0.6);
  font-family: var(--font-family);
  max-width: 100vw;
  width: 100%;
  display: block;
}
.btn-arcade {
  padding: 10px 12px;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
  color: #041014;
  border: none;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 28px rgba(255, 77, 166, 0.06);
  cursor: pointer;
  margin-top: 1rem;
}
.btn-arcade.alt {
  background: var(--neon-yellow);
  color: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.btn-arcade:active {
  transform: translateY(2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}

/* message and reveal */
.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  text-align: center;
}
.reveal {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.02);
  text-align: center;
}

/* leaderboard style */
.leaderboard {
  margin-top: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
}
.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-radius: 6px;
  margin-top: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.01),
    rgba(0, 0, 0, 0.06)
  );
  border: 1px solid rgba(255, 255, 255, 0.02);
  font-weight: 700;
}
.lb-rank {
  color: var(--muted);
  min-width: 34px;
}
.lb-name {
  flex: 1;
  padding-left: 8px;
  color: #fff;
}
.lb-score {
  min-width: 64px;
  text-align: right;
  color: var(--neon-cyan);
}

/* small / responsive */
@media (max-width: 420px) {
  .game-wrapper {
    max-width: 390px;
  }
  .masked-answer {
    font-size: 1rem;
    letter-spacing: 5px;
    padding: 10px;
    line-height: 2rem;
  }
  .tile {
    min-height: 62px;
    font-size: 1rem;
    padding: 10px;
  }
  .hud-stats {
    gap: 8px;
    justify-content: space-between;
  }
  .stat-number {
    font-size: 2rem;
  }
  .title-wrap .logo {
    font-size: 2rem;
    text-align: center;
    display: block;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .guess-area {
    gap: 6px;
  }
}

.mask-letter {
  display: inline-block;
  min-width: 14px; /* width for each letter/underscore */
  margin: 0 6px; /* spacing between letters */
  text-align: center;
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  color: #cfeff0;
  line-height: 1.2;
}

.mask-letter.revealed {
  color: #ffffff;
  text-shadow: 0 6px 18px rgba(0, 255, 213, 0.06);
}

.mask-space {
  display: inline-block;
  width: 18px; /* wider gap between words */
}

/* smaller devices: reduce spacing */
@media (max-width: 420px) {
  .mask-letter {
    min-width: 12px;
    margin: 0 4px;
    font-size: 12px;
  }
  .mask-space {
    width: 14px;
  }
}

/* ensure masked-answer doesn't use large letter-spacing anymore */
.masked-answer {
  letter-spacing: 0; /* override previous */
}
