:root {
  --bg: #fdf3df;
  --bg-accent: #ffe6b8;
  --ink: #2b2b2b;
  --muted: #6a5d4d;
  --primary: #ff7a18;
  --primary-dark: #e96500;
  --secondary: #3aa86c;
  --secondary-dark: #2b8556;
  --card: #fff9ef;
  --shadow: 0 16px 40px rgba(86, 59, 16, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", "Noto Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff7e5 0%, var(--bg) 45%, #f8d9a0 100%);
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app {
  width: min(1100px, 96vw);
  padding: 32px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffd166, #ff7a18);
  font-size: 28px;
  box-shadow: 0 10px 22px rgba(232, 112, 0, 0.35);
}

.title {
  font-size: 28px;
  font-weight: 700;
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
}

.panel {
  flex: 1;
  background: var(--card);
  border-radius: 30px;
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: -30% -30% auto auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 122, 24, 0.22), transparent 65%);
  z-index: 0;
}

.menu,
.session,
.summary {
  position: relative;
  z-index: 1;
}

.menu-card {
  max-width: 600px;
  margin: 0 auto;
  background: #fff4e2;
  border-radius: 24px;
  padding: 28px;
  box-shadow: inset 0 0 0 1px rgba(255, 122, 24, 0.18);
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.hint {
  margin: 0 0 24px;
  color: var(--muted);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

label {
  font-weight: 600;
  font-size: 15px;
}




.pill {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #ffe3b5;
  font-weight: 600;
}

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

.toggle,
.chip {
  border: none;
  padding: 10px 16px;
  border-radius: 14px;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", "Noto Sans", sans-serif;
  font-weight: 600;
  background: #ffe5c2;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.toggle.active,
.chip.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 122, 24, 0.35);
}

.toggle.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.toggle:hover:not(.disabled),
.chip:hover {
  transform: translateY(-2px);
}

.primary {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", "Noto Sans", sans-serif;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(255, 122, 24, 0.35);
}

.primary:hover {
  filter: brightness(1.02);
}

.ghost {
  margin: 20px auto 0;
  display: block;
  border: 2px dashed rgba(255, 122, 24, 0.4);
  background: transparent;
  padding: 10px 18px;
  border-radius: 14px;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", "Noto Sans", sans-serif;
  font-weight: 600;
  cursor: pointer;
}

.hidden {
  display: none;
}

.session-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.progress-label {
  font-weight: 600;
}

.progress-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10px, 1fr));
  gap: 6px;
}

.progress-segment {
  height: 12px;
  border-radius: 999px;
  background: #f3d7b4;
  transition: background 0.2s ease;
}

.progress-segment.correct {
  background: #5fce7c;
}

.progress-segment.wrong {
  background: #ff6b6b;
}

.problem-card {
  background: #fff;
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 18px 32px rgba(128, 79, 8, 0.16);
}

.problem {
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 700;
  margin-bottom: 16px;
}

#answerInput {
  width: min(360px, 90%);
  padding: 16px 18px;
  font-size: clamp(42px, 5vw, 64px);
  font-family: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  font-weight: 600;
  border-radius: 14px;
  border: 2px solid #ffd9a4;
  text-align: center;
  outline: none;
}

#answerInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(255, 122, 24, 0.2);
}

.feedback {
  min-height: 24px;
  margin-top: 12px;
  font-weight: 600;
  color: var(--secondary-dark);
}

.feedback.wrong {
  color: #e33e3e;
}

