@font-face {
  font-family: 'Dudadak Hand';
  src: url(/fonts/dudadak-hand.woff2) format('woff2');
  font-display: swap;
}
:root {
  --paper: #f1e6cc;
  --paper2: #e3d3b0;
  --ink: #1f1b16;
  --soft: #5a4f42;
  --tomato: #d63a22;
  --tomato-ink: #b02e19;
  --teal: #0f6a64;
  --mustard: #e3a41d;
  --cream: #fff8e6;
  --font: 'Dudadak Hand', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100svh;
  max-width: 760px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom)
    max(10px, env(safe-area-inset-left));
  background-image: radial-gradient(rgba(31, 27, 22, 0.05) 1px, transparent 1.2px);
  background-size: 7px 7px;
  overscroll-behavior: none;
}
button,
input {
  font: inherit;
  color: inherit;
}
a {
  color: var(--teal);
}
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
/* the always-focused typing field: on screen (top, so browsers never scroll to it), invisible, 16px so iOS doesn't zoom */
.typer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  font-size: 16px;
  border: 0;
  padding: 0;
  caret-color: transparent;
  z-index: -1;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 2px;
}
.brand {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--tomato-ink);
  transform: rotate(-2deg);
  text-shadow: 2px 2px 0 var(--ink);
}
.brand .en {
  font-size: 16px;
  margin-left: 6px;
  color: var(--ink);
  text-shadow: none;
  letter-spacing: 0;
}
html[lang='en'] .brand .ko {
  font-size: 20px;
}
html[lang='en'] .brand .en {
  font-size: 30px;
  color: var(--tomato-ink);
  text-shadow: 2px 2px 0 var(--ink);
}
.tools {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tagline {
  margin: 2px 0 8px;
  color: var(--soft);
  font-size: 15px;
}
.wallet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  padding: 2px 8px 2px 3px;
  border: 2px solid var(--ink);
  background: var(--cream);
}
.wallet i {
  font-style: normal;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  background: var(--teal);
  color: var(--cream);
  font-size: 14px;
  transform: rotate(-6deg);
}

.ink {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 17px;
  min-height: 44px;
  transition:
    transform 0.06s,
    box-shadow 0.06s;
}
.ink:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.ink.round {
  width: 44px;
  padding: 0;
  font-size: 20px;
}
.ink.lang {
  min-width: 44px;
  padding: 0 8px;
}
.ink.primary {
  background: var(--tomato);
  color: #fff;
  border-color: var(--ink);
}
.ink.small {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 15px;
}
.ink.wide {
  width: 100%;
  margin-top: 10px;
}
.ink:disabled {
  opacity: 0.5;
  cursor: default;
}

.stage {
  position: relative;
  margin: 0;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
}
#game {
  display: block;
  width: 100%;
  height: clamp(170px, 46vw, 330px);
  touch-action: manipulation;
}
body[data-screen='play'] #game {
  height: clamp(190px, 52vw, 360px);
}
.tapme {
  position: absolute;
  inset: auto 0 8px;
  margin: 0;
  text-align: center;
  color: var(--soft);
  font-size: 15px;
  pointer-events: none;
}

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 6px;
  font-size: 15px;
  flex-wrap: nowrap;
}
.hud .stat {
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 52px;
}
.hud small,
.stat small {
  color: var(--soft);
  font-size: 12px;
}
.hud b {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.hearts {
  font-size: 20px;
  color: var(--tomato);
  letter-spacing: 1px;
  min-width: 60px;
}
.boost {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.boost .bar {
  display: block;
  height: 14px;
  border: 2.5px solid var(--ink);
  background: var(--cream);
}
.boost .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--tomato) 0 6px, var(--mustard) 6px 12px);
  transition: width 0.15s;
}
body.dashing .boost .bar i {
  animation: zip 0.3s linear infinite;
}
@keyframes zip {
  to {
    background-position: 17px 0;
  }
}
#btn-quit {
  margin-left: auto;
}

