/* ============================================
   CYBERPUNK HUD GAME SYSTEM
   ============================================ */
@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Noto+Sans+TC:wght@400;700;900&family=Press+Start+2P&display=swap");

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --cyan: #00f0ff;
  --pink: #ff2d7b;
  --lime: #39ff14;
  --gold: #ffd700;
  --purple: #b026ff;
  --orange: #ff6a00;
  --dark: #0a0a1a;
  --panel: rgba(10, 10, 30, 0.85);
  --glow-cyan: 0 0 20px rgba(0, 240, 255, 0.5), 0 0 40px rgba(0, 240, 255, 0.2);
  --glow-pink:
    0 0 20px rgba(255, 45, 123, 0.5), 0 0 40px rgba(255, 45, 123, 0.2);
  --glow-lime: 0 0 20px rgba(57, 255, 20, 0.5);
  --glow-gold: 0 0 20px rgba(255, 215, 0, 0.5);
  --font-hud: "Orbitron", sans-serif;
  --font-zh: "Noto Sans TC", sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  background: var(--dark);
  color: #fff;
  font-family: var(--font-zh);
  overflow: hidden;
  cursor: default;
}

/* Scanline overlay */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 240, 255, 0.04) 2px,
    rgba(0, 240, 255, 0.04) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Grid background */
#bg-grid {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(0, 240, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.08) 1px, transparent 1px);
  background-size: 60px 60px;
  z-index: 0;
}

/* Particle canvas */
#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  z-index: 10;
  padding: 0;
}
.screen.active {
  display: flex;
}

/* ============ HUD ELEMENTS ============ */
.hud-border {
  position: fixed;
  z-index: 100;
  pointer-events: none;
}
.hud-border.top {
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}
.hud-border.bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--pink), transparent);
}
.hud-border.left {
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--cyan), transparent, var(--pink));
}
.hud-border.right {
  top: 0;
  right: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--cyan), transparent, var(--pink));
}

/* Corner decorations */
.hud-corner {
  position: fixed;
  width: 60px;
  height: 60px;
  z-index: 101;
  pointer-events: none;
}
.hud-corner::before,
.hud-corner::after {
  content: "";
  position: absolute;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.hud-corner.tl {
  top: 8px;
  left: 8px;
}
.hud-corner.tl::before {
  width: 30px;
  height: 2px;
  top: 0;
  left: 0;
}
.hud-corner.tl::after {
  width: 2px;
  height: 30px;
  top: 0;
  left: 0;
}
.hud-corner.tr {
  top: 8px;
  right: 8px;
}
.hud-corner.tr::before {
  width: 30px;
  height: 2px;
  top: 0;
  right: 0;
}
.hud-corner.tr::after {
  width: 2px;
  height: 30px;
  top: 0;
  right: 0;
}
.hud-corner.bl {
  bottom: 8px;
  left: 8px;
}
.hud-corner.bl::before {
  width: 30px;
  height: 2px;
  bottom: 0;
  left: 0;
}
.hud-corner.bl::after {
  width: 2px;
  height: 30px;
  bottom: 0;
  left: 0;
}
.hud-corner.br {
  bottom: 8px;
  right: 8px;
}
.hud-corner.br::before {
  width: 30px;
  height: 2px;
  bottom: 0;
  right: 0;
}
.hud-corner.br::after {
  width: 2px;
  height: 30px;
  bottom: 0;
  right: 0;
}

/* ============ BUTTONS ============ */
.hud-btn {
  font-family: var(--font-hud);
  font-size: 1.3rem;
  padding: 1rem 2.5rem;
  background: transparent;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 3px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.hud-btn:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: var(--glow-cyan);
  transform: scale(1.05);
}
.hud-btn:active {
  transform: scale(0.98);
}
.hud-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 240, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}
.hud-btn:hover::before {
  left: 100%;
}

.hud-btn.pink {
  border-color: var(--pink);
  color: var(--pink);
}
.hud-btn.pink:hover {
  background: rgba(255, 45, 123, 0.15);
  box-shadow: var(--glow-pink);
}
.hud-btn.lime {
  border-color: var(--lime);
  color: var(--lime);
}
.hud-btn.lime:hover {
  background: rgba(57, 255, 20, 0.15);
  box-shadow: var(--glow-lime);
}
.hud-btn.gold {
  border-color: var(--gold);
  color: var(--gold);
}
.hud-btn.gold:hover {
  background: rgba(255, 215, 0, 0.15);
  box-shadow: var(--glow-gold);
}
.hud-btn.large {
  font-size: 1.8rem;
  padding: 1.4rem 3.5rem;
}
.hud-btn.xl {
  font-size: 2.5rem;
  padding: 1.8rem 5rem;
}

