:root {
  --bg: #fff6d8;
  --ink: #1b2a4a;
  --panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Comic Sans MS", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 20% 20%, #ffe08a 0 14%, transparent 15%),
    radial-gradient(circle at 80% 15%, #8ad6ff 0 12%, transparent 13%),
    radial-gradient(circle at 10% 85%, #ff9dc6 0 12%, transparent 13%),
    radial-gradient(circle at 90% 85%, #b7f07e 0 14%, transparent 15%),
    var(--bg);
  color: var(--ink);
  transition: background 0.2s ease;
}

body.wrong {
  background: #ff6f6f;
}

body.right {
  background: #7ce0a7;
}

.shell {
  width: min(96vw, 820px);
  background: var(--panel);
  border-radius: 30px;
  border: 5px solid #ffe08a;
  padding: 1.2rem;
  box-shadow: 0 12px 28px rgba(40, 61, 104, 0.2);
}

h1,
h2 {
  margin: 0;
  text-align: center;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
}

h2 {
  font-size: clamp(1.3rem, 4vw, 2rem);
}

.subtitle {
  margin: 0.6rem 0 1rem;
  text-align: center;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.mission-subtitle {
  margin-bottom: 0.2rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.empty-state {
  margin: 0.2rem 0 0;
  text-align: center;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 700;
}

.admin-entry {
  margin-top: 0.4rem;
  display: grid;
  justify-items: center;
}

.mini-link {
  color: #23385f;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 2px dashed #89c8ff;
}

.app-card {
  border: 0;
  border-radius: 22px;
  background: #f7fcff;
  border: 3px dashed #89c8ff;
  padding: 1rem;
  text-align: left;
  display: grid;
  gap: 0.35rem;
  cursor: pointer;
  color: #10203d;
  text-decoration: none;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.app-card .emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.app-card strong {
  font-size: 1.2rem;
}

.app-card span {
  font-size: 1rem;
}

.card-badge {
  justify-self: start;
  border-radius: 999px;
  background: #dce9ff;
  color: #17386d;
  padding: 0.18rem 0.6rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.app-screen {
  display: grid;
  gap: 0.8rem;
}

.login-box {
  display: grid;
  gap: 0.7rem;
  max-width: 420px;
  margin: 0.8rem auto 0;
}

.login-box input,
.admin-field input,
.admin-field select {
  min-height: 48px;
  border: 3px dashed #89c8ff;
  border-radius: 14px;
  padding: 0 0.8rem;
  font-size: 1rem;
  font-family: inherit;
  background: #f7fcff;
  color: #10203d;
}

.topbar {
  display: grid;
  gap: 0.6rem;
}

.back-btn {
  justify-self: start;
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 0.9rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: #ffe08a;
  color: #23385f;
}

.progress {
  position: relative;
  height: 62px;
  padding: 0 40px 0 12px;
}

.progress-track {
  height: 38px;
  border-radius: 999px;
  border: 3px solid #8cc4ff;
  background:
    repeating-linear-gradient(
      90deg,
      #eef7ff 0,
      #eef7ff 16px,
      #d9ecff 16px,
      #d9ecff 20px
    );
}

.animal {
  position: absolute;
  top: 14px;
  left: 12px;
  font-size: 2rem;
  line-height: 1;
  transform: translateX(0);
  transition: transform 0.25s ease;
}

.goal {
  position: absolute;
  right: 6px;
  top: 12px;
  font-size: 2rem;
}

.word-panel {
  min-height: 130px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  border: 4px dashed #89c8ff;
  background: #f7fcff;
}

#words-word,
#sums-problem,
#compare-prompt,
#table-1-problem,
#table-2-problem,
#table-3-problem,
#mix-problem,
#reading-words-upper-target,
#reading-words-lower-target,
#reading-qu-ch-target {
  margin: 0;
  font-size: clamp(2.3rem, 8vw, 4rem);
  font-weight: 700;
  text-align: center;
}

#reading-phrases-upper-target,
#reading-phrases-lower-target {
  margin: 0;
  font-size: clamp(1.9rem, 5.8vw, 3rem);
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}

#articles-word {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  font-weight: 700;
  text-transform: lowercase;
}

.syllables-target {
  margin: 0;
  font-size: clamp(3rem, 11vw, 4.8rem);
  font-weight: 700;
  text-transform: lowercase;
  line-height: 1;
}

.syllables-prompt {
  margin: 0.45rem 0 0;
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  font-weight: 700;
  text-align: center;
}

#column-hint {
  margin: 0.8rem 0 0;
  text-align: center;
  font-size: clamp(1rem, 2.8vw, 1.3rem);
  font-weight: 700;
}

#words-word {
  text-transform: lowercase;
}

#reading-words-upper-target {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#reading-words-lower-target {
  text-transform: lowercase;
}

#reading-qu-ch-target {
  text-transform: lowercase;
}