.round-message {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #e9f7ef;
  color: #2b8556;
  font-weight: 600;
  box-shadow: 0 8px 16px rgba(43, 133, 86, 0.12);
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.reaction {
  height: 40px;
  margin-top: 6px;
  font-size: 32px;
  opacity: 0;
  transform: translateY(6px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.reaction.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.reaction.happy {
  color: #2b8556;
  animation: pop 0.4s ease;
}

.reaction.sad {
  color: #e33e3e;
  animation: wobble 0.45s ease;
}

@keyframes pop {
  0% {
    transform: translateY(10px) scale(0.8);
  }
  60% {
    transform: translateY(-4px) scale(1.08);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes wobble {
  0% {
    transform: translateX(0) rotate(0deg);
  }
  25% {
    transform: translateX(-6px) rotate(-4deg);
  }
  50% {
    transform: translateX(6px) rotate(4deg);
  }
  100% {
    transform: translateX(0) rotate(0deg);
  }
}

.session-stats {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat {
  background: #ffe9c7;
  border-radius: 16px;
  padding: 14px 16px;
  text-align: center;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 20px 0 24px;
}

.summary-item {
  background: #fff1d4;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    align-self: stretch;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 8px;
    flex-basis: 100%;
    width: 100%;
  }

  .brand .header-controls {
    order: 2;
  }

  .lang-selector {
    flex-wrap: wrap;
  }

  .panel {
    padding: 20px;
  }

  .menu-card,
  .problem-card {
    padding: 20px;
  }

  .button-row {
    flex-direction: column;
  }
}

.session {
  position: relative;
}

.round-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 249, 239, 0.95);
  display: grid;
  place-items: center;
  z-index: 2;
  backdrop-filter: blur(3px);
}

.round-overlay-card {
  text-align: center;
  background: #fff1d4;
  padding: 30px 28px;
  border-radius: 24px;
  box-shadow: 0 18px 36px rgba(255, 122, 24, 0.25);
  max-width: 520px;
  animation: overlayPop 0.5s ease;
}

#roundOverlayTitle {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 42px);
}

#roundOverlayText {
  margin: 0;
  font-size: clamp(18px, 3vw, 26px);
  color: #2b8556;
  font-weight: 600;
}

@keyframes overlayPop {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  60% {
    opacity: 1;
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

.round-overlay.hidden {
  display: none;
}

.lang-selector {
  display: flex;
  gap: 8px;
}

.lang-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 12px;
  background: #ffe9c7;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.lang-btn.active {
  background: #ff7a18;
  color: #fff;
  box-shadow: 0 8px 18px rgba(255, 122, 24, 0.35);
}

.lang-btn:hover {
  transform: translateY(-2px);
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.mute-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #ffe9c7;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.mute-btn.muted {
  background: #f5c7a1;
  filter: grayscale(0.4);
}

.mute-btn:hover {
  transform: translateY(-2px);
}



.round-overlay-hint {
  margin-top: 16px;
  font-size: 16px;
  color: #6a5d4d;
}

.review-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 20px;
}

.review-item {
  background: #fff1d4;
  border-radius: 14px;
  padding: 12px 14px;
  font-family: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  font-size: 18px;
  display: flex;
  justify-content: space-between;
}

.review-item span:last-child {
  color: #2b8556;
  font-weight: 600;
}

.daily-goal {
  margin-bottom: 10px;
}

.daily-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  background: #fff1d4;
  border-radius: 18px;
  padding: 14px;
}

.daily-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.daily-value {
  font-size: 18px;
  font-weight: 700;
}

#maxNumberButtons .chip {
  min-width: 64px;
}

:focus-visible {
  outline: 3px solid #2b8556;
  outline-offset: 3px;
}

.progress-segment {
  display: grid;
  place-items: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.answer-submit {
  margin: 18px auto 0;
  width: min(360px, 90%);
  font-size: 18px;
  padding: 12px 18px;
}

#heatmapBtn {
  margin-bottom: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

#adaptiveToggle {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.avg-badge {
  display: none;
  font-size: 12px;
  font-weight: 700;
  color: #2b8556;
}

.avg-card.good {
  background: #e9f7ef;
}

.avg-card.bad {
  background: #ffe1e1;
}

.avg-badge.show {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 6px;
  animation: bounce 0.8s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

#restartBtn {
  width: min(360px, 90%);
  margin: 20px auto 0;
  padding: 12px 18px;
  display: block;
}