.btn-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1.5rem;
}

/* ============ PANELS ============ */
.hud-panel {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 2rem;
  position: relative;
  backdrop-filter: blur(10px);
}
.hud-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}

/* ============ HOME SCREEN ============ */
#home {
  justify-content: safe center;
  overflow-y: auto;
  padding: 2vh 4rem;
  gap: 1.5rem;
}
#home .logo-title {
  font-family: "Press Start 2P", monospace;
  font-size: 3.8rem;
  font-weight: 400;
  text-align: center;
  letter-spacing: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--pink), var(--cyan));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 3s ease infinite;
  text-shadow: none;
  filter: drop-shadow(0 0 30px rgba(0, 240, 255, 0.3));
}
@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

#home .subtitle {
  font-size: 1.4rem;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 10px;
  text-transform: uppercase;
  font-family: var(--font-hud);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.4rem;
  max-width: 1320px;
  width: 100%;
}

.stage-card {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 1.8rem 1.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  clip-path: polygon(
    0 10px,
    10px 0,
    100% 0,
    100% calc(100% - 10px),
    calc(100% - 10px) 100%,
    0 100%
  );
}
.stage-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.05), transparent);
  transition: opacity 0.3s;
}
.stage-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
}
.stage-card:hover::before {
  opacity: 0;
}
.stage-card .stage-num {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  color: var(--cyan);
  letter-spacing: 4px;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}
.stage-card .stage-icon {
  font-size: 4.2rem;
  margin-bottom: 0.7rem;
  display: block;
}
.stage-card .stage-name {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.stage-card .stage-desc {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.5);
}
.stage-card:nth-child(1) {
  --accent: var(--cyan);
}
.stage-card:nth-child(2) {
  --accent: var(--pink);
}
.stage-card:nth-child(3) {
  --accent: var(--lime);
}
.stage-card:nth-child(4) {
  --accent: var(--gold);
}
.stage-card:nth-child(5) {
  --accent: var(--purple);
}
.stage-card:nth-child(6) {
  --accent: var(--orange);
}
.stage-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
.stage-card .stage-num {
  color: var(--accent);
}

/* ============ GAME HEADER (in-game top bar) ============ */
.game-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0.8rem 1.5rem;
  background: rgba(10, 10, 30, 0.9);
  border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  z-index: 200;
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.game-header .gh-title {
  font-family: var(--font-hud);
  font-size: 2rem;
  color: var(--cyan);
  letter-spacing: 4px;
  text-align: center;
}
.game-header .gh-btns {
  display: flex;
  gap: 0.5rem;
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
}
.game-header .gh-btn {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  padding: 0.4rem 0.7rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.game-header .gh-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ============ QUIZ GAME ============ */
.quiz-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  width: 100%;
  max-width: none;
  gap: 0.8rem;
  flex: 1;
  padding: 1rem 2rem 3rem;
  overflow-y: auto;
}

.quiz-progress {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.quiz-dot {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 240, 255, 0.3);
  border-radius: 50%;
  transition: all 0.3s;
}
.quiz-dot.active {
  border-color: var(--cyan);
  box-shadow: var(--glow-cyan);
  background: var(--cyan);
}
.quiz-dot.done {
  border-color: var(--lime);
  background: var(--lime);
}

.quiz-question {
  font-size: 3.5rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  max-width: 1100px;
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
}

.quiz-options {
  display: flex;
  justify-content: center;
  gap: 2rem;
  width: 96%;
  flex: 1;
}