.racebar {
  display: grid;
  gap: 3px;
  margin: 0 0 6px;
}
.racebar .lane {
  display: grid;
  grid-template-columns: 70px 1fr 40px;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.racebar .lane .nick {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.racebar .track {
  position: relative;
  height: 18px;
  border-bottom: 2px dashed var(--soft);
}
.racebar .track canvas {
  position: absolute;
  bottom: -2px;
  transform: translateX(-50%);
  transition: left 0.5s linear;
}
.racebar .lane.you .nick {
  color: var(--tomato-ink);
  font-weight: 700;
}

.wordline {
  text-align: center;
  padding: 8px 4px 4px;
  min-height: 92px;
}
.target {
  margin: 0;
  font-size: 34px;
  letter-spacing: 1px;
  min-height: 44px;
}
.target .got {
  color: var(--teal);
}
.target .bad {
  color: var(--tomato-ink);
  text-decoration: underline wavy;
}
.echo {
  margin: 2px 0 0;
  min-height: 22px;
  color: var(--soft);
  font-size: 18px;
}
.echo.miss {
  color: var(--tomato-ink);
}
.sentence {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--soft);
}
.sentence mark {
  background: var(--mustard);
  color: var(--ink);
  padding: 0 2px;
}

.panel {
  padding: 10px 0 24px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row h2 {
  margin: 0;
  font-size: 24px;
  flex: 1;
}
h3 {
  margin: 18px 0 6px;
  font-size: 19px;
}
.muted {
  color: var(--soft);
}
.small {
  font-size: 14px;
}
.langpick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.langpick p {
  margin: 0;
  width: 100%;
  font-size: 17px;
}
.chip[aria-pressed='true'] {
  background: var(--teal);
  color: var(--cream);
}
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}
.mode {
  text-align: left;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-left: 10px solid var(--tomato);
  padding: 12px 12px 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 92px;
  position: relative;
  box-shadow: 3px 3px 0 var(--ink);
}
.mode:nth-child(2) {
  border-left-color: var(--teal);
  transform: rotate(0.6deg);
}
.mode:nth-child(3) {
  border-left-color: var(--mustard);
  transform: rotate(-0.5deg);
}
.mode:nth-child(4) {
  border-left-color: var(--ink);
}
.mode::after {
  content: '';
  position: absolute;
  left: -6px;
  top: 6px;
  bottom: 6px;
  border-left: 2px dotted var(--cream);
}
.mode b {
  font-size: 21px;
}
.mode small {
  color: var(--soft);
  font-size: 14px;
  line-height: 1.25;
}
.mode:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.foot {
  margin-top: 18px;
  font-size: 14px;
  color: var(--soft);
  text-align: center;
}

.grid {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 8px;
}
.grid button {
  width: 100%;
  aspect-ratio: 1;
  background: var(--cream);
  border: 2px solid var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  padding: 0;
}
.grid button small {
  font-size: 11px;
  color: var(--mustard);
  letter-spacing: -1px;
  -webkit-text-stroke: 0.3px var(--ink);
}
.grid button.boss {
  background: var(--paper2);
  border-width: 3px;
}
.grid button.boss::before {
  content: '⌫';
  font-size: 12px;
}
.grid button:disabled {
  opacity: 0.45;
  cursor: default;
  background: transparent;
  border-style: dashed;
}
.grid button.cleared {
  box-shadow: 2px 2px 0 var(--teal);
}

.opts {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}
.opts fieldset {
  border: 2px dashed var(--soft);
  margin: 0;
  padding: 6px 8px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.opts legend {
  font-size: 14px;
  color: var(--soft);
  padding: 0 4px;
}
.opts label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 2px solid var(--ink);
  background: var(--cream);
  padding: 6px 10px;
  cursor: pointer;
  min-height: 40px;
  font-size: 15px;
}
.opts input {
  accent-color: var(--teal);
}
.opts label:has(input:checked) {
  background: var(--teal);
  color: var(--cream);
}
.graph {
  margin: 0;
  border: 2px solid var(--ink);
  background: var(--cream);
  padding: 6px;
}
.graph svg {
  display: block;
  width: 100%;
  height: auto;
}
.graph p {
  margin: 8px;
  color: var(--soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--soft);
  flex: 1;
}
.field input {
  font-size: 18px;
  color: var(--ink);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  padding: 8px 10px;
  min-height: 44px;
}
#race-code {
  text-transform: uppercase;
  letter-spacing: 4px;
}
.joinrow {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 14px;
}
.code {
  font-size: 44px;
  letter-spacing: 8px;
  margin: 8px 0;
  text-align: center;
  color: var(--tomato-ink);
}
.racers {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
}
.racers li {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px dotted var(--soft);
  padding: 4px 0;
  font-size: 17px;
}
.note {
  margin: 6px 0;
  padding: 8px 10px;
  background: var(--cream);
  border-left: 6px solid var(--mustard);
  font-size: 15px;
}
.note:empty {
  display: none;
}

