:root {
  --accent: #c87940;
  --accent-dark: #7c4824;
  --wash: #f2c49e;
  --wrong: #ad473d;
}

.subtraction-stage {
  width: min(100%, 680px);
}

.subtraction-card {
  position: relative;
  display: grid;
  overflow: hidden;
  min-height: min(38vh, 330px);
  min-height: min(38dvh, 330px);
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  padding: 18px 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.34)),
    var(--wash);
  box-shadow: var(--shadow);
}

.subtraction-card::after {
  position: absolute;
  right: -40px;
  bottom: -48px;
  width: 122px;
  height: 122px;
  border: 2px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 50%;
  content: "";
}

.story-labels {
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.story-chip {
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
}

.story-chip strong {
  color: var(--accent-dark);
  font-family: "Nunito", sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.story-chip--take {
  border: 1px dashed color-mix(in srgb, var(--wrong) 52%, transparent);
  color: var(--wrong);
}

.object-grid {
  z-index: 1;
  display: flex;
  min-height: 112px;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 4vw, 22px);
}

.take-away-object {
  position: relative;
  display: grid;
  width: clamp(58px, 18vw, 88px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  place-items: center;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: clamp(3rem, 14vw, 5rem);
  line-height: 1;
  filter: drop-shadow(0 4px 5px rgba(32, 48, 41, 0.11));
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 150ms ease, filter 150ms ease;
}

.take-away-object:not(:disabled):hover { transform: translateY(-2px) scale(1.04); }
.take-away-object:not(:disabled):active { transform: scale(0.92); }
.take-away-object:focus-visible { outline: 4px solid color-mix(in srgb, var(--accent) 55%, white); outline-offset: 3px; }
.take-away-object:disabled { cursor: default; }

.subtraction-card.is-changing .take-away-object {
  animation: object-pop 290ms cubic-bezier(0.2, 0.85, 0.35, 1.2) both;
  animation-delay: calc(var(--object-index) * 55ms);
}

.take-away-object.is-taken {
  opacity: 0.35;
  filter: grayscale(0.75) drop-shadow(0 2px 3px rgba(32, 48, 41, 0.05));
  transform: translateY(-7px) scale(0.88);
}

.take-away-object.is-taken::after {
  position: absolute;
  width: 88%;
  height: 6px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  background: var(--wrong);
  box-shadow: 0 2px 5px rgba(92, 35, 30, 0.2);
  content: "";
  transform: rotate(-42deg);
}

.subtraction-card.is-changing .take-away-object.is-taken {
  animation: object-taken 420ms ease both;
}

.subtraction-equation {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 16px);
  color: var(--accent-dark);
  font-family: "Nunito", sans-serif;
  font-size: clamp(1.55rem, 7vw, 2.4rem);
  font-weight: 900;
}

.equation-answer {
  display: grid;
  width: 1.2em;
  height: 1.2em;
  place-items: center;
  border-radius: 0.32em;
  background: rgba(255, 255, 255, 0.72);
}

.feedback {
  min-height: 25px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.feedback.is-correct { color: var(--accent-dark); }
.feedback.is-ready { color: var(--accent-dark); }
.feedback.is-wrong { color: var(--wrong); }

.answer-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.answer-button {
  min-height: 68px;
  border: 2px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(32, 48, 41, 0.07);
  color: var(--ink);
  cursor: pointer;
  font-family: "Nunito", sans-serif;
  font-size: clamp(1.8rem, 8vw, 2.45rem);
  font-weight: 900;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.answer-button:hover { transform: translateY(-2px); border-color: var(--accent); }
.answer-button:active { transform: scale(0.97); }
.answer-button:disabled { cursor: default; }

.answer-options.is-waiting .answer-button {
  opacity: 0.42;
  transform: none;
}

.answer-button.is-correct {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--wash) 52%, white);
  color: var(--accent-dark);
}

.answer-button.is-wrong {
  border-color: var(--wrong);
  animation: gentle-shake 280ms ease;
}

@keyframes object-pop {
  0% { opacity: 0; transform: scale(0.58) translateY(7px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes object-taken {
  0% { opacity: 1; filter: none; transform: translateY(0) scale(1); }
  100% { opacity: 0.35; filter: grayscale(0.75); transform: translateY(-7px) scale(0.88); }
}

@keyframes gentle-shake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

@media (min-width: 700px) {
  .subtraction-card {
    min-height: min(42vh, 375px);
    min-height: min(42dvh, 375px);
    gap: 16px;
    padding: 24px;
    border-radius: 42px;
  }

  .answer-options { gap: 14px; }
  .answer-button { min-height: 80px; border-radius: 25px; }
}

@media (max-width: 420px) {
  .subtraction-card { padding-inline: 10px; }
  .object-grid { gap: 7px; }
  .take-away-object { width: clamp(52px, 17vw, 70px); }
}

@media (max-height: 700px) {
  .subtraction-card { min-height: 245px; gap: 8px; padding-block: 12px; }
  .object-grid { min-height: 92px; }
  .feedback { margin-block: 8px 6px; }
  .answer-button { min-height: 58px; }
}