.quiz-option {
  background: var(--panel);
  border: 2px solid rgba(0, 240, 255, 0.3);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 7rem;
  width: 48%;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.4s;
  position: relative;
  overflow: hidden;
}
.quiz-option:first-child {
  clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%);
  border-color: var(--cyan);
  animation: breatheCyan 3s ease-in-out infinite;
}
.quiz-option:last-child {
  clip-path: polygon(20px 0, 100% 0, 100% 100%, 0 100%);
  border-color: var(--pink);
  animation: breathePink 3s ease-in-out 1.5s infinite;
}
@keyframes breatheCyan {
  0%,
  100% {
    background: var(--panel);
    box-shadow: none;
  }
  50% {
    background: rgba(0, 240, 255, 0.12);
    box-shadow:
      inset 0 0 60px rgba(0, 240, 255, 0.08),
      0 0 30px rgba(0, 240, 255, 0.15);
  }
}
@keyframes breathePink {
  0%,
  100% {
    background: var(--panel);
    box-shadow: none;
  }
  50% {
    background: rgba(255, 45, 123, 0.12);
    box-shadow:
      inset 0 0 60px rgba(255, 45, 123, 0.08),
      0 0 30px rgba(255, 45, 123, 0.15);
  }
}
.quiz-option:first-child:hover {
  background: rgba(0, 240, 255, 0.15);
  box-shadow: var(--glow-cyan);
  transform: scale(1.03);
}
.quiz-option:last-child:hover {
  background: rgba(255, 45, 123, 0.15);
  box-shadow: var(--glow-pink);
  transform: scale(1.03);
}
.quiz-option .opt-label {
  font-family: var(--font-hud);
  font-size: 1.4rem;
  letter-spacing: 4px;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}
.quiz-option:first-child .opt-label {
  color: var(--cyan);
}
.quiz-option:last-child .opt-label {
  color: var(--pink);
}

.answer-revealed .quiz-question {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0.5rem;
}
.answer-revealed .quiz-options {
  gap: 0.5rem;
}
.answer-revealed .quiz-option {
  font-size: clamp(2rem, 5vw, 3rem);
  padding: 0.5rem 1rem;
  min-height: auto;
}
.answer-revealed .quiz-option.correct {
  font-size: clamp(2rem, 5vw, 3rem) !important;
}
.quiz-option.correct {
  border-color: var(--lime) !important;
  background: rgba(57, 255, 20, 0.35) !important;
  box-shadow:
    0 0 60px rgba(57, 255, 20, 0.5),
    inset 0 0 40px rgba(57, 255, 20, 0.1) !important;
  animation: correctPulse 0.5s ease !important;
  color: var(--lime) !important;
  font-size: 9rem !important;
  text-shadow: 0 0 30px rgba(57, 255, 20, 0.6);
}
.quiz-option.wrong {
  border-color: #ff0040 !important;
  background: rgba(255, 0, 64, 0.15) !important;
  opacity: 0.4;
  animation: none !important;
}
@keyframes correctPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Answer extra info */
.answer-info {
  font-size: 1.5rem;
  color: var(--gold);
  font-weight: 700;
  text-align: center;
  animation: fadeInUp 0.5s ease;
}
.answer-info-inline {
  font-size: 2.5rem;
  color: var(--gold);
  font-weight: 700;
  margin-top: 0.8rem;
  animation: fadeInUp 0.4s ease;
}

/* ============ COUNTDOWN OVERLAY ============ */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 500;
  backdrop-filter: blur(5px);
}
.countdown-overlay.active {
  display: flex;
}
.countdown-num {
  font-family: var(--font-hud);
  font-size: 20rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow:
    0 0 60px var(--cyan),
    0 0 120px rgba(0, 240, 255, 0.3);
  animation: countPulse 1s ease infinite;
}
@keyframes countPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}
.countdown-text {
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 6px;
  font-family: var(--font-hud);
  position: absolute;
  bottom: 30%;
}

/* ============ TIMER ============ */
.timer-display {
  font-family: var(--font-hud);
  font-size: 12rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 40px var(--cyan);
  text-align: center;
  transition:
    color 0.3s,
    text-shadow 0.3s;
}
.timer-display.warning {
  color: var(--gold);
  text-shadow: 0 0 40px var(--gold);
}
.timer-display.danger {
  color: var(--pink);
  text-shadow: 0 0 40px var(--pink);
  animation: timerShake 0.3s ease infinite;
}
@keyframes timerShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
.timer-label {
  font-family: var(--font-hud);
  font-size: 1.3rem;
  letter-spacing: 6px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  margin-top: 0.5rem;
}

/* ============ IMAGE CHALLENGE ============ */
.challenge-image-container {
  width: 80vw;
  max-width: 700px;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.challenge-image-container img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border: 2px solid rgba(0, 240, 255, 0.3);
  transform-origin: center center;
}
.image-timer-bar {
  position: absolute;
  bottom: -10px;
  left: 0;
  height: 4px;
  background: var(--cyan);
  box-shadow: var(--glow-cyan);
  transition: width linear;
}

