:root {
  color-scheme: dark;
  --bg: #080b1f;
  --bg-2: #15102d;
  --surface: rgba(18, 20, 42, 0.9);
  --surface-2: rgba(28, 31, 58, 0.92);
  --panel: #171a35;
  --screen: #060c18;
  --yellow: #ffce00;
  --yellow-2: #ffbc0c;
  --orange: #ff9327;
  --cyan: #46dfff;
  --blue: #3577ff;
  --white: #e8e8e8;
  --gray: #a0a0a0;
  --dark-gray: #303030;
  --line: rgba(232, 232, 232, 0.14);
  --line-strong: rgba(255, 206, 0, 0.72);
  --green: #4bea8f;
  --red: #ff4d66;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --pixel-shadow: 0 4px 0 rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 206, 0, 0.14), transparent 26%),
    radial-gradient(circle at 78% 20%, rgba(70, 223, 255, 0.13), transparent 28%),
    linear-gradient(135deg, #080b1f 0%, #15102d 54%, #080b1f 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 5px);
  background-size: 28px 28px, 28px 28px, auto;
  opacity: 0.46;
  z-index: 20;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1260px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 26px 0;
}

.menu-screen,
.game-stage {
  width: 100%;
}

.menu-screen {
  position: relative;
  min-height: calc(100vh - 52px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.retro-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Animated background: adjust colors, opacity, speeds, or shape positions in this block. */
.retro-bg::before {
  content: "";
  position: absolute;
  inset: auto -18% -38% -18%;
  height: 66%;
  background:
    linear-gradient(90deg, transparent 0 49.3%, rgba(70, 223, 255, 0.2) 49.3% 50.7%, transparent 50.7%),
    linear-gradient(transparent 0 49.3%, rgba(255, 206, 0, 0.16) 49.3% 50.7%, transparent 50.7%);
  background-size: 78px 78px;
  transform: perspective(480px) rotateX(62deg);
  animation: gridRide 4.8s linear infinite;
  transform-origin: center bottom;
}

.retro-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0 34%, rgba(8, 11, 31, 0.72) 76%);
}

.energy-icon,
.bg-line,
.bg-particle {
  position: absolute;
  z-index: 0;
}

.energy-icon {
  width: 76px;
  height: 76px;
  fill: none;
  stroke: rgba(232, 232, 232, 0.76);
  stroke-width: 4;
  stroke-linecap: square;
  stroke-linejoin: round;
  opacity: 0.55;
  filter: drop-shadow(0 0 16px rgba(70, 223, 255, 0.26));
  animation: floatIcon 7.4s ease-in-out infinite;
}

.icon-pv {
  left: 8%;
  top: 18%;
  stroke: rgba(70, 223, 255, 0.82);
}

.icon-genset {
  right: 10%;
  top: 17%;
  width: 82px;
  height: 82px;
  stroke: rgba(255, 206, 0, 0.82);
  animation-delay: -1.8s;
}

.icon-grid {
  left: 15%;
  bottom: 18%;
  width: 86px;
  height: 86px;
  stroke: rgba(53, 119, 255, 0.86);
  animation-delay: -3.6s;
}

.icon-bess {
  right: 18%;
  bottom: 18%;
  width: 82px;
  height: 82px;
  stroke: rgba(232, 232, 232, 0.78);
  animation-delay: -5.2s;
}

.bg-line {
  width: 34%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(70, 223, 255, 0.72), rgba(255, 206, 0, 0.5), transparent);
  filter: drop-shadow(0 0 10px rgba(70, 223, 255, 0.45));
  opacity: 0.52;
  animation: driftLine 7.2s linear infinite;
}

.line-one {
  left: -8%;
  top: 28%;
}

.line-two {
  right: -10%;
  top: 55%;
  animation-delay: -2.4s;
}

.line-three {
  left: 18%;
  bottom: 24%;
  animation-delay: -4.6s;
}

.bg-particle {
  width: 5px;
  height: 5px;
  background: rgba(232, 232, 232, 0.92);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.48);
  opacity: 0.68;
  animation: particleBlink 2.8s steps(3, end) infinite;
}

.particle-one {
  left: 26%;
  top: 16%;
}

.particle-two {
  left: 72%;
  top: 30%;
  animation-delay: -0.7s;
}