#reading-phrases-upper-target {
  text-transform: uppercase;
}

#reading-phrases-lower-target {
  text-transform: lowercase;
}

.column-sum {
  width: min(320px, 94%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  gap: 0.35rem 0.45rem;
  align-items: end;
  position: relative;
}

.column-empty {
  min-height: 1px;
}

.column-digit {
  text-align: center;
  font-size: clamp(2.5rem, 9vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
}

.column-plus {
  text-align: center;
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
}

.column-line {
  border-top: 4px solid #1b2a4a;
  margin-top: 0.1rem;
}

.drop-slot {
  width: 100%;
  min-height: 68px;
  border: 3px solid #8cc4ff;
  border-radius: 14px;
  background: #fff;
  color: #10203d;
  text-align: center;
  font-size: clamp(2rem, 7vw, 2.7rem);
  font-weight: 700;
  display: grid;
  place-items: center;
  user-select: none;
}

.drop-slot.is-locked {
  background: #e9edf4;
  border-color: #b3bdcb;
  color: #7e8aa0;
}

.drop-slot.is-filled {
  background: #eaf7ff;
}

.carry-slot {
  min-height: 40px;
  max-width: 58px;
  justify-self: center;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  border-width: 2px;
  border-style: dashed;
}

.dot-slot {
  max-width: 40px;
  min-height: 40px;
  border-radius: 999px;
  font-size: clamp(1.5rem, 4.5vw, 1.9rem);
}

#column-carry-sub-borrow-one {
  position: absolute;
  top: 6px;
  left: calc(67% - 14px);
  transform: translateX(-50%);
  z-index: 2;
}

#column-carry-sub-borrow-dot {
  position: absolute;
  top: 72px;
  left: calc(31% - 31px);
  transform: translateX(-50%);
  z-index: 2;
}

.digit-bank {
  margin: 0.7rem auto 0;
  width: min(360px, 98%);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
}

.drag-digit {
  min-height: 56px;
  border: 0;
  border-radius: 14px;
  font-size: clamp(1.6rem, 5.2vw, 2rem);
  font-weight: 700;
  color: #10203d;
  cursor: grab;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
}

.drag-digit:active {
  cursor: grabbing;
  transform: translateY(2px);
}