/* ============ VIDEO SECTION ============ */
.video-upload-zone {
  width: 80vw;
  max-width: 800px;
  aspect-ratio: 16/9;
  border: 2px dashed rgba(0, 240, 255, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.video-upload-zone:hover {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.05);
}
.video-upload-zone video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.video-upload-zone .upload-hint {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}
.video-upload-zone .upload-hint .icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

/* ============ GATHER GAME ============ */
.slot-machine {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 90%;
}
.slot-window {
  flex: 1;
  max-width: 45%;
  min-height: 45vh;
  background: var(--panel);
  border: 2px solid var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 900;
  overflow: hidden;
  position: relative;
}
.slot-window .slot-label {
  position: absolute;
  top: -1.8rem;
  font-family: var(--font-hud);
  font-size: 0.9rem;
  color: var(--cyan);
  letter-spacing: 3px;
}
.slot-reel {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.5s cubic-bezier(0.17, 0.67, 0.12, 1.1);
}
.slot-item {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  white-space: nowrap;
}

/* ============ MEMORY TOWER ============ */
.tower-container {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
}
.tower-block {
  width: 120px;
  height: 80px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: 1rem;
  color: rgba(0, 0, 0, 0.7);
  animation: blockDrop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid rgba(255, 255, 255, 0.2);
}
@keyframes blockDrop {
  0% {
    transform: translateY(-60px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.block-palette {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.block-color-btn {
  width: 75px;
  height: 75px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.block-color-btn:hover {
  transform: scale(1.15);
  border-color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* ============ DICE ============ */
/* Dice arena — dual layout */
.dice-arena {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
  gap: 1rem;
  width: 100%;
}
.dice-player-panel {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  position: relative;
}
.dice-player-panel .player-name {
  font-family: var(--font-zh);
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 2px;
}
.dice-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  font-size: 3.5rem;
  color: var(--gold);
  text-shadow:
    0 0 20px var(--gold),
    0 0 40px rgba(255, 215, 0, 0.3);
  padding: 0 1rem;
  letter-spacing: 4px;
  gap: 0.5rem;
}
.dice-turn-arrow {
  font-family: var(--font-zh);
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  animation: arrowBounce 0.8s ease-in-out infinite;
}
@keyframes arrowBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}
.dice-container {
  perspective: 1200px;
  width: 14vmin;
  height: 14vmin;
  max-width: 150px;
  max-height: 150px;
  padding: 4vmin;
  box-sizing: content-box;
  z-index: 1;
}
.dice-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: diceIdle 6s linear infinite;
}
.dice-3d.dice-locked .dice-face {
  background: linear-gradient(135deg, #0a3a0a, #002a00);
  border-color: #39ff14;
  color: #39ff14;
  text-shadow:
    0 0 30px #39ff14,
    0 0 60px rgba(57, 255, 20, 0.3);
  box-shadow:
    inset 0 0 40px rgba(57, 255, 20, 0.15),
    0 0 30px rgba(57, 255, 20, 0.3);
  transition: all 0.3s ease;
}
@keyframes diceIdle {
  from {
    transform: rotateX(0deg) rotateY(0deg);
  }
  to {
    transform: rotateX(360deg) rotateY(360deg);
  }
}
.dice-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a3e, #0c0c2a);
  border: 3px solid var(--dice-color, var(--cyan));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hud);
  font-size: 4rem;
  font-weight: 900;
  color: var(--dice-color, var(--cyan));
  text-shadow: 0 0 20px var(--dice-color, var(--cyan));
  box-shadow:
    inset 0 0 20px
      color-mix(in srgb, var(--dice-color, var(--cyan)) 10%, transparent),
    0 0 10px color-mix(in srgb, var(--dice-color, var(--cyan)) 20%, transparent);
  backface-visibility: visible;
}
.dice-face.f1 {
  transform: rotateY(0deg) translateZ(calc(14vmin / 2));
}
.dice-face.f2 {
  transform: rotateY(180deg) translateZ(calc(14vmin / 2));
}
.dice-face.f3 {
  transform: rotateY(90deg) translateZ(calc(14vmin / 2));
}
.dice-face.f4 {
  transform: rotateY(-90deg) translateZ(calc(14vmin / 2));
}
.dice-face.f5 {
  transform: rotateX(90deg) translateZ(calc(14vmin / 2));
}
.dice-face.f6 {
  transform: rotateX(-90deg) translateZ(calc(14vmin / 2));
}
@media (min-width: 900px) {
  .dice-face.f1 {
    transform: rotateY(0deg) translateZ(75px);
  }
  .dice-face.f2 {
    transform: rotateY(180deg) translateZ(75px);
  }
  .dice-face.f3 {
    transform: rotateY(90deg) translateZ(75px);
  }
  .dice-face.f4 {
    transform: rotateY(-90deg) translateZ(75px);
  }
  .dice-face.f5 {
    transform: rotateX(90deg) translateZ(75px);
  }
  .dice-face.f6 {
    transform: rotateX(-90deg) translateZ(75px);
  }
}
/* Live score */
.dice-live-score {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}
.dice-live-score .score-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 2px solid currentColor;
  border-radius: 6px;
  background: var(--panel);
  font-family: "Press Start 2P", monospace;
  font-size: 1.2rem;
}
.dice-live-score .score-box.empty {
  border-style: dashed;
  opacity: 0.2;
}
.dice-live-score .score-plus {
  font-size: 1rem;
  opacity: 0.3;
}
.dice-score-total {
  font-family: "Press Start 2P", monospace;
  font-size: 2rem;
  margin-top: 0.2rem;
}
.dice-roll-btn {
  font-family: var(--font-zh);
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.5rem 1.5rem;
  border: 2px solid;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 2px;
}
.dice-roll-btn:hover:not(:disabled) {
  filter: brightness(1.3);
  transform: scale(1.05);
}
.dice-roll-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

/* ============ EFFECTS ============ */
#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

/* ============ GAME INTRO (進入頁) ============ */
.game-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  text-align: center;
  gap: 0.5rem;
}
.game-intro .gi-icon {
  font-size: 7rem;
}
.game-intro .gi-title {
  font-family: var(--font-zh);
  font-size: 3.5rem;
  font-weight: 900;
  margin: 0.3rem 0;
}
.game-intro .gi-desc {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.6rem;
  max-width: 800px;
  line-height: 1.9;
  margin-bottom: 1rem;
}
.game-intro .gi-desc strong {
  font-weight: 700;
}

/* ============ TRANSITIONS ============ */
.stage-intro {
  display: none;
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
  z-index: 600;
}
.stage-intro.active {
  display: flex;
}
.stage-intro .intro-num {
  font-family: var(--font-hud);
  font-size: 1.2rem;
  color: var(--cyan);
  letter-spacing: 10px;
  animation: fadeInUp 0.8s ease;
}
.stage-intro .intro-title {
  font-family: var(--font-zh);
  font-size: 4rem;
  font-weight: 900;
  margin: 1rem 0;
  text-shadow: 0 0 40px rgba(0, 240, 255, 0.5);
  animation: fadeInUp 0.8s ease 0.2s both;
}
.stage-intro .intro-desc {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.6);
  max-width: 600px;
  text-align: center;
  line-height: 1.8;
  animation: fadeInUp 0.8s ease 0.4s both;
  margin-bottom: 2rem;
}
.stage-intro .intro-start {
  animation: fadeInUp 0.8s ease 0.6s both;
}

