:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5b6478;
  --paper: #fffaf0;
  --green: #91c83f;
  --blue: #2563eb;
  --pink: #e83e8c;
  --gold: #f7b731;
  --bad: #ef4444;
  --good: #16a34a;
}

* {
  box-sizing: border-box;
}

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

body {
  align-items: center;
  background:
    radial-gradient(circle at 18% 16%, rgba(247, 183, 49, 0.28), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(232, 62, 140, 0.22), transparent 26%),
    linear-gradient(135deg, #e7fbff 0%, #fff8dc 52%, #efffea 100%);
  color: var(--ink);
  display: flex;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  justify-content: center;
  padding: 18px;
}

button {
  background: var(--ink);
  border: 0;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 12px 18px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  box-shadow: 0 12px 24px rgba(23, 32, 51, 0.22);
  transform: translateY(-1px);
}

.game-shell {
  max-width: 1120px;
  width: min(100%, 1120px);
}

.hud {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--pink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(30px, 5vw, 56px);
  line-height: 0.96;
  margin-bottom: 0;
}

h2 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  margin-bottom: 12px;
}

.money-card {
  background: white;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 7px 7px 0 var(--gold);
  min-width: 240px;
  padding: 12px 14px;
  text-align: right;
}

.money-card span,
.money-card small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 800;
}

.money-card strong {
  display: block;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.stage-wrap {
  background: #111827;
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: 12px 12px 0 rgba(23, 32, 51, 0.16);
  overflow: hidden;
  position: relative;
}

.toast-stack {
  display: grid;
  gap: 10px;
  left: 50%;
  max-width: min(92%, 520px);
  pointer-events: none;
  position: absolute;
  top: 18px;
  transform: translateX(-50%);
  width: max-content;
  z-index: 3;
}

.toast {
  animation: toast-pop 2.35s ease forwards;
  background: linear-gradient(135deg, #ffffff, #fff2a6 45%, #ffd6ec);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 6px 6px 0 rgba(23, 32, 51, 0.25);
  color: var(--ink);
  font-size: clamp(16px, 2.6vw, 23px);
  font-weight: 950;
  line-height: 1.15;
  overflow-wrap: anywhere;
  padding: 12px 16px;
  text-align: center;
}

@keyframes toast-pop {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0.86);
  }

  12%,
  78% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-24px) scale(0.95);
  }
}

canvas {
  aspect-ratio: 16 / 9;
  display: block;
  height: auto;
  touch-action: none;
  width: 100%;
}

.overlay {
  align-items: center;
  background: rgba(23, 32, 51, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: absolute;
}

.overlay.hidden {
  display: none;
}

.panel {
  background: rgba(255, 250, 240, 0.96);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: 10px 10px 0 rgba(23, 32, 51, 0.35);
  max-width: 520px;
  padding: 28px;
  text-align: center;
}

.panel p:not(.eyebrow) {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.win-panel {
  background: linear-gradient(135deg, #fff7ad, #ffffff 48%, #dfffe8);
}

.scoreboard {
  margin-top: 18px;
}

.subjects {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.subject {
  background: white;
  border: 2px solid rgba(23, 32, 51, 0.18);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
  padding: 10px;
}

.subject strong {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar {
  background: #e9edf5;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

.fill {
  background: linear-gradient(90deg, var(--blue), var(--good));
  border-radius: inherit;
  height: 100%;
  transition: width 0.2s ease;
}

.subject span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-top: 7px;
}

.tips {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.tips span {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 7px 11px;
}

@media (max-width: 820px) {
  body {
    align-items: start;
    padding: 12px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .money-card {
    min-width: 0;
    text-align: left;
  }

  .subjects {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 20px;
  }
}