.drag-digit:nth-child(1) { background: #ffcf66; }
.drag-digit:nth-child(2) { background: #8ad6ff; }
.drag-digit:nth-child(3) { background: #ff9dc6; }
.drag-digit:nth-child(4) { background: #b7f07e; }
.drag-digit:nth-child(5) { background: #ffb97a; }
.drag-digit:nth-child(6) { background: #b2b2ff; }
.drag-digit:nth-child(7) { background: #ffd7a3; }
.drag-digit:nth-child(8) { background: #8de4db; }
.drag-digit:nth-child(9) { background: #f5a6ff; }
.drag-digit:nth-child(10) { background: #9fe29f; }

.drag-digit.is-selected {
  outline: 4px solid #1b2a4a;
  outline-offset: 1px;
}

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

.game-area {
  position: relative;
}

.numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  min-height: 176px;
}

.num-btn {
  min-height: 84px;
  border: 0;
  border-radius: 20px;
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 700;
  color: #10203d;
  cursor: pointer;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.15);
}

.num-btn:active {
  transform: translateY(2px);
}

.article-groups {
  display: grid;
  gap: 0.75rem;
}

.article-group {
  border-radius: 20px;
  border: 3px dashed #89c8ff;
  background: #f7fcff;
  padding: 0.65rem;
}

.article-group-title {
  margin: 0 0 0.45rem;
  text-align: center;
  font-size: clamp(1.1rem, 3.2vw, 1.35rem);
  font-weight: 700;
}

.article-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.article-btn {
  min-height: 72px;
  font-size: clamp(1.2rem, 3.7vw, 1.6rem);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.3rem;
}

.article-icon {
  font-size: clamp(2rem, 6vw, 2.8rem);
  line-height: 1;
}

.article-label {
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  font-weight: 700;
  line-height: 1.1;
}

.article-btn.is-selected {
  outline: 4px solid #1b2a4a;
  outline-offset: 1px;
}

.syllable-word-btn {
  min-height: 78px;
  font-size: clamp(1.4rem, 4.6vw, 2rem);
  text-transform: lowercase;
}

.reading-controls {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: auto minmax(180px, 360px);
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
}

.reading-controls label {
  font-size: clamp(1rem, 2.9vw, 1.2rem);
  font-weight: 700;
}

.reading-controls select {
  min-height: 46px;
  border-radius: 12px;
  border: 3px solid #8cc4ff;
  background: #f7fcff;
  color: #10203d;
  font-size: clamp(1rem, 2.9vw, 1.15rem);
  font-weight: 700;
  padding: 0.2rem 0.55rem;
}

.compare-options {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.times2-hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.times2-chip {
  margin: 0;
  border-radius: 14px;
  border: 3px dashed #89c8ff;
  background: #f7fcff;
  color: #10203d;
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 700;
  padding: 0.2rem 0.4rem;
}

.times2-game {
  width: 100%;
  min-height: 300px;
  border-radius: 18px;
  border: 3px solid #8cc4ff;
  background: #eef7ff;
  overflow: hidden;
}

.times2-game canvas {
  display: block;
}

.times2-status {
  margin: 0.75rem 0 0;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 700;
  text-align: center;
}

.num-btn:nth-child(1) { background: #ffcf66; }
.num-btn:nth-child(2) { background: #8ad6ff; }
.num-btn:nth-child(3) { background: #ff9dc6; }
.num-btn:nth-child(4) { background: #b7f07e; }
.num-btn:nth-child(5) { background: #ffb97a; }
.num-btn:nth-child(6) { background: #b2b2ff; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 24px;
  font-size: clamp(4rem, 18vw, 9rem);
  font-weight: 700;
  pointer-events: none;
}

.overlay.ok {
  background: rgba(45, 187, 110, 0.35);
  color: #0e6f3d;
}

.overlay.error {
  background: rgba(235, 66, 66, 0.35);
  color: #9e1010;
}

.actions {
  margin-top: 0.2rem;
}

.main-btn {
  width: 100%;
  min-height: 74px;
  border: 0;
  border-radius: 18px;
  font-size: clamp(1.4rem, 4.8vw, 2rem);
  font-weight: 700;
  background: #4c8cff;
  color: #fff;
  cursor: pointer;
}

.admin-login-btn,
.admin-action-btn {
  min-height: 58px;
  font-size: 1.1rem;
}

.admin-toolbar {
  display: grid;
  gap: 0.7rem;
}

.admin-subtitle {
  margin-bottom: 0;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.admin-status,
.admin-error {
  min-height: 1.3rem;
  margin: 0;
  text-align: center;
  font-weight: 700;
}

.admin-error {
  color: #aa1d1d;
}

.admin-status {
  color: #1f5d2e;
}

.admin-list {
  display: grid;
  gap: 0.8rem;
}

.admin-card {
  border-radius: 22px;
  border: 3px dashed #89c8ff;
  background: #f7fcff;
  padding: 0.9rem;
  display: grid;
  gap: 0.7rem;
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: start;
}

.admin-card-title,
.admin-card-type,
.admin-card-desc {
  margin: 0;
}

.admin-card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.admin-card-type {
  font-size: 0.95rem;
  font-weight: 700;
  color: #395a90;
}

.admin-card-desc {
  font-size: 0.98rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 180px;
  gap: 0.8rem;
}

.admin-field {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
}

.admin-switch {
  align-content: center;
}

.admin-switch input {
  min-height: auto;
  width: 24px;
  height: 24px;
  padding: 0;
}

.hidden {
  display: none !important;
}

@media (min-width: 980px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .progress {
    height: 56px;
  }

  .goal,
  .animal {
    font-size: 1.8rem;
  }

  .numbers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .num-btn {
    min-height: 76px;
  }

  .drop-slot {
    min-height: 60px;
  }

  .carry-slot {
    min-height: 34px;
    max-width: 46px;
    font-size: clamp(1.05rem, 3.8vw, 1.35rem);
  }

  .dot-slot {
    min-height: 30px;
    max-width: 30px;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
  }

  #column-carry-sub-borrow-one {
    top: 8px;
    left: calc(67% - 10px);
  }

  #column-carry-sub-borrow-dot {
    top: 66px;
    left: calc(31% - 19px);
  }

  .drag-digit {
    min-height: 52px;
  }

  .times2-hud {
    grid-template-columns: 1fr;
  }

  .times2-game {
    min-height: 280px;
  }

  .reading-controls {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .reading-controls select {
    width: min(320px, 100%);
  }

  .admin-actions,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-card-head {
    display: grid;
  }
}