@keyframes goSplash {
  0% {
    font-size: 0;
    opacity: 1;
  }
  30% {
    font-size: 20rem;
    opacity: 1;
  }
  60% {
    font-size: 22rem;
    opacity: 1;
  }
  100% {
    font-size: 26rem;
    opacity: 0;
  }
}
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* ============ GAME START FLASH ============ */
.game-start-flash {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  z-index: 700;
}
.game-start-flash.active {
  display: flex;
}
.game-start-text {
  font-family: var(--font-hud);
  font-size: clamp(2.5rem, 10vw, 6rem);
  font-weight: 900;
  color: var(--cyan);
  text-shadow:
    0 0 60px var(--cyan),
    0 0 120px rgba(0, 240, 255, 0.5);
  animation: startFlash 1.5s ease forwards;
}
@keyframes startFlash {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
  60% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* ============ WINNER ============ */
.winner-screen {
  text-align: center;
}
.winner-screen .trophy {
  font-size: 10rem;
  margin-bottom: 1rem;
}
.winner-screen .winner-title {
  font-family: var(--font-hud);
  font-size: 4rem;
  background: linear-gradient(135deg, var(--gold), var(--orange), var(--gold));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 2s ease infinite;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  #home {
    padding: 2vh 1.5rem;
  }
  #home .logo-title {
    font-size: 2.2rem;
    letter-spacing: 4px;
  }
  #home .subtitle {
    letter-spacing: 4px;
    font-size: 1rem;
  }
  .stage-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .quiz-question {
    font-size: 1.5rem;
  }
  .quiz-option {
    font-size: 1.8rem;
    padding: 2rem 1rem;
  }
  .timer-display {
    font-size: 5rem;
  }
  .dice-arena {
    flex-direction: column;
    gap: 0.5rem;
  }
  .dice-vs {
    writing-mode: horizontal-tb;
    flex-direction: row;
    font-size: 2rem;
    padding: 0;
    gap: 0.8rem;
  }
  .dice-player-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
  }
  .dice-container {
    width: 10vmin;
    height: 10vmin;
    padding: 2vmin;
  }
  .dice-face {
    font-size: 2rem;
  }
  .dice-player-panel .player-name {
    font-size: 0.9rem;
    width: auto;
  }
  .dice-live-score .score-box {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.8rem;
  }
  .dice-live-score .score-plus {
    font-size: 0.6rem;
  }
  .dice-score-total {
    font-size: 1.1rem;
  }
  .dice-roll-btn {
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
  }
  .dice-face.f1 {
    transform: rotateY(0deg) translateZ(calc(10vmin / 2));
  }
  .dice-face.f2 {
    transform: rotateY(180deg) translateZ(calc(10vmin / 2));
  }
  .dice-face.f3 {
    transform: rotateY(90deg) translateZ(calc(10vmin / 2));
  }
  .dice-face.f4 {
    transform: rotateY(-90deg) translateZ(calc(10vmin / 2));
  }
  .dice-face.f5 {
    transform: rotateX(90deg) translateZ(calc(10vmin / 2));
  }
  .dice-face.f6 {
    transform: rotateX(-90deg) translateZ(calc(10vmin / 2));
  }
  .hud-btn {
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    letter-spacing: 1px;
  }
  .hud-btn.large {
    font-size: 1.3rem;
    padding: 1rem 2rem;
  }
  .hud-btn.xl {
    font-size: 1.6rem;
    padding: 1.2rem 2.5rem;
  }
  .game-header .gh-title {
    font-size: 1.3rem;
    letter-spacing: 2px;
  }
  .quiz-container {
    padding: 1rem;
  }
  .slot-machine {
    gap: 1rem;
  }
}