.particle-three {
  left: 36%;
  bottom: 18%;
  animation-delay: -1.3s;
}

.particle-four {
  right: 21%;
  bottom: 32%;
  animation-delay: -2s;
}

.menu-card {
  /* Start screen styling: update this block to adjust the pre-game card. */
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  padding: clamp(28px, 5vw, 56px);
  text-align: center;
  background: linear-gradient(180deg, rgba(23, 26, 53, 0.96), rgba(13, 16, 35, 0.96));
  border: 1px solid var(--line);
  border-top: 5px solid var(--yellow);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.menu-card::before,
.board-wrap::before,
.status-panel::before,
.quiz-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 6px);
  opacity: 0.48;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

.menu-logo {
  width: min(210px, 48vw);
  max-height: 78px;
  margin: 0 auto 18px;
}

.header-logo {
  width: 94px;
  max-height: 48px;
  flex: 0 0 auto;
}

.menu-subtitle {
  margin: 8px 0 0;
  color: var(--cyan);
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-tagline {
  max-width: 600px;
  margin: 18px auto 0;
  color: rgba(232, 232, 232, 0.82);
  font-size: 1rem;
  line-height: 1.7;
}

.menu-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.menu-help {
  display: none;
  max-width: 590px;
  margin: 24px auto 0;
  padding: 18px 20px;
  color: rgba(232, 232, 232, 0.9);
  border: 1px solid rgba(70, 223, 255, 0.4);
  background: rgba(6, 12, 24, 0.72);
  text-align: left;
  line-height: 1.6;
}

.menu-help.show {
  display: block;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: rgba(14, 17, 39, 0.9);
  border: 1px solid var(--line);
  border-top: 4px solid var(--yellow);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: rgba(232, 232, 232, 0.72);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--white);
  font-family: "Courier New", ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(2.6rem, 7vw, 6.2rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(255, 206, 0, 0.82), 6px 6px 0 rgba(53, 119, 255, 0.42);
}

.brand-row h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(170px, 0.78fr) minmax(300px, 370px) minmax(320px, 1.12fr);
  gap: 18px;
  align-items: stretch;
}

.status-panel,
.quiz-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow: hidden;
}

.status-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.metric,
.next-box {
  background: rgba(6, 12, 24, 0.62);
  border: 1px solid rgba(232, 232, 232, 0.12);
  padding: 13px;
}

.metric span,
.next-box span,
.question-count {
  display: block;
  color: var(--gray);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--yellow);
  font-family: "Courier New", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.9rem;
  line-height: 1;
}

.next-box canvas {
  width: 100%;
  max-width: 112px;
  aspect-ratio: 1;
  display: block;
  margin-top: 10px;
  image-rendering: pixelated;
}

.board-wrap {
  position: relative;
  aspect-ratio: 1 / 2;
  overflow: hidden;
  background: var(--screen);
  border: 1px solid rgba(232, 232, 232, 0.16);
  border-top: 5px solid var(--yellow);
  box-shadow: var(--shadow);
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 11, 31, 0.84);
  backdrop-filter: blur(10px);
}

.overlay.show {
  display: flex;
}

#gameOverOverlay.show,
#pauseOverlay.show {
  z-index: 8;
}

.overlay-panel {
  width: min(320px, 100%);
  padding: 22px;
  text-align: center;
  background: linear-gradient(180deg, rgba(23, 26, 53, 0.98), rgba(9, 13, 28, 0.98));
  border: 1px solid rgba(70, 223, 255, 0.36);
  border-top: 4px solid var(--yellow);
  box-shadow: var(--shadow);
}

.overlay-panel h2 {
  margin-bottom: 12px;
  color: var(--yellow);
  font-size: 1.65rem;
  text-transform: uppercase;
}

.overlay-panel p {
  color: rgba(232, 232, 232, 0.82);
  line-height: 1.6;
}

.primary-button,
.secondary-button,
.answer-button,
.icon-button,
.retry-button {
  border: 1px solid transparent;
  color: var(--white);
  cursor: pointer;
  border-radius: 6px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  min-width: 136px;
  min-height: 48px;
  background: linear-gradient(180deg, var(--yellow), var(--yellow-2));
  color: #191919;
  box-shadow: 0 10px 26px rgba(255, 206, 0, 0.24);
}

