:root {
  --ink: #19304f;
  --muted: #607089;
  --paper: #fffaf2;
  --line: #dbe8f6;
  --blue: #5fc3ff;
  --blue-dark: #2778d8;
  --sun: #ffd54f;
  --coral: #ff776c;
  --mint: #5ad7a5;
  --grape: #7f6cff;
  --shadow: 0 18px 45px rgba(39, 120, 216, 0.18);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Trebuchet MS", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 213, 79, 0.42), transparent 24rem),
    linear-gradient(160deg, #dff6ff 0%, #eef8ff 43%, #fff4df 100%);
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.shape {
  position: absolute;
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  opacity: 0.64;
  animation: floaty 8s ease-in-out infinite;
}

.shape::before,
.shape::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 4rem;
  font-weight: 900;
}

.shape-one {
  top: 10%;
  left: -0.7rem;
  color: var(--coral);
}

.shape-one::before {
  content: "+";
}

.shape-two {
  top: 18%;
  right: 0.8rem;
  color: var(--grape);
  animation-delay: -2s;
}

.shape-two::before {
  content: "x";
}

.shape-three {
  bottom: 16%;
  left: 1rem;
  color: var(--mint);
  animation-delay: -4s;
}

.shape-three::before {
  content: "%";
}

.shape-four {
  right: 0.2rem;
  bottom: 9%;
  color: var(--sun);
  animation-delay: -1s;
}

.shape-four::before {
  content: "=";
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 31rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: 0.9rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  touch-action: manipulation;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.1rem 0;
}

.eyebrow {
  margin: 0 0 0.12rem;
  color: var(--blue-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 11.2vw, 4rem);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 4px 0 #ffffff;
}

.icon-button {
  width: 3rem;
  height: 3rem;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--sun);
  box-shadow: var(--shadow);
  font-size: 1.45rem;
  font-weight: 900;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.score-strip > div {
  min-width: 0;
  padding: 0.62rem 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(39, 120, 216, 0.1);
  text-align: center;
  backdrop-filter: blur(8px);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-strip strong {
  display: block;
  margin-top: 0.18rem;
  font-size: 1.35rem;
  line-height: 1;
}

.play-panel,
.results-panel {
  border: 3px solid #fff;
  border-radius: 0.5rem;
  background: rgba(255, 250, 242, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.play-panel {
  display: grid;
  gap: 0.62rem;
  padding: 0.72rem;
}

.score-strip[hidden],
.play-panel[hidden],
.results-panel[hidden] {
  display: none;
}

.timer-wrap {
  position: relative;
  justify-self: center;
  width: 5.95rem;
  height: 5.95rem;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 8px 15px rgba(39, 120, 216, 0.16));
}

.timer-track,
.timer-progress {
  fill: none;
  stroke-width: 12;
}

.timer-track {
  stroke: #e9f2fb;
}

.timer-progress {
  stroke: var(--mint);
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  transition: stroke 160ms linear;
}

.timer-number {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  font-weight: 1000;
}

.timer-wrap.warning .timer-progress {
  stroke: var(--coral);
}

.timer-wrap.warning .timer-number {
  animation: pulse 420ms ease-in-out infinite alternate;
}

.question-card {
  display: grid;
  gap: 0.48rem;
  padding: 0.78rem;
  border: 2px dashed #cde3f7;
  border-radius: 0.5rem;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, var(--blue), var(--sun), var(--coral)) border-box;
}

.round-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.question {
  min-height: 4.25rem;
  display: grid;
  place-items: center;
  font-size: clamp(2.05rem, 12.4vw, 4.7rem);
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.answer-display {
  min-height: 3.25rem;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
  background: #f7fbff;
  color: var(--blue-dark);
  font-size: 2.2rem;
  font-weight: 1000;
  line-height: 1;
}

.feedback {
  min-height: 1.8rem;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
}

.feedback.good {
  color: #16865d;
}

.feedback.bad {
  color: #c74242;
}

.keypad {
  order: 5;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.46rem;
}

.keypad button,
.primary-action {
  min-height: 3.28rem;
  border-radius: 0.5rem;
  box-shadow: 0 7px 0 rgba(25, 48, 79, 0.18);
  font-weight: 1000;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.keypad button {
  background: #ffffff;
  border: 2px solid #d6e8f9;
  font-size: 1.55rem;
}

.keypad button:active,
.primary-action:active,
.icon-button:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 rgba(25, 48, 79, 0.18);
}

.keypad button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.55;
}

.soft-key {
  color: #be5a18;
  background: #fff2d1 !important;
  border-color: #ffd886 !important;
}

.enter-key {
  color: #fff;
  background: var(--blue-dark) !important;
  border-color: #1f62b1 !important;
}

.primary-action {
  order: 4;
  color: #fff;
  background: linear-gradient(135deg, var(--coral), #ff9d4f);
  font-size: 1.25rem;
}

.results-panel {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.results-panel h2 {
  font-size: clamp(2.25rem, 11vw, 4rem);
  line-height: 1.05;
  text-align: center;
}

.results-panel p {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

.stars {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.2rem;
  color: var(--sun);
  font-size: 2.3rem;
  text-shadow: 0 2px 0 #ffffff;
}

.result-action {
  order: initial;
  margin-top: 0.25rem;
}

.review-list {
  display: grid;
  gap: 0.45rem;
}

.review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.6rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: #ffffff;
  font-weight: 850;
}

.review-item span:last-child {
  flex: 0 0 auto;
}

.review-item.correct span:last-child {
  color: #16865d;
}

.review-item.wrong span:last-child {
  color: #c74242;
}

.pop {
  animation: pop 300ms ease-out;
}

@keyframes floaty {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(-5deg);
  }

  50% {
    transform: translate3d(0, -18px, 0) rotate(7deg);
  }
}

@keyframes pulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.1);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.94);
  }

  70% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

@media (min-width: 46rem) {
  body {
    display: grid;
    place-items: center;
  }

  .game-shell {
    min-height: auto;
    padding-block: 2rem;
  }

  .play-panel {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