dialog.paper {
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  max-width: min(94vw, 460px);
  padding: 18px 18px 14px;
}
dialog.paper.wide {
  max-width: min(96vw, 640px);
  width: 100%;
}
dialog::backdrop {
  background: rgba(31, 27, 22, 0.45);
}
dialog h2 {
  margin: 0 0 8px;
  font-size: 28px;
}
.steps {
  padding-left: 22px;
  line-height: 1.45;
  font-size: 17px;
}
.quip {
  margin: 0;
  color: var(--soft);
  font-size: 16px;
}
.stars {
  margin: 0;
  font-size: 32px;
  color: var(--mustard);
  -webkit-text-stroke: 1px var(--ink);
  letter-spacing: 2px;
  min-height: 0;
}
.big {
  font-size: 30px;
  margin: 4px 0;
}
.earn {
  margin: 6px 0;
  padding: 6px 8px;
  background: var(--cream);
  border: 2px dashed var(--teal);
  font-size: 15px;
}
.earn:empty {
  display: none;
}
.share {
  font-family: var(--font);
  background: var(--cream);
  border: 2px solid var(--ink);
  padding: 8px;
  white-space: pre-wrap;
  font-size: 14px;
  margin: 8px 0;
}
.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ranking {
  padding-left: 0;
  list-style: none;
  margin: 6px 0;
  display: grid;
  gap: 4px;
}
.ranking li {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 16px;
}
.ranking li b {
  width: 34px;
}
.ranking li.you {
  color: var(--tomato-ink);
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.tabs button[aria-selected='true'] {
  background: var(--ink);
  color: var(--cream);
}
.items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}
.items li {
  border: 2px solid var(--ink);
  background: var(--cream);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 15px;
}
.items li.on {
  box-shadow: inset 0 0 0 3px var(--teal);
}
.items .swatch {
  width: 40px;
  height: 40px;
  border: 2px solid var(--ink);
}
.toast {
  position: fixed;
  left: 50%;
  top: 12px;
  visibility: hidden;
  transform: translateX(-50%) translateY(-150%);
  background: var(--ink);
  color: var(--cream);
  padding: 8px 14px;
  transition: transform 0.2s;
  z-index: 10;
  font-size: 16px;
  max-width: 90vw;
}
.toast.show {
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
body[data-screen='play'] .tagline,
body[data-screen='play'] .top {
  display: none;
}
/* character select (Catch Mind style cards) + home/race pickers */
.homebtns {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
}
.castbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 2px 10px;
}
.cast-stage {
  position: relative;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--paper);
}
#cast-preview {
  display: block;
  width: 100%;
  height: clamp(150px, 26vh, 210px);
  cursor: pointer;
}
.cast-mood {
  position: absolute;
  top: 6px;
  left: 8px;
  margin: 0;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--cream);
  font-size: 14px;
  transform: rotate(-2deg);
}
.cast-name {
  margin: 10px 0 0;
  font-size: 26px;
  color: var(--tomato-ink);
}
.cast-trait {
  margin: 2px 0 8px;
  font-size: 15px;
  min-height: 1.3em;
}
.cast-sub {
  margin: 12px 0 4px;
  font-size: 15px;
  color: var(--soft);
}
.cast-grid,
.caststrip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.castcard canvas {
  max-width: 100%;
  height: auto !important;
}
.caststrip {
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  margin: 2px 0 8px;
}
.castlabel {
  margin: 10px 0 2px;
  font-size: 15px;
  color: var(--soft);
}
.castcard {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  border: 2.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 4px;
  cursor: pointer;
  min-height: 44px;
  font-size: 14px;
  position: relative;
}
.castcard b {
  font-weight: 400;
  line-height: 1.1;
  text-align: center;
}
.castcard[aria-checked='true'] {
  background: #f7d9a8;
  border-color: var(--tomato-ink);
  box-shadow: 3px 3px 0 var(--tomato-ink);
  transform: rotate(-2deg) translateY(-2px);
}
.castcard[aria-checked='true']::after {
  content: '✓';
  position: absolute;
  top: -9px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tomato);
  color: #fff;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-size: 13px;
}
.castcard .price {
  font-size: 12px;
  color: var(--teal);
}
.cast-grid.classic .castcard {
  font-size: 12px;
}
dialog.cast {
  max-height: 96vh;
  overflow: auto;
}
.done-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.done-art:empty {
  display: none;
}
@media (max-width: 420px) {
  .homebtns {
    grid-template-columns: 1fr;
  }
  .castcard {
    font-size: 12px;
  }
  .modes {
    grid-template-columns: 1fr;
  }
  .mode {
    min-height: 70px;
  }
  .target {
    font-size: 30px;
  }
  .brand {
    font-size: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
body.reduce * {
  transition: none !important;
  animation: none !important;
}
/* privacy page */
body.doc {
  max-width: 720px;
}
.doc .brand {
  text-decoration: none;
  display: inline-block;
}
.docmain {
  line-height: 1.6;
  font-size: 17px;
  padding-bottom: 40px;
}
.docmain h1 {
  font-size: 30px;
  margin: 18px 0 4px;
}
.docmain h2 {
  font-size: 21px;
  margin: 20px 0 4px;
}
.docmain hr {
  border: 0;
  border-top: 3px dashed var(--soft);
  margin: 30px 0;
}
.toggles {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}
.toggles label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  border: 2px solid var(--ink);
  background: var(--cream);
  padding: 8px 10px;
  min-height: 44px;
  cursor: pointer;
}
.toggles input {
  width: 22px;
  height: 22px;
  accent-color: var(--teal);
}
body.big .target {
  font-size: 44px;
}
body.big .echo,
body.big .sentence {
  font-size: 22px;
}
body.big .hud b {
  font-size: 24px;
}
body.big .mode small {
  font-size: 16px;
}
