:root {
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: #17324d;
  background: #e9eff6;
  font-synthesis: none;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background:
    radial-gradient(ellipse at 25% 20%, #e4f4fa, transparent 55%),
    radial-gradient(ellipse at 80% 80%, #e8e3f5, transparent 55%), #edf1f7;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
  border: 0;
  min-height: 48px;
  border-radius: 16px;
  color: inherit;
  font-weight: 700;
  transition:
    transform 0.14s,
    background 0.14s;
}
button:active {
  transform: scale(0.97);
}
button:disabled {
  cursor: default;
  opacity: 0.55;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #735adc;
  outline-offset: 3px;
}
button.primary {
  background: #286ce8;
  color: white;
  box-shadow: 0 6px 16px #286ce823;
  min-height: 58px;
  font-size: 18px;
  padding: 14px 20px;
  width: 100%;
}
button.secondary {
  background: #edf3fa;
  padding: 12px 16px;
  min-height: 52px;
}
button.text-button {
  background: transparent;
  text-decoration: underline;
  padding: 10px;
  font-size: 16px;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 32px;
  line-height: 1.3;
  letter-spacing: -1.6px;
}
h2 {
  font-size: 25px;
  line-height: 1.4;
  letter-spacing: -0.8px;
}
p {
  line-height: 1.65;
}
#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  min-height: 580px;
  margin: auto;
  position: relative;
  overflow: hidden;
  background: #f7fbff;
  box-shadow: 0 10px 90px #324a6520;
}
.home,
.name-view,
.complete-view {
  height: 100%;
  padding: calc(28px + env(safe-area-inset-top)) 26px
    calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  color: #536b86;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-dot {
  width: 24px;
  height: 24px;
  background: #286ce8;
  border-radius: 7px;
  color: white;
  display: grid;
  place-items: center;
  font-size: 16px;
}
.pill {
  border: 1px solid #dce7f2;
  border-radius: 30px;
  padding: 7px 12px;
  background: #fff;
  font-size: 14px;
}
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 260px;
}
.eyebrow {
  font-size: 14px;
  letter-spacing: 1.6px;
  font-weight: 800;
  color: #456586;
}
.hero .eyebrow {
  margin: 22px 0 12px;
  color: #326dc1;
}
.hero p {
  font-size: 18px;
  margin-top: 15px;
  color: #4d6680;
}
.tile-art {
  position: relative;
  width: 230px;
  height: 180px;
  margin-bottom: 8px;
}
.art-tile {
  position: absolute;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 23px;
  font-size: 37px;
  font-weight: 800;
  border: 2px solid #ffffffb0;
  box-shadow: 0 12px 20px #507bad1c;
  animation: arrive 0.5s both;
}
.art-tile:nth-child(1) {
  left: 17px;
  top: 26px;
  background: #b2dfff;
  transform: rotate(-12deg);
}
.art-tile:nth-child(2) {
  left: 95px;
  top: 3px;
  background: #c7b9f0;
  transform: rotate(7deg);
  animation-delay: 0.08s;
}
.art-tile:nth-child(3) {
  left: 143px;
  top: 82px;
  background: #afe8d3;
  transform: rotate(12deg);
  animation-delay: 0.16s;
}
.art-tile:nth-child(4) {
  left: 54px;
  top: 105px;
  background: #ffe5a2;
  transform: rotate(-5deg);
  animation-delay: 0.24s;
}
.spark {
  position: absolute;
  color: #7b6acb;
  font-size: 25px;
  top: 21px;
  right: 2px;
}
.home-actions {
  display: grid;
  gap: 12px;
}
.create-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: #fff;
  border: 1.5px solid #d6def0;
  padding: 17px 20px;
  font-size: 18px;
  min-height: 74px;
}
.create-button small {
  font-size: 14px;
  display: block;
  color: #526b85;
  font-weight: 500;
  margin-top: 4px;
}
.home-bottom {
  text-align: center;
  margin-top: 19px;
  color: #526b85;
  font-size: 14px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  min-height: 60px;
  gap: 8px;
}
.icon-button {
  width: 48px;
  min-width: 48px;
  background: #ffffffa6;
  font-size: 26px;
  border: 1px solid #dce7f2;
}
.level-label {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 1.2px;
}
.game-view {
  padding: calc(8px + env(safe-area-inset-top)) 18px
    calc(12px + env(safe-area-inset-bottom));
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  gap: 8px;
}
.target-block {
  text-align: center;
  flex: none;
}
.next-number {
  display: block;
  font-size: 68px;
  line-height: 1.05;
  letter-spacing: -3px;
  color: #2469d4;
}
.metrics {
  display: flex;
  justify-content: center;
  gap: 28px;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 9px;
}
.goal {
  font-size: 14px;
  color: #435f7a;
  margin-top: 6px;
}
.number-board {
  --tile: #a9dcff;
  --ink: #17324d;
  --board: #e1edf7;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(48px, 1fr));
  gap: 9px;
  padding: 11px;
  background: var(--board);
  border-radius: 23px;
  flex: 1;
  min-height: 296px;
  max-height: 430px;
}
.number-tile {
  background: var(--tile);
  color: var(--ink);
  font-size: clamp(28px, 7vw, 36px);
  font-weight: inherit;
  border-radius: 16px;
  box-shadow:
    0 4px 0 #17324d24,
    inset 0 1px 0 #ffffffa0;
  min-width: 0;
  padding: 0;
  line-height: 1;
}
.number-board[data-shape="square"] .number-tile {
  border-radius: 5px;
}
.number-board[data-shape="circle"] .number-tile {
  border-radius: 50%;
  aspect-ratio: 1;
  align-self: center;
  justify-self: center;
  width: min(100%, var(--circle-size, 64px));
}
.number-board[data-size="small"] .number-tile {
  font-size: 28px;
}
.number-board[data-size="normal"] .number-tile {
  font-size: 32px;
}
.number-board[data-size="huge"] .number-tile {
  font-size: clamp(32px, 9vw, 44px);
}
.number-board[data-gap="wide"] {
  gap: 12px;
}
.number-board[data-gap="narrow"] {
  gap: 5px;
}
.number-board[data-depth="false"] .number-tile {
  box-shadow: none;
}
.number-tile.done {
  opacity: 1;
  background: #ffffff80;
  color: #536e86;
  box-shadow: none;
  transform: scale(0.93);
}
.number-tile.done:after {
  content: " ✓";
  font-size: 12px;
}
.number-tile.hint {
  outline: 4px solid #7a51c2;
  outline-offset: -4px;
  filter: brightness(1.08);
}
.number-tile.wrong {
  animation: shake 0.2s;
  border: 3px solid #b64255;
}
.game-footer {
  flex: none;
}
.progress-label {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.track {
  height: 6px;
  background: #d8e3f0;
  border-radius: 12px;
  overflow: hidden;
}
.fill {
  height: 100%;
  background: linear-gradient(90deg, #359cec, #8980e6);
  transition: width 0.16s;
}
.two-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.praise {
  min-height: 18px;
  font-size: 14px;
  text-align: center;
  color: #4b4393;
  font-weight: 700;
}
.game-overlay {
  position: absolute;
  inset: 0;
  padding: calc(30px + env(safe-area-inset-top)) 26px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  align-items: stretch;
  text-align: center;
  background: #f6fbfffa;
  z-index: 5;
  overflow: auto;
}
.game-overlay[hidden],
[hidden] {
  display: none !important;
}
.celebration-icon {
  font-size: 68px;
  color: #d29b23;
  line-height: 1.1;
}
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  text-align: left;
  padding: 20px;
  border: 1px solid #dce7f2;
  border-radius: 20px;
  background: white;
  margin: 0;
}
.stats dt {
  font-size: 15px;
  color: #47617c;
}
.stats dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
  font-size: 17px;
}
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
}
.confetti i {
  position: absolute;
  left: var(--x);
  top: -20px;
  width: 9px;
  height: 15px;
  border-radius: 2px;
  animation: fall 1.9s var(--d) both;
}
.standalone-welcome {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  text-align: center;
  padding: 24px;
}
.brand-mark {
  font-size: 60px;
  color: #286ce8;
  letter-spacing: 10px;
}
.name-view {
  gap: 24px;
}
.name-view .intro {
  margin-top: auto;
}
.name-view form {
  display: grid;
  gap: 16px;
  margin-bottom: auto;
}
.name-view p {
  font-size: 18px;
  margin-top: 12px;
  color: #49617b;
}
input,
textarea,
select {
  border: 1.5px solid #bdcfe1;
  border-radius: 14px;
  background: white;
  color: #17324d;
  padding: 14px;
  min-height: 54px;
  width: 100%;
  font-size: 18px;
}
label {
  display: block;
  font-size: 16px;
  font-weight: 700;
}
.notice {
  font-size: 15px;
  color: #465f79;
}
.training-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top)) 16px env(safe-area-inset-bottom);
  background: #f6f9fe;
}
.training-heading {
  text-align: center;
  flex: 1;
}
.training-heading strong {
  display: block;
  font-size: 17px;
}
.training-heading span {
  font-size: 14px;
  color: #52708f;
}
.training-progress {
  display: flex;
  gap: 5px;
  margin: 8px 2px 16px;
}
.training-progress i {
  height: 4px;
  flex: 1;
  background: #dce6f3;
  border-radius: 5px;
}
.training-progress i.filled {
  background: #6b7fea;
}
.chat-log {
  overflow: auto;
  flex: 1;
  min-height: 100px;
  scroll-behavior: smooth;
  padding: 4px 2px 16px;
  overscroll-behavior: contain;
}
.message {
  margin: 0 0 15px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.avatar {
  background: #e3eafa;
  color: #4366bf;
  min-width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-weight: 800;
}
.bubble {
  background: white;
  border: 1px solid #dfe7f2;
  border-radius: 0 16px 16px;
  padding: 14px;
  line-height: 1.65;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.message.user {
  justify-content: flex-end;
}
.user .bubble {
  background: #286ce8;
  color: white;
  border: 0;
  border-radius: 16px 0 16px 16px;
  max-width: 90%;
}
.code-card {
  background: #172b43;
  color: #e0edfa;
  border-radius: 16px;
  padding: 14px;
  margin: 12px 0;
}
.code-top {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 10px;
}
.code-card pre {
  height: 145px;
  overflow: auto;
  font:
    13px/1.7 Consolas,
    monospace;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
  scrollbar-width: thin;
}
.code-line:nth-child(3n + 1) {
  color: #9edccc;
}
.code-line:nth-child(3n + 2) {
  color: #c8bafa;
}
.code-line:nth-child(3n) {
  color: #f3d69e;
}
.code-card.running pre:after {
  content: "▎";
  color: #b8cbff;
  animation: cursor 0.8s 20;
}
.code-card .track {
  margin-top: 12px;
  background: #35485d;
}
.code-card .fill {
  transition: none;
}
.step-complete {
  background: #e8f6ef;
  border: 1px solid #c3e4d4;
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 14px;
  margin-top: 12px;
}
.step-complete p {
  font-size: 17px;
  font-weight: 700;
  color: #1f644b;
}
.composer {
  flex: none;
  background: #f6f9fe;
  padding: 12px 0 14px;
  border-top: 1px solid #dfe7f2;
}
.example-label {
  font-size: 14px;
  font-weight: 700;
  color: #43617d;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.example-label button {
  min-height: 40px;
  background: transparent;
  color: #2860b7;
  font-size: 15px;
}
.example-text {
  border: 1px dashed #becfe5;
  border-radius: 12px;
  background: #edf3fc;
  min-height: 48px;
  font-size: 15px;
  text-align: left;
  padding: 10px;
  margin: 6px 0 10px;
  width: 100%;
  font-weight: 500;
  line-height: 1.55;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-row textarea {
  resize: none;
  height: 72px;
  min-height: 58px;
  font-size: 17px;
}
.input-row .primary {
  width: 76px;
  flex: none;
  padding: 10px;
  font-size: 17px;
}
.stage-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.stage-nav button {
  font-size: 14px;
  min-height: 42px;
  flex: 1;
  background: #e7eef9;
}
.complete-view {
  gap: 15px;
  overflow: auto;
}
.complete-view .topbar {
  min-height: 48px;
}
.badge {
  align-self: center;
  background: #fff0bf;
  color: #745016;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 30px;
  font-weight: 800;
}
.complete-view h1 {
  text-align: center;
  font-size: 27px;
}
.complete-view p {
  text-align: center;
}
.mini-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px;
  border-radius: 18px;
  min-height: 176px;
  flex: none;
}
.mini-board span {
  display: grid;
  place-items: center;
  min-height: 30px;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 2px 0 #17324d20;
}
.summary-chips {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
}
.summary-chips span {
  padding: 7px 10px;
  background: white;
  border: 1px solid #dce7f2;
  border-radius: 30px;
}
.export-message {
  background: #e9f4ec;
  border-radius: 14px;
  padding: 12px;
  font-size: 16px;
  text-align: center;
}
.history-panel {
  display: grid;
  gap: 12px;
}
.stage-picker {
  background: #edf3fa;
  border: 0;
  min-height: 48px;
}
.toast {
  position: absolute;
  bottom: 18px;
  left: 18px;
  right: 18px;
  background: #17324d;
  color: #fff;
  border-radius: 14px;
  padding: 14px;
  z-index: 30;
  font-size: 16px;
}
.storage-warning {
  padding: 10px;
  background: #fff2ca;
  font-size: 14px;
  color: #684d1b;
}
.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: #17324d66;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 40;
}
.dialog-card {
  background: #fff;
  border-radius: 22px;
  padding: 24px;
  display: grid;
  gap: 18px;
  width: 100%;
}
.dialog-card h2 {
  font-size: 22px;
}
.dialog-card .two-actions {
  margin: 0;
}
.dialog-card button {
  font-size: 16px;
}
@keyframes arrive {
  from {
    opacity: 0;
    translate: 0 12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes shake {
  25% {
    translate: -3px;
  }
  75% {
    translate: 3px;
  }
}
@keyframes fall {
  to {
    transform: translateY(850px) rotate(var(--r));
    opacity: 0;
  }
}
@keyframes cursor {
  50% {
    opacity: 0;
  }
}
@media (min-width: 600px) {
  #app {
    height: min(900px, calc(100dvh - 48px));
    margin: 24px auto;
    border-radius: 32px;
    border: 1px solid #fff;
    min-height: 580px;
  }
}
@media (max-height: 740px) {
  .home {
    padding-top: 18px;
  }
  .tile-art {
    height: 145px;
    transform: scale(0.85);
    margin-bottom: -12px;
  }
  .hero .eyebrow {
    margin: 8px 0;
  }
  .hero h1 {
    font-size: 29px;
  }
  .hero p {
    margin-top: 10px;
  }
  .home-bottom {
    margin-top: 10px;
  }
  .game-view {
    gap: 5px;
    padding-top: 4px;
  }
  .topbar {
    min-height: 50px;
  }
  .next-number {
    font-size: 52px;
  }
  .metrics {
    margin-top: 3px;
  }
  .goal {
    margin-top: 3px;
  }
  .number-board {
    padding: 9px;
    gap: 7px;
    min-height: 290px;
  }
  .two-actions {
    margin-top: 8px;
  }
  .complete-view {
    padding-top: 12px;
    gap: 12px;
  }
  .mini-board {
    min-height: 155px;
  }
  .complete-view h1 {
    font-size: 24px;
  }
}
@media (max-height: 620px) {
  #app {
    overflow: auto;
  }
  .home {
    min-height: 580px;
  }
  .game-view {
    min-height: 580px;
  }
  .training-view {
    min-height: 0;
  }
  .training-view .composer {
    padding-top: 5px;
  }
  .example-text {
    max-height: 70px;
    overflow: auto;
  }
  .training-view .topbar {
    min-height: 48px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .confetti i {
    top: 20%;
    height: 12px;
  }
  .confetti {
    opacity: 0.6;
  }
}

button {
  color: #17324d;
}
.target-block {
  background: #ffffffb8;
  border-radius: 18px;
  padding: 6px;
  color: #17324d;
}
.game-footer {
  background: #ffffffb8;
  padding: 8px;
  border-radius: 18px;
  color: #17324d;
}
.praise {
  border-radius: 8px;
  background: #ffffffb8;
}
.number-board[data-level="4"],
.number-board[data-level="7"],
.number-board[data-level="8"] {
  background-image: linear-gradient(135deg, #ffffff40, transparent 60%);
}
.complete-view > .notice {
  color: inherit;
}
.game-view .game-overlay {
  color: #17324d;
}

.number-board[data-shape="circle"] .number-tile {
  height: 100%;
  width: auto;
  max-height: 70px;
  max-width: 100%;
  aspect-ratio: 1;
  min-width: 48px;
}
.praise:empty {
  background: transparent;
}