/* Glitch text effect */
.glitch {
  position: relative;
}
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.glitch::before {
  color: var(--cyan);
  animation: glitch1 2s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
}
.glitch::after {
  color: var(--pink);
  animation: glitch2 2s infinite;
  clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
}
@keyframes glitch1 {
  0%,
  90%,
  100% {
    transform: translate(0);
  }
  92% {
    transform: translate(-3px, 1px);
  }
  94% {
    transform: translate(3px, -1px);
  }
  96% {
    transform: translate(-2px, 0);
  }
}
@keyframes glitch2 {
  0%,
  90%,
  100% {
    transform: translate(0);
  }
  91% {
    transform: translate(3px, -1px);
  }
  93% {
    transform: translate(-3px, 1px);
  }
  95% {
    transform: translate(2px, 0);
  }
}

/* Sub-stage selector */
.sub-stage-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 600px;
}
.sub-stage-item {
  background: var(--panel);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 1.5rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  cursor: pointer;
  transition: all 0.3s;
}
.sub-stage-item:hover {
  border-color: var(--cyan);
  background: rgba(0, 240, 255, 0.1);
  transform: translateX(10px);
}
.sub-stage-item .ss-num {
  font-family: var(--font-hud);
  font-size: 1rem;
  color: var(--cyan);
  min-width: 60px;
}
.sub-stage-item .ss-title {
  font-weight: 700;
  font-size: 1.5rem;
}

/* Fullscreen hint */
.fs-hint {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: var(--font-hud);
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 2px;
  z-index: 100;
  cursor: pointer;
  transition: color 0.2s;
}
.fs-hint:hover {
  color: var(--cyan);
}

/* Keyboard hints */
.key-hints {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  font-family: var(--font-hud);
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 1px;
  z-index: 100;
  line-height: 1.8;
}
.key-hints kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Sound toggles */
.sound-toggles {
  position: fixed;
  top: 0.8rem;
  right: 7.5rem;
  display: flex;
  gap: 0.6rem;
  z-index: 300;
}
.sound-toggles span {
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.sound-toggles span:hover {
  opacity: 1;
}
.sound-toggles span.off {
  opacity: 0.2;
}
