@font-face {
  font-family: "Zen Maru Gothic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/zen-maru-gothic-400.woff2") format("woff2");
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/zen-maru-gothic-700.woff2") format("woff2");
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/zen-maru-gothic-900.woff2") format("woff2");
}

@font-face {
  font-family: "M PLUS Rounded 1c";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/m-plus-rounded-1c-800.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink: #1e304f;
  --muted: #6d7a8e;
  --line: #e5f1f6;
  --paper: #fffdf7;
  --panel: #ffffff;
  --accent: #ff6262;
  --blue: #2d9bf0;
  --green: #35c96d;
  --mint: #ddf7ed;
  --yellow: #fff0a6;
  --taken: #cfd6de;
  --outline: #1e304f;
  --shadow: 0 4px 0 rgba(30, 48, 79, 0.25);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font-text: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --font-number: "M PLUS Rounded 1c", "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --weight-text: 700;
  --weight-number: 800;
}

* {
  box-sizing: border-box;
  -webkit-user-drag: none;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  background:
    linear-gradient(rgba(229, 241, 246, 0.72) 1px, transparent 1px),
    linear-gradient(90deg, rgba(229, 241, 246, 0.72) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font-text);
  font-weight: var(--weight-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.eq-number,
.eq-symbol,
.answer-box,
.choice,
.count-limit-button,
.count-progress,
.count-time,
.count-row-label,
.count-result-score,
.count-result-stats strong,
.bead-group-label {
  font-family: var(--font-number);
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

select {
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

.app {
  position: relative;
  width: min(100%, 1024px);
  height: 100%;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 24px clamp(18px, 5vw, 72px) 34px;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-content: start;
  gap: clamp(10px, 1.8vh, 18px);
  overflow: hidden;
  touch-action: none;
}

.topbar {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.level-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 54px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #ffe66b;
  box-shadow: 0 5px 0 #d6b33e;
}

.level-control::after {
  content: "";
  position: absolute;
  right: 15px;
  width: 8px;
  height: 8px;
  border-right: 3px solid var(--outline);
  border-bottom: 3px solid var(--outline);
  pointer-events: none;
  transform: translateY(-2px) rotate(45deg);
}

.level-control::before {
  content: "★";
  width: 30px;
  height: 30px;
  margin-left: 10px;
  border: 3px solid var(--outline);
  border-radius: 9px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

.level-control select {
  min-height: 48px;
  border: 0;
  border-radius: 15px;
  padding: 0 38px 0 10px;
  appearance: none;
  background: transparent;
  color: var(--outline);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  outline: none;
}

.level-control select:hover,
.level-control select:focus-visible {
  background: rgba(255, 255, 255, 0.18);
}

.streak {
  max-width: min(54vw, 430px);
  max-height: 72px;
  min-height: 54px;
  min-width: 148px;
  padding: 7px 10px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 0 #c9d2de;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 2px 5px;
  overflow: hidden;
  font-size: 24px;
  line-height: 1;
}

.streak::before {
  content: "ごほうび";
  margin-right: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.count-status {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.app.is-count .count-status {
  display: flex;
}

.count-limit {
  min-height: 54px;
  padding: 5px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 5px 0 #c9d2de;
  display: flex;
  align-items: center;
  gap: 4px;
}

.count-limit-button {
  min-width: 48px;
  min-height: 38px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.count-limit-button.is-active {
  background: var(--yellow);
  color: var(--outline);
  box-shadow: inset 0 0 0 2px var(--outline);
}

.count-limit-button:hover,
.count-limit-button:focus-visible {
  background: #fff7cf;
  color: var(--outline);
  outline: none;
}

.count-progress {
  min-width: 112px;
  min-height: 54px;
  padding: 0 18px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #ffffff;
  color: var(--outline);
  box-shadow: 0 5px 0 #c9d2de;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.reward-emoji {
  display: inline-flex;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: rewardPop 240ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.count-timer {
  width: 198px;
  min-height: 242px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--outline);
  font-weight: 800;
}

.count-timer[hidden] {
  display: none;
}

.app.is-count .streak {
  display: none;
}

.app.is-count .count-progress {
  display: flex;
}

.clock-face {
  position: relative;
  width: 182px;
  height: 182px;
  border: 5px solid var(--outline);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--outline) 0 5px, transparent 6px),
    #fff7cf;
  box-shadow: inset 0 -6px 0 rgba(30, 48, 79, 0.12);
}

.clock-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 7px;
  height: 66px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%) rotate(0deg);
  transform-origin: 50% 100%;
}

.count-time {
  min-width: 0;
  font-size: 26px;
  text-align: center;
}

.equation {
  display: grid;
  grid-template-columns: minmax(1.8ch, auto) 0.62ch minmax(1ch, auto) 0.72ch minmax(1.3ch, auto);
  align-items: center;
  justify-content: center;
  column-gap: clamp(8px, 1.45vw, 16px);
  row-gap: 0;
  width: min(100%, 860px);
  margin: clamp(30px, 4vh, 44px) auto 0;
  padding: clamp(12px, 2.4vw, 18px) clamp(18px, 5vw, 48px);
  border: 4px solid var(--outline);
  border-radius: 18px;
  background: var(--yellow);
  box-shadow: 0 7px 0 #d8b94a;
  font-size: clamp(54px, 8vw, 88px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.eq-part {
  min-height: clamp(68px, 9vw, 96px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.eq-number {
  min-width: 1.4ch;
  color: var(--blue);
  transition: color 160ms var(--ease);
}

.equation.is-add #eqB,
.app:has(#leftZone.is-clickable:hover) .equation.is-sub #eqB,
.app:has(#leftZone.is-clickable:focus-visible) .equation.is-sub #eqB {
  color: var(--green);
}

.equation.is-count {
  grid-template-columns: 1fr;
  width: min(100%, 620px);
  margin-top: clamp(10px, 2vh, 20px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: clamp(30px, 5vw, 46px);
}

.equation.is-count #eqA {
  min-width: auto;
  color: var(--ink);
}

.equation.is-count .eq-symbol,
.equation.is-count #eqB,
.equation.is-count #eqAnswer {
  display: none;
}

.eq-symbol {
  color: #8390a0;
  transform: none;
}

.answer-box {
  min-width: clamp(76px, 10vw, 98px);
  margin-left: clamp(10px, 1.7vw, 18px);
  padding: 0 12px;
  border: 4px solid var(--outline);
  border-radius: 18px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 0 #b33a48;
  transform: translateY(-0.02em);
}

.answer-box.is-filled {
  border-color: var(--outline);
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 6px 0 #20904d;
}

.play {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: clamp(12px, 2.5vw, 34px);
  width: min(100%, 980px);
  margin: 20px auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.count-game {
  position: relative;
  width: min(100%, 860px);
  min-height: 342px;
  margin: 4px auto 0;
  display: grid;
  place-items: center;
}

.count-correct-mark {
  position: absolute;
  left: 50%;
  top: 36%;
  z-index: 5;
  color: rgba(255, 98, 98, 0.32);
  font-size: clamp(170px, 23vw, 250px);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 5px 0 rgba(30, 48, 79, 0.08);
  transform: translate(-50%, -50%);
  animation: countCorrectPop 360ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.count-correct-mark[hidden] {
  display: none;
}

.count-stage {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 34px);
}

.count-board {
  display: grid;
  grid-template-columns: repeat(5, 50px) 38px;
  gap: 8px;
  padding: 14px;
  border: 4px solid var(--outline);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 7px 0 #c9d2de;
}

.count-cell {
  width: 50px;
  height: 50px;
  border: 3px solid #d8e2ec;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}

.count-cell.is-empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.34);
}

.count-cell .bead {
  width: 36px;
  height: 36px;
}

.count-row-label {
  width: 38px;
  height: 50px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: #fff7cf;
  color: var(--outline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 0 #c9d2de;
}

.count-row-label.is-muted {
  border-color: #d8e2ec;
  background: #f4f7fa;
  color: #b2bcc9;
  box-shadow: none;
}

.count-result {
  width: min(100%, 620px);
  padding: 28px;
  border: 4px solid var(--outline);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 7px 0 #c9d2de;
  text-align: center;
}

.count-result-title {
  color: var(--accent);
  font-size: clamp(34px, 6vw, 54px);
  font-weight: 800;
  line-height: 1;
}

.count-result-score {
  margin-top: 14px;
  color: var(--outline);
  font-size: clamp(56px, 10vw, 86px);
  font-weight: 800;
  line-height: 1;
}

.count-result-stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 800;
}

.count-result-stats span {
  min-height: 58px;
  padding: 8px 6px;
  border: 3px solid #d8e2ec;
  border-radius: 14px;
  background: #f9fcff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.count-result-stats strong {
  color: var(--outline);
  font-size: 22px;
}

.connector {
  min-width: 1ch;
  min-height: 1em;
  padding: 0 clamp(2px, 1vw, 8px);
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  color: var(--outline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

.bead-zone {
  height: 216px;
  min-height: 216px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.42);
  display: grid;
  grid-template-columns: repeat(5, 38px);
  gap: 13px;
  align-content: center;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), box-shadow 160ms var(--ease), opacity 160ms var(--ease);
}

.bead-zone.is-clickable {
  cursor: pointer;
}

.bead-zone.is-clickable:hover,
.bead-zone.is-clickable:focus-visible {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 3px var(--green);
  outline: none;
}

.bead-zone.is-target {
  background: rgba(255, 255, 255, 0.52);
}

.play:has(#rightZone.is-clickable:hover) #leftZone.is-target,
.play:has(#rightZone.is-clickable:focus-visible) #leftZone.is-target,
.play:has(#leftZone.is-clickable:hover) #rightZone.is-target,
.play:has(#leftZone.is-clickable:focus-visible) #rightZone.is-target {
  background: rgba(53, 201, 109, 0.08);
  box-shadow: inset 0 0 0 3px var(--green);
}

.bead-zone.is-empty {
  height: 216px;
  min-height: 216px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aeb7c3;
  font-size: 24px;
  font-weight: 800;
}

.bead {
  --bead-fill: var(--blue);
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--outline);
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.82) 0 10%, rgba(255, 255, 255, 0) 12%),
    var(--bead-fill);
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: transform 140ms var(--ease), opacity 140ms var(--ease), background 140ms var(--ease);
}

.bead-group {
  position: relative;
  display: inline-flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.bead-group-label {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  min-width: 58px;
  min-height: 42px;
  padding: 1px 12px 3px;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: #ffffff;
  color: var(--outline);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 0 #c9d2de;
  transform: translate(-50%, -50%);
}

.bead-chain {
  --bead-size: 38px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, var(--bead-size));
  gap: 8px;
  padding: 9px;
  border: 4px solid #ffd84a;
  border-radius: 26px;
  background: rgba(255, 216, 74, 0.06);
}

.bead.add {
  --bead-fill: var(--green);
}

.bead.taken {
  --bead-fill: var(--green);
}

.bead-zone.is-clickable:hover .bead.add,
.bead-zone.is-clickable:focus-visible .bead.add,
.bead-zone.is-clickable:hover .bead.will-take,
.bead-zone.is-clickable:focus-visible .bead.will-take {
  transform: translateY(-4px) scale(1.04);
}

.bead-zone.is-clickable:hover .bead.will-take,
.bead-zone.is-clickable:focus-visible .bead.will-take {
  --bead-fill: var(--green);
}

.hint {
  position: absolute;
  top: clamp(83px, calc(12vh - 5px), 107px);
  left: 50%;
  z-index: 6;
  width: max-content;
  max-width: min(88vw, 620px);
  min-height: 42px;
  margin: 0;
  padding: 8px 18px 9px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #ffffff;
  color: var(--ink);
  font-size: clamp(18px, 2.7vw, 24px);
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 5px 0 #c9d2de;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -8px) scale(0.96);
  transition: opacity 140ms var(--ease);
}

.hint::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 16px;
  height: 16px;
  border-right: 3px solid var(--outline);
  border-bottom: 3px solid var(--outline);
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
}

.hint.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.hint.is-bouncing {
  animation: hintBounce 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.choices {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.choices.is-count {
  max-width: 760px;
  margin-top: clamp(18px, 3vh, 34px);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.choices.is-count .choice {
  min-height: 70px;
  border-radius: 26px;
  font-size: clamp(28px, 4.3vw, 40px);
}

.choice {
  min-height: 78px;
  border: 3px solid var(--outline);
  border-radius: 30px;
  background: var(--panel);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(32px, 4.8vw, 42px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: 0 6px 0 #c9d2de;
  transition: background 160ms var(--ease), border-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease), box-shadow 120ms var(--ease);
}

.choice:hover,
.choice:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.choice.is-selected {
  border-color: var(--accent);
  background: #fff3f3;
  box-shadow: 0 6px 0 #f4b9bf, inset 0 0 0 2px var(--accent);
}

.choice:active,
.control-button:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #c9d2de;
}

.choice.is-correct {
  border-color: var(--outline);
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 6px 0 #20904d;
}

.choice.is-wrong {
  border-color: var(--outline);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 6px 0 #b33a48;
}

.choice:disabled {
  cursor: default;
}

.control-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.controls {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
}

.controls.is-hidden {
  display: none;
}

.controls.is-single {
  grid-template-columns: 1fr;
}

.app.is-count .controls:not(.is-hidden) {
  margin-top: clamp(14px, 2.4vh, 28px);
}

.control-button {
  min-height: 60px;
  border: 3px solid var(--outline);
  border-radius: 20px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 #c9d2de;
  transition: background 160ms var(--ease), transform 120ms var(--ease), box-shadow 120ms var(--ease);
}

.control-button.secondary {
  background: #f7fbff;
  color: var(--ink);
}

.control-button.secondary:hover,
.control-button.secondary:focus-visible {
  background: #e7e7e7;
  outline: none;
}

.control-button.primary {
  background: #48c9c3;
  color: #ffffff;
  box-shadow: 0 6px 0 #15948e;
}

.control-button.primary:hover,
.control-button.primary:focus-visible {
  background: #35beb8;
  outline: none;
}

.success-effect {
  position: fixed;
  inset: 0;
  z-index: 20;
  border: 0;
  background: rgba(251, 251, 252, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  overflow: hidden;
  animation: effectFade 180ms var(--ease) both;
}

.success-effect[hidden] {
  display: none;
}

.success-badge {
  width: min(330px, 78vw);
  height: min(330px, 78vw);
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(40px, 8vw, 58px);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 18px 50px rgba(255, 98, 98, 0.36);
  animation: effectPop 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-effect small {
  padding: 8px 18px 9px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 5px 0 #c9d2de;
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 800;
  line-height: 1.2;
  position: relative;
  z-index: 2;
}

.confetti-piece {
  position: absolute;
  top: -28px;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 1.45);
  border-radius: 3px;
  background: var(--color);
  opacity: 0.95;
  pointer-events: none;
  animation: confettiDrop var(--fall) var(--delay) cubic-bezier(0.18, 0.72, 0.32, 1) forwards;
}

@keyframes effectFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes effectPop {
  0% {
    opacity: 0;
    transform: scale(0.58);
  }
  58% {
    opacity: 1;
    transform: scale(1.08);
  }
  78% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes rewardPop {
  0% {
    opacity: 0;
    transform: translateY(4px) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes hintBounce {
  0% {
    opacity: 0;
    transform: translate(-50%, -14px) scale(0.9);
  }
  58% {
    opacity: 1;
    transform: translate(-50%, 3px) scale(1.04);
  }
  78% {
    transform: translate(-50%, -2px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

@keyframes countCorrectPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }
  65% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes confettiDrop {
  0% {
    transform: translate3d(0, -8vh, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--drift), 112vh, 0) rotate(var(--spin));
  }
}

@media (max-width: 680px) {
  .app {
    padding: 24px 24px 34px;
    grid-template-rows: auto auto auto auto auto;
    gap: 14px;
  }

  .hint {
    top: 87px;
  }

  .count-timer {
    width: 117px;
    min-height: 164px;
    padding: 10px 7px;
    border-width: 3px;
    border-radius: 18px;
    gap: 6px;
  }

  .clock-face {
    width: 100px;
    height: 100px;
    border-width: 4px;
  }

  .clock-hand {
    width: 5px;
    height: 34px;
  }

  .count-time {
    font-size: 16px;
  }

  .count-progress {
    min-width: 78px;
    min-height: 48px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 18px;
  }

  .count-status {
    gap: 7px;
  }

  .count-limit {
    min-height: 48px;
    padding: 4px;
    border-radius: 16px;
  }

  .count-limit-button {
    min-width: 38px;
    min-height: 34px;
    border-radius: 12px;
    font-size: 16px;
  }

  .equation {
    margin-top: 34px;
    gap: 8px;
    font-size: clamp(50px, 14vw, 64px);
  }

  .eq-part {
    min-height: 86px;
  }

  .answer-box {
    min-width: 78px;
    padding: 0 8px;
  }

  .play {
    grid-template-columns: 1fr;
    gap: 8px;
    justify-items: center;
  }

  .count-game {
    min-height: 236px;
    margin-top: 8px;
  }

  .count-stage {
    gap: 10px;
  }

  .count-board {
    grid-template-columns: repeat(5, 44px) 32px;
    gap: 7px;
    padding: 12px;
    border-width: 3px;
  }

  .count-cell {
    width: 44px;
    height: 44px;
    border-width: 2px;
    border-radius: 10px;
  }

  .count-cell .bead {
    width: 32px;
    height: 32px;
  }

  .count-row-label {
    width: 32px;
    height: 44px;
    border-width: 2px;
    font-size: 17px;
    box-shadow: 0 3px 0 #c9d2de;
  }

  .count-result {
    padding: 22px 16px;
  }

  .count-result-stats {
    gap: 8px;
    font-size: 14px;
  }

  .count-result-stats strong {
    font-size: 18px;
  }

  .connector {
    min-height: 1em;
    font-size: 38px;
  }

  .bead-zone {
    width: 100%;
    height: 142px;
    min-height: 142px;
    padding: 10px;
    grid-template-columns: repeat(5, 30px);
    gap: 9px;
  }

  .bead {
    width: 30px;
    height: 30px;
  }

  .bead-chain {
    --bead-size: 30px;
    gap: 7px;
    padding: 8px;
    border-width: 3px;
    border-radius: 22px;
  }

  .bead-group-label {
    min-width: 52px;
    min-height: 36px;
    font-size: 30px;
  }

  .bead-zone.is-empty {
    height: 142px;
    min-height: 142px;
  }

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

  .choices.is-count {
    gap: 8px;
    margin-top: 16px;
  }

  .choices.is-count .choice {
    min-height: 58px;
    border-radius: 22px;
    font-size: clamp(25px, 8vw, 34px);
  }

  .choice {
    min-height: 78px;
    font-size: clamp(30px, 10vw, 42px);
  }

  .controls {
    grid-template-columns: 0.72fr 1fr;
  }

  .control-button {
    min-height: 60px;
    padding: 0 18px;
    font-size: 20px;
  }
}

@media (max-width: 390px) {
  .app {
    padding-inline: 18px;
  }

  .equation {
    gap: 6px;
  }

  .bead-zone {
    height: 132px;
    min-height: 132px;
    grid-template-columns: repeat(5, 26px);
    gap: 8px;
  }

  .count-board {
    grid-template-columns: repeat(5, 37px) 28px;
    gap: 6px;
    padding: 10px;
  }

  .count-cell {
    width: 37px;
    height: 37px;
    border-radius: 9px;
  }

  .count-cell .bead {
    width: 28px;
    height: 28px;
  }

  .count-row-label {
    width: 28px;
    height: 37px;
    font-size: 15px;
  }

  .count-stage {
    gap: 8px;
  }

  .count-timer {
    width: 82px;
    min-height: 120px;
    gap: 5px;
  }

  .clock-face {
    width: 72px;
    height: 72px;
  }

  .clock-hand {
    height: 25px;
  }

  .count-time {
    font-size: 14px;
  }

  .count-limit-button {
    min-width: 31px;
    min-height: 30px;
    font-size: 14px;
  }

  .count-progress {
    min-width: 68px;
    min-height: 42px;
    font-size: 16px;
  }

  .choices.is-count {
    gap: 6px;
  }

  .choices.is-count .choice {
    min-height: 54px;
    border-width: 2px;
    border-radius: 19px;
    font-size: 24px;
  }

  .count-result-stats {
    grid-template-columns: 1fr;
  }

  .bead-zone.is-empty {
    height: 132px;
    min-height: 132px;
  }

  .bead {
    width: 26px;
    height: 26px;
  }

  .bead-chain {
    --bead-size: 26px;
    gap: 6px;
    padding: 7px;
    border-radius: 20px;
  }
}

.app:not(.is-count) {
  --composition-y: clamp(0px, calc((100dvh - 640px) / 2), 128px);
  width: 1024px;
  max-width: none;
  padding: 24px 72px 34px;
  gap: 18px;
}

.app:not(.is-count) > .topbar,
.app:not(.is-count) > .equation,
.app:not(.is-count) > .play,
.app:not(.is-count) > .choices {
  transform: translateY(var(--composition-y));
}

.app:not(.is-count) .topbar {
  height: 54px;
  justify-content: flex-start;
}

.app:not(.is-count) .streak {
  flex: 0 0 430px;
  width: 430px;
  max-width: 430px;
  max-height: 54px;
  min-width: 148px;
  height: 54px;
  min-height: 54px;
  margin-left: 24px;
  padding: 7px 10px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  font-size: 24px;
}

.app:not(.is-count) .hint {
  left: auto;
  right: 92px;
  top: 3px;
  z-index: 41;
  width: max-content;
  max-width: none;
  min-height: 42px;
  padding: 8px 18px 9px;
  border-radius: 999px;
  font-size: 24px;
}

.app:not(.is-count) .hint.is-visible {
  transform: translateY(var(--composition-y));
}

.app:not(.is-count) .hint.is-bouncing {
  animation: none;
  opacity: 1;
  transform: translateY(var(--composition-y));
}

.app:not(.is-count) .equation {
  position: relative;
  z-index: 3;
  grid-template-columns: minmax(1.8ch, auto) 0.62ch minmax(1ch, auto) 0.72ch minmax(1.3ch, auto);
  justify-content: start;
  column-gap: 16px;
  width: 860px;
  margin: 44px auto 0;
  padding: 18px 330px 18px 58px;
  font-size: 88px;
}

.app:not(.is-count) .eq-part {
  min-height: 96px;
}

.app:not(.is-count) .answer-box {
  min-width: 98px;
  margin-left: 18px;
  padding: 0 12px;
}

.app:not(.is-count) .play {
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  gap: 34px;
  width: 880px;
  margin: 20px auto;
}

.app:not(.is-count) .bead-zone {
  width: auto;
  height: 216px;
  min-height: 216px;
  padding: 12px;
  grid-template-columns: repeat(5, 38px);
  gap: 13px;
}

.app:not(.is-count) .bead {
  width: 38px;
  height: 38px;
}

.app:not(.is-count) .bead-chain {
  --bead-size: 38px;
  gap: 8px;
  padding: 9px;
  border-width: 4px;
  border-radius: 26px;
}

.app:not(.is-count) .bead-group-label {
  min-width: 58px;
  min-height: 42px;
  font-size: 34px;
}

.app:not(.is-count) .connector {
  font-size: 56px;
}

.app:not(.is-count) .choices {
  gap: 14px;
}

.app:not(.is-count) .choice {
  min-height: 78px;
  font-size: 42px;
}

.cat-layer {
  position: absolute;
  right: 122px;
  top: 33px;
  z-index: 40;
  width: 320px;
  height: 320px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transform: translateY(var(--composition-y));
}

.cat-layer[hidden] {
  display: none;
}

.cat-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  filter: drop-shadow(0 9px 0 rgba(30, 48, 79, 0.16));
  pointer-events: none;
  backface-visibility: hidden;
  transform-origin: 50% 100%;
  transition: none;
}

.cat-layer.is-popping .cat-face {
  animation: catPop 360ms cubic-bezier(0.22, 1.45, 0.36, 1);
}

.cat-touch-face {
  opacity: 0;
  transform: none;
}

.cat-layer.is-touching .cat-main-face {
  opacity: 0;
  transform: none;
}

.cat-layer.is-touching .cat-touch-face {
  opacity: 1;
  transform: none;
}

@keyframes catPop {
  0% {
    transform: scaleX(1) scaleY(1);
  }

  20% {
    transform: scaleX(1.025) scaleY(0.97);
  }

  48% {
    transform: scaleX(0.975) scaleY(1.07);
  }

  74% {
    transform: scaleX(1.012) scaleY(0.99);
  }

  100% {
    transform: scaleX(1) scaleY(1);
  }
}

.level-control select,
.streak::before,
.count-timer,
.count-result-title,
.count-result-stats,
.bead-zone.is-empty,
.hint,
.control-button,
.success-badge,
.success-effect small {
  font-family: var(--font-text);
  font-weight: var(--weight-text);
}

.eq-number,
.eq-symbol,
.answer-box,
.choice,
.count-limit-button,
.count-progress,
.count-time,
.count-row-label,
.count-result-score,
.count-result-stats strong,
.connector,
.bead-group-label {
  font-family: var(--font-number);
  font-weight: var(--weight-number);
}
