:root {
  --gold: #f4c542;
  --gold-deep: #b8860b;
  --neon: #2d6fff;
  --neon-hot: #5b8cff;
  --ink: #07060a;
  --triangle: #14245c;
  --ball: min(78vw, 360px); /* ball diameter; overridden on short screens */
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #fff;
  background:
    radial-gradient(circle at 50% 0%, #141a3a 0%, #0a0a18 55%, #05060a 100%);
  overflow: hidden;
  touch-action: manipulation;
}

.stage {
  width: min(94vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Marquee + lights ------------------------------------------------- */

.marquee {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  width: 100%;
}

.title {
  margin: 0;
  white-space: nowrap;
  font-size: clamp(26px, 8.5vw, 40px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow:
    0 0 6px var(--neon-hot),
    0 0 14px var(--neon),
    0 2px 0 #0a1430;
  animation: neon-flicker 3.5s infinite;
}

@keyframes neon-flicker {
  0%, 18%, 22%, 100% { opacity: 1; }
  20% { opacity: 0.55; }
  60% { opacity: 1; }
  62% { opacity: 0.7; }
}

.bulbs {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background-image: radial-gradient(circle, var(--gold) 0 3px, transparent 4px);
  background-size: 16px 10px;
  background-position: center;
  background-repeat: repeat-x;
  animation: chase 0.8s steps(2) infinite;
}

@keyframes chase {
  to { background-position-x: 16px; }
}

/* ---- Ball ------------------------------------------------------------- */

.ball {
  position: relative;
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background:
    radial-gradient(circle at 32% 26%, #4a4a4a 0%, #1c1c1c 34%, #000 72%);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.9),
    inset -18px -22px 50px rgba(0, 0, 0, 0.8),
    0 30px 60px rgba(0, 0, 0, 0.75),
    0 0 0 2px #000;
  will-change: transform;
}

.ball:active {
  cursor: grabbing;
}

.ball:focus {
  outline: none;
}

/* Keyboard focus gets an intentional gold halo instead of the browser default. */
.ball:focus-visible {
  outline: none;
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.9),
    inset -18px -22px 50px rgba(0, 0, 0, 0.8),
    0 30px 60px rgba(0, 0, 0, 0.75),
    0 0 0 3px var(--gold),
    0 0 22px 4px rgba(244, 197, 66, 0.5);
}

/* Glossy highlight near the top-left. */
.ball-shine {
  position: absolute;
  left: 18%;
  top: 12%;
  width: 38%;
  height: 28%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 70%);
  filter: blur(2px);
  pointer-events: none;
}

/* The white "8" disc sits up top. */
.number {
  position: absolute;
  left: 50%;
  top: 24%;
  width: 30%;
  height: 30%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff, #e7e7e7 70%, #cfcfcf);
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: calc(var(--ball) * 0.17);
  line-height: 1;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* The dark answer window, lower-center. */
.window {
  position: absolute;
  left: 50%;
  top: 62%;
  width: 46%;
  height: 46%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #0b1024 0%, #04060f 70%);
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.95), inset 0 4px 10px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

/* The blue answer die, seen through the window. */
.triangle {
  position: relative;
  width: 84%;
  height: 84%;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(50% 8%, 92% 88%, 8% 88%);
  background:
    radial-gradient(circle at 50% 70%, var(--neon) 0%, var(--triangle) 60%, #0a1334 100%);
  box-shadow: 0 0 22px rgba(45, 111, 255, 0.45);
  opacity: 0.96;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.answer {
  max-width: 66%;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.05;
  font-size: calc(var(--ball) * 0.044);
  color: #eaf0ff;
  text-shadow: 0 0 8px rgba(150, 185, 255, 0.7);
  transform: translateY(16%); /* sit in the wide lower part of the triangle */
}

/* While "thinking", the answer fades and the die drifts like ink in water. */
.ball.thinking .triangle {
  opacity: 0.15;
  transform: scale(0.9) rotate(-4deg);
  animation: swirl 0.6s ease-in-out infinite alternate;
}

@keyframes swirl {
  from { transform: scale(0.86) translate(-4%, 3%) rotate(-6deg); }
  to   { transform: scale(0.96) translate(4%, -2%) rotate(6deg); }
}

.ball.reveal .triangle {
  animation: pop 0.45s ease;
}

@keyframes pop {
  0% { opacity: 0.1; transform: scale(0.7); }
  60% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0.96; transform: scale(1); }
}

/* Shake animation, applied for the duration of a shake. */
.ball.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate(-3px, 1px) rotate(-2deg); }
  20%, 80% { transform: translate(5px, -2px) rotate(3deg); }
  30%, 50%, 70% { transform: translate(-8px, 2px) rotate(-4deg); }
  40%, 60% { transform: translate(8px, -1px) rotate(4deg); }
}

/* ---- Hint ------------------------------------------------------------- */

.hint {
  margin-top: 26px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
  opacity: 0.7;
  min-height: 16px;
}

@media (max-height: 720px) {
  :root { --ball: min(62vw, 280px); }
  .marquee { margin-bottom: 14px; }
  .hint { margin-top: 16px; }
}
