:root {
  --bg-1: #fff9eb;
  --bg-2: #f4f0ff;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(62, 43, 14, 0.12);
  --text: #241a10;
  --muted: #6f5f50;
  --accent: #f18f01;
  --accent-2: #2a9d8f;
  --success: #1f8f5f;
  --danger: #d64545;
  --shadow: 0 24px 70px rgba(46, 27, 10, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  font-family: "Trebuchet MS", "Verdana", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(241, 143, 1, 0.22), transparent 34%),
    radial-gradient(circle at top right, rgba(42, 157, 143, 0.18), transparent 28%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  overflow-x: hidden;
}

.bg-blobs::before,
.bg-blobs::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.45;
  pointer-events: none;
}

.bg-blobs::before {
  width: 220px;
  height: 220px;
  right: -40px;
  top: 20px;
  background: rgba(241, 143, 1, 0.2);
}

.bg-blobs::after {
  width: 280px;
  height: 280px;
  left: -60px;
  bottom: -40px;
  background: rgba(42, 157, 143, 0.18);
}

.app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 40px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
  padding: 32px clamp(16px, 3vw, 32px) 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-2);
  font-weight: 800;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
}

.subcopy {
  max-width: 48rem;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.stats {
  width: 100%;
}

.stats-table-wrap,
.game-card {
  border: 1px solid var(--card-border);
  background: var(--card);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.stats-table-wrap {
  border-radius: 18px;
  overflow: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.stats-table th,
.stats-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(62, 43, 14, 0.08);
  text-align: left;
}

.stats-table thead th {
  background: rgba(36, 26, 16, 0.05);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-table tbody th {
  font-weight: 800;
}

.stats-table tbody tr:last-child th,
.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.stats-table td {
  font-weight: 800;
  text-align: center;
}

.game-card {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding: 26px clamp(16px, 3vw, 32px);
  overflow: hidden;
}

.choice-screen,
.play-screen {
  min-height: 460px;
}

.choice-screen {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 48px 20px;
}

.choice-screen h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.choice-screen p {
  margin: 0 0 22px;
  color: var(--muted);
  max-width: 34rem;
}

.choice-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.choice-group {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.choice-group h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.mode-button,
.level-button,
.submit-button,
.link-button {
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.level-button {
  min-width: 120px;
  padding: 14px 18px;
  font-size: 1rem;
  background: rgba(36, 26, 16, 0.07);
  color: var(--text);
}

.level-button.is-active {
  background: linear-gradient(135deg, #2a9d8f, #1f8f5f);
  color: #fff;
}

.mode-button {
  min-width: 170px;
  padding: 16px 24px;
  font-size: 1.2rem;
  background: rgba(36, 26, 16, 0.07);
  color: var(--text);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.12);
}

.mode-button.is-selected {
  background: linear-gradient(135deg, #2a9d8f, #1f8f5f);
  color: #fff;
  transform: translateY(-2px);
}

.mode-button:hover,
.submit-button:hover,
.link-button:hover {
  transform: translateY(-2px);
}

.start-button {
  border: 0;
  border-radius: 18px;
  padding: 16px 28px;
  margin-top: 8px;
  background: linear-gradient(135deg, #241a10, #4d3825);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease;
}

.start-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.hidden {
  display: none !important;
}

.play-screen.hidden,
.choice-screen.hidden {
  display: none !important;
}

.play-screen {
  display: grid;
  gap: 18px;
  align-content: start;
}

.mode-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(36, 26, 16, 0.06);
  font-weight: 800;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.link-button {
  background: transparent;
  color: var(--accent-2);
  padding: 8px 12px;
}

.equation {
  display: flex;
  align-items: stretch;
  gap: 14px;
  width: 100%;
}

.money-side {
  flex: 1 1 0;
  min-width: 0;
  min-height: 280px;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 247, 232, 0.82));
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: grid;
  align-content: start;
  gap: 10px;
}

.helper-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(42, 157, 143, 0.08);
  border: 1px solid rgba(42, 157, 143, 0.14);
}

.helper-label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.helper-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.helper-group {
  position: relative;
  display: flex;
  align-items: center;
}

.helper-group span {
  position: absolute;
  left: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.92rem;
  z-index: 1;
}

.helper-group input {
  width: 100%;
  border: 1px solid rgba(36, 26, 16, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 10px 10px 30px;
  font: inherit;
  font-weight: 800;
  color: var(--text);
  outline: none;
}

.helper-group input:focus {
  border-color: rgba(42, 157, 143, 0.7);
  box-shadow: 0 0 0 3px rgba(42, 157, 143, 0.12);
}

.helper-total {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

.money-side-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.money-toggle {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(42, 157, 143, 0.14);
  color: #15685d;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.money-hint-tag {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(241, 143, 1, 0.16);
  color: #9e5600;
  font-size: 0.85rem;
  font-weight: 800;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.money-hint-tag.is-used {
  background: rgba(42, 157, 143, 0.18);
  color: #15685d;
}

.money-pieces {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  justify-content: center;
  gap: 10px;
  overflow: auto;
  max-height: 100%;
}

.money-total {
  width: 100%;
  text-align: center;
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 6px;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    max-height 160ms ease,
    margin-bottom 160ms ease;
}

.money-total.is-hidden {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
}

.operator,
.equals {
  flex: 0 0 auto;
  align-self: center;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  font-weight: 900;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}

.operator {
  animation: pulse 1.8s ease-in-out infinite;
}

.answer-form {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr)) auto;
  gap: 12px;
  align-items: center;
}

.answer-group {
  position: relative;
  display: flex;
  align-items: center;
}

.answer-symbol {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-weight: 800;
  z-index: 1;
}

.answer-group input {
  width: 100%;
  border: 2px solid rgba(36, 26, 16, 0.12);
  border-radius: 16px;
  background: #fff;
  padding: 16px 16px 16px 46px;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  outline: none;
}

.answer-group input:focus {
  border-color: rgba(42, 157, 143, 0.7);
  box-shadow: 0 0 0 4px rgba(42, 157, 143, 0.15);
}

.submit-button {
  padding: 16px 22px;
  background: linear-gradient(135deg, #241a10, #4d3825);
  color: #fff;
  min-width: 110px;
}

.feedback {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
}

.money-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.07);
}

.money-piece img {
  width: 78px;
  height: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
}

.money-piece span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.success-state {
  animation: pop 420ms ease;
  box-shadow:
    0 0 0 4px rgba(31, 143, 95, 0.18),
    var(--shadow);
}

.wrong-state {
  animation: shake 420ms ease;
  box-shadow:
    0 0 0 4px rgba(214, 69, 69, 0.16),
    var(--shadow);
}

.correct-message {
  color: var(--success);
}

.wrong-message {
  color: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.98);
  }
  60% {
    transform: scale(1.015);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(6px);
  }
}

@media (max-width: 960px) {
  .equation {
    flex-direction: column;
  }

  .operator,
  .equals {
    font-size: 3rem;
  }

  .answer-form {
    grid-template-columns: 1fr;
  }

  .mode-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .pill-row {
    width: 100%;
  }

  .mode-pill {
    width: fit-content;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding-bottom: 24px;
  }

  .game-card {
    padding: 18px;
  }

  .hero {
    padding-top: 18px;
  }

  .stats {
    width: 100%;
  }

  .stat-card {
    min-width: 0;
  }

  .money-side {
    min-height: 220px;
  }

  .money-piece img {
    width: 64px;
  }
}