.secondary-button {
  min-width: 118px;
  min-height: 44px;
  margin-top: 10px;
  background: rgba(232, 232, 232, 0.08);
  border-color: rgba(232, 232, 232, 0.18);
  color: var(--white);
}

.primary-button:hover,
.secondary-button:hover,
.answer-button:hover,
.icon-button:hover,
.retry-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 206, 0, 0.82);
}

.icon-button {
  width: 42px;
  height: 42px;
  background: rgba(232, 232, 232, 0.08);
  border-color: rgba(232, 232, 232, 0.16);
}

.retry-button {
  min-width: 78px;
  height: 42px;
  background: rgba(255, 206, 0, 0.14);
  border-color: rgba(255, 206, 0, 0.42);
  color: var(--yellow);
}

.quiz-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.timer-shell {
  height: 10px;
  overflow: hidden;
  background: rgba(232, 232, 232, 0.08);
  border: 1px solid rgba(232, 232, 232, 0.12);
}

#timerBar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--yellow), var(--orange));
  transform-origin: left center;
}

.question-count {
  margin-bottom: 0;
  color: var(--yellow);
}

#questionText {
  min-height: 112px;
  margin-bottom: 0;
  color: var(--white);
  font-size: clamp(1.16rem, 2vw, 1.55rem);
  line-height: 1.3;
}

.answers {
  display: grid;
  gap: 11px;
}

.answer-button {
  width: 100%;
  min-height: 58px;
  padding: 13px 15px;
  border-color: rgba(232, 232, 232, 0.14);
  background: rgba(6, 12, 24, 0.72);
  text-align: left;
  line-height: 1.35;
}

.answer-button:hover {
  background: rgba(70, 223, 255, 0.12);
}

.answer-button.correct {
  background: rgba(75, 234, 143, 0.2);
  color: #dfffe9;
  border-color: rgba(75, 234, 143, 0.88);
  box-shadow: 0 0 0 1px rgba(75, 234, 143, 0.28), 0 0 26px rgba(75, 234, 143, 0.16);
}

.answer-button.wrong {
  background: rgba(255, 77, 102, 0.2);
  color: #ffe4e8;
  border-color: rgba(255, 77, 102, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 77, 102, 0.28), 0 0 26px rgba(255, 77, 102, 0.14);
}

.answer-button:disabled {
  cursor: default;
  opacity: 1;
}

.feedback {
  min-height: 48px;
  margin-bottom: 0;
  color: rgba(232, 232, 232, 0.72);
  line-height: 1.45;
}

@keyframes gridRide {
  from {
    background-position: 0 0, 0 0;
  }

  to {
    background-position: 0 78px, 0 78px;
  }
}

@keyframes floatIcon {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(-2deg) scale(1);
    opacity: 0.46;
  }

  50% {
    transform: translate3d(18px, -30px, 0) rotate(6deg) scale(1.06);
    opacity: 0.72;
  }
}

@keyframes driftLine {
  0% {
    transform: translate3d(-12%, 0, 0);
    opacity: 0;
  }

  20%,
  80% {
    opacity: 0.52;
  }

  100% {
    transform: translate3d(40%, 0, 0);
    opacity: 0;
  }
}

@keyframes particleBlink {
  0%,
  100% {
    opacity: 0.24;
  }

  50% {
    opacity: 0.95;
  }
}

@media (max-width: 1020px) {
  .play-layout {
    grid-template-columns: minmax(150px, 0.72fr) minmax(280px, 340px) minmax(280px, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(720px, calc(100% - 20px));
    align-items: start;
    padding-top: 16px;
  }

  .brand-row {
    flex-wrap: wrap;
  }

  .header-controls {
    margin-left: auto;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .status-panel {
    grid-template-columns: repeat(5, 1fr);
  }

  .next-box {
    grid-column: span 2;
  }

  .next-box canvas {
    max-width: 72px;
  }

  .board-wrap,
  #board {
    width: min(100%, 360px);
    justify-self: center;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 14px, 430px);
  }

  .menu-actions {
    display: grid;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .header-logo {
    width: 72px;
  }

  .status-panel {
    grid-template-columns: repeat(2, 1fr);
  }

  .next-box {
    grid-column: 1 / -1;
  }

  .metric,
  .next-box,
  .quiz-panel {
    padding: 12px;
  }
}
