:root {
  color-scheme: dark;
  --pink: #ff3ca6;
  --cyan: #3cf0ff;
  --violet: #9b6bff;
  --ink: #f0f0f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Chakra Petch", system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Inside the OS shell, the shell chrome owns volume + fullscreen + home. */
html.in-shell .mute-btn,
html.in-shell .fs-btn,
html.in-shell .back-link {
  display: none;
}

.back-link {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  z-index: 6;
  color: #8f8fb0;
  text-decoration: none;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  text-transform: uppercase;
}
.back-link:hover {
  color: var(--violet);
}

.duel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 0.9rem;
  padding: 1rem;
}

.status {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 1.05rem;
  min-height: 1.4em;
  color: #dfe0ff;
  text-shadow: 0 0 14px rgba(155, 107, 255, 0.5);
}

.stage {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  line-height: 0;
}
canvas {
  display: block;
  max-width: min(78vw, 62vh);
  height: auto;
  background:
    radial-gradient(circle at 50% 20%, rgba(64, 42, 138, 0.4) 0%, transparent 62%),
    rgba(5, 3, 13, 0.8);
  /* Blur the sun behind the board so its scan-lines soften to a glow and don't
     compete with the grid (the grid + marks drawn on the canvas stay sharp). */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: none;
}

/* MAXTRON's speech bubble */
.bot-speech {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  max-width: 82%;
  padding: 0.5rem 0.9rem;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.3;
  text-align: center;
  color: #eafff6;
  background: rgba(8, 20, 26, 0.85);
  border: 1.5px solid rgba(60, 240, 255, 0.55);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(60, 240, 255, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.bot-speech.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Title card / choose-your-opponent overlay (sits over the board) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.4rem;
  text-align: center;
  line-height: 1.4; /* the .stage sets line-height:0 for the canvas — reset it here */
  background:
    radial-gradient(ellipse 90% 55% at 50% 8%, rgba(255, 150, 80, 0.14), transparent 60%),
    rgba(6, 5, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
/* NEON DUEL wordmark: living glyph on top, split-colour arcade type below */
.wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}
.logo-glyph {
  width: 104px;
  height: 104px;
  filter: drop-shadow(0 0 10px rgba(155, 107, 255, 0.5));
}
.overlay-logo {
  margin: 0;
  display: flex;
  gap: 0.34em;
  white-space: nowrap;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(2rem, 9vw, 3.1rem);
  letter-spacing: 0.06em;
  line-height: 1;
}
.wm-neon {
  color: #eafeff;
  text-shadow: 0 0 10px var(--cyan), 0 0 26px rgba(60, 240, 255, 0.7), 0 0 46px rgba(60, 240, 255, 0.4);
}
.wm-duel {
  color: #ffe9f5;
  text-shadow: 0 0 10px var(--pink), 0 0 26px rgba(255, 60, 166, 0.7), 0 0 46px rgba(255, 60, 166, 0.4);
  animation: wmFlicker 5s infinite steps(1);
}
/* a rare, quick arcade-sign flicker on the pink word */
@keyframes wmFlicker {
  0%, 40%, 47%, 100% { opacity: 1; }
  42% { opacity: 0.35; }
  44% { opacity: 1; }
  45% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .wm-duel { animation: none; }
}
.overlay-tag {
  margin: 0 0 0.1rem;
  max-width: 92%;
  color: #c4c4e0;
  font-size: 0.84rem;
  line-height: 1.5;
}
/* On the result screen, drop the rules line so the "You win!" headline
   has room and the card doesn't feel squished. */
.overlay.has-result .overlay-tag {
  display: none;
}
.overlay-result {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, #ff4ec7, #ffd93d, #4dd2ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 78, 199, 0.5));
}
.overlay-result:empty {
  display: none;
}
.overlay-pick {
  margin: 0.1rem 0;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #b6a6e0;
}
.mode-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(290px, 84%);
}
.choice {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.55rem 0.9rem;
  text-align: left;
  background: rgba(8, 5, 20, 0.7);
  border: 1.5px solid rgba(155, 107, 255, 0.45);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.choice b {
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}
.choice span {
  font-size: 0.75rem;
  color: #b6a6e0;
}
.choice:hover {
  border-color: var(--cyan);
  background: rgba(60, 240, 255, 0.1);
  box-shadow: 0 0 16px rgba(60, 240, 255, 0.3);
}
.choice:active {
  transform: scale(0.98);
}

#restart {
  margin-top: 0.3rem;
  padding: 0.6rem 1.8rem;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  letter-spacing: 0.1em;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(90deg, #b06bff, #ff4ec7);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(255, 78, 199, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#restart:hover {
  transform: scale(1.05);
  box-shadow: 0 0 32px rgba(255, 78, 199, 0.75);
}
#restart:active {
  transform: scale(0.98);
}

/* Corner buttons (hidden in the shell) */
.mute-btn,
.fs-btn {
  position: fixed;
  top: 14px;
  z-index: 80;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 19, 0.7);
  border: 2px solid rgba(155, 107, 255, 0.55);
  border-radius: 11px;
  color: var(--cyan);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}
.mute-btn {
  right: 14px;
}
.fs-btn {
  right: 62px;
  color: #ffd23c;
  border-color: rgba(255, 210, 60, 0.55);
}
.mute-btn svg,
.fs-btn svg {
  width: 21px;
  height: 21px;
  filter: drop-shadow(0 0 5px currentColor);
}
.mute-btn:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(60, 240, 255, 0.5);
}
.fs-btn:hover {
  border-color: #ffd23c;
  box-shadow: 0 0 16px rgba(255, 210, 60, 0.5);
}
.mute-btn:active,
.fs-btn:active {
  transform: scale(0.92);
}
.mute-btn.muted {
  color: var(--pink);
  border-color: rgba(255, 60, 166, 0.6);
}
