:root {
  color-scheme: light;
  --bg: #f2f5f1;
  --ink: #20221f;
  --muted: #686d65;
  --paper: #ffffff;
  --line: #d7ddd2;
  --green: #2f6f58;
  --blue: #315f8c;
  --red: #b8483f;
  --amber: #c78323;
  --soft-green: #e7f2eb;
  --soft-blue: #e8f0f7;
  --shadow: 0 18px 42px rgba(44, 60, 48, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic",
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1240px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0 40px;
}

.topbar,
.session-band,
.dashboard,
.summary {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.status-tile {
  display: grid;
  place-items: center;
  width: 82px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.status-tile span {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.status-tile small,
.metric-grid small {
  color: var(--muted);
  font-weight: 750;
}

.session-band {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-green);
}

.mode-label,
.skill-name {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-size: 13px;
  font-weight: 850;
}

.icon-button,
.primary-button,
.secondary-button {
  border-radius: 8px;
  min-height: 44px;
  border: 0;
  font-weight: 850;
}

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 22px;
}

.primary-button,
.secondary-button {
  padding: 0 18px;
}

.primary-button {
  background: var(--green);
  color: white;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.dashboard {
  grid-template-columns: minmax(230px, 0.7fr) minmax(420px, 1.35fr) minmax(260px, 0.85fr);
  align-items: start;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.profile-panel,
.log-panel,
.trainer {
  padding: 20px;
}

.panel-head {
  margin-bottom: 16px;
}

.skill-list {
  display: grid;
  gap: 10px;
}

.skill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.skill-row strong {
  font-size: 14px;
}

.skill-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.skill-state {
  min-width: 64px;
  text-align: center;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.memory-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft-blue);
}

.memory-box p {
  margin-bottom: 0;
  color: var(--blue);
  font-weight: 850;
}

.memory-box strong {
  font-size: 20px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.progress-track {
  flex: 1;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde5d8;
}

#progressBar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

.problem-card {
  position: relative;
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 30px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.stamp-effect {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
}

.stamp-mark {
  display: grid;
  place-items: center;
  width: min(62vw, 440px);
  aspect-ratio: 1;
  border: 18px solid rgba(188, 37, 28, 0.88);
  border-radius: 999px;
  color: rgba(188, 37, 28, 0.9);
  font-size: clamp(120px, 26vw, 270px);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.55);
  transform: rotate(-10deg);
  animation: fullStamp 920ms cubic-bezier(0.12, 0.9, 0.25, 1) both;
}

.stamp-effect.wrong .stamp-mark {
  width: min(54vw, 360px);
  border-color: transparent;
  color: rgba(184, 72, 63, 0.92);
  font-size: clamp(150px, 30vw, 310px);
  animation-name: fullStampWrong;
}

.problem-text {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(46px, 9vw, 82px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(120px, 220px) auto;
  gap: 10px;
  width: min(100%, 390px);
}

.action-slot {
  position: relative;
  width: 136px;
  min-height: 58px;
}

.action-slot .primary-button,
.answer-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 58px;
}

.answer-form input {
  width: 100%;
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
  font-size: 24px;
  font-weight: 850;
  text-align: center;
}

.answer-form input[readonly] {
  caret-color: transparent;
}

.answer-form input:focus {
  border-color: var(--green);
  outline: 3px solid rgba(47, 111, 88, 0.16);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 1fr));
  gap: 10px;
  width: min(100%, 390px);
}

.keypad button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(44, 60, 48, 0.06);
}

.keypad button:active {
  transform: translateY(1px);
  background: var(--soft-green);
}

.keypad button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.answer-overlay {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 6px;
  border: 2px solid rgba(188, 37, 28, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--red);
  box-shadow: 0 14px 30px rgba(184, 72, 63, 0.18);
  animation: stampPop 180ms ease-out;
}

.answer-overlay.wrong {
  border-color: rgba(184, 72, 63, 0.28);
  background: rgba(250, 236, 233, 0.96);
}

.overlay-mark {
  display: grid;
  place-items: center;
  width: 50px;
  aspect-ratio: 1;
  border-radius: 999px;
  border: 5px solid currentColor;
  color: var(--red);
  font-size: 30px;
  font-weight: 950;
  line-height: 1;
}

.answer-overlay.wrong .overlay-mark {
  border-color: transparent;
  font-size: 42px;
}

.overlay-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 950;
}

.answer-overlay:disabled {
  cursor: default;
}

.feedback-card {
  min-height: 104px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
}

.feedback-card.correct {
  background: var(--soft-green);
}

.feedback-card.wrong {
  background: #faece9;
}

.feedback-card p {
  margin-bottom: 8px;
  font-weight: 900;
}

#feedbackBody {
  color: var(--muted);
  line-height: 1.65;
  font-weight: 650;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric-grid div {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metric-grid span {
  font-size: 22px;
  font-weight: 900;
}

.attempt-log {
  display: grid;
  gap: 8px;
  max-height: 392px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.attempt-log li {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 13px;
}

.attempt-log li.wrong {
  border-left-color: var(--red);
}

.attempt-log strong {
  font-size: 14px;
}

.attempt-log span {
  color: var(--muted);
}

.summary {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 18px;
  padding: 20px;
}

.summary p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
  font-weight: 650;
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .profile-panel,
  .log-panel {
    order: 2;
  }

  .trainer {
    order: 1;
  }
}

@media (max-width: 620px) {
  .app {
    width: min(100vw - 18px, 1240px);
    padding-top: 14px;
  }

  .topbar,
  .session-band,
  .summary {
    grid-template-columns: 1fr;
  }

  .status-tile {
    width: 100%;
    aspect-ratio: auto;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 8px;
    min-height: 58px;
  }

  .answer-form {
    grid-template-columns: minmax(0, 1fr) 128px;
  }

  .keypad {
    grid-template-columns: repeat(3, 1fr);
  }

  .action-slot {
    width: 128px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@keyframes stampPop {
  0% {
    opacity: 0;
    transform: scale(1.18) rotate(-4deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes fullStamp {
  0% {
    opacity: 0;
    transform: scale(1.75) rotate(-18deg);
  }
  24% {
    opacity: 1;
    transform: scale(0.92) rotate(-8deg);
  }
  72% {
    opacity: 0.92;
    transform: scale(1) rotate(-10deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.04) rotate(-10deg);
  }
}

@keyframes fullStampWrong {
  0% {
    opacity: 0;
    transform: scale(1.45) rotate(6deg);
  }
  25% {
    opacity: 1;
    transform: scale(0.96) rotate(-3deg);
  }
  100% {
    opacity: 0;
    transform: scale(1.02) rotate(0deg);
  }
}
