:root {
  color-scheme: light;
  --plaster: oklch(0.955 0.03 85);
  --plaster-2: oklch(0.91 0.05 80);
  --plaster-3: oklch(0.86 0.06 75);
  --ink: oklch(0.24 0.045 35);
  --ink-soft: oklch(0.40 0.05 40);
  --red: oklch(0.50 0.17 28);
  --red-deep: oklch(0.40 0.14 28);
  --saffron: oklch(0.84 0.15 80);
  --saffron-deep: oklch(0.72 0.15 70);
  --teal: oklch(0.47 0.08 205);
  --leaf: oklch(0.50 0.13 150);
  --cream: oklch(0.975 0.02 85);
  --shadow: oklch(0.35 0.06 40 / 0.25);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Lilita One", "Arial Rounded MT Bold", sans-serif;
  --body: "Fredoka", "Trebuchet MS", sans-serif;
  --gutter: clamp(16px, 4vw, 32px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--plaster);
  background-image:
    radial-gradient(circle at 15% 10%, oklch(0.93 0.05 75 / 0.7) 0 18%, transparent 40%),
    radial-gradient(circle at 90% 85%, oklch(0.92 0.05 60 / 0.6) 0 15%, transparent 35%);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(16px, 1rem + 0.3vw, 19px);
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 720px; margin: 0 auto; min-height: 100dvh;
  padding: max(env(safe-area-inset-top), 12px) var(--gutter) max(env(safe-area-inset-bottom), 16px);
}
.screen { animation: enter 0.45s var(--ease) both; }
[hidden] { display: none !important; }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } }

h1, h2 { font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: 0.01em; }
.sign { margin: clamp(24px, 8vh, 72px) 0 28px; }
.sign.small { margin: 16px 0 20px; }
.sign h1 {
  font-size: clamp(2.6rem, 9vw + 0.5rem, 4.6rem); line-height: 0.95; color: var(--red);
  text-shadow: 3px 3px 0 var(--saffron);
}
.sign.small h1 { font-size: clamp(2rem, 7vw, 3rem); }
.kicker { font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem; color: var(--teal); margin: 0 0 6px; }
.lede { font-size: 1.1rem; max-width: 28ch; margin: 14px 0 0; color: var(--ink-soft); }
.lede.dark { max-width: none; margin: 4px 0 18px; }
.err { color: var(--red-deep); font-weight: 600; min-height: 1.4em; margin: 4px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.join { display: grid; gap: 6px; max-width: 380px; }
.join label { font-weight: 600; margin-top: 10px; }
input {
  font: inherit; font-size: 1.15rem; padding: 14px 16px; border-radius: 14px;
  border: 3px solid var(--ink); background: var(--cream); color: var(--ink); width: 100%;
}
input:focus-visible, button:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }

.btn {
  font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer; border-radius: 14px;
  padding: 13px 22px; min-height: 48px; border: 3px solid var(--ink); color: var(--ink); background: var(--cream);
  transition: transform 0.15s var(--ease);
}
.btn:active { transform: translateY(2px) scale(0.98); }
.btn.primary { background: var(--red); color: var(--cream); box-shadow: 0 4px 0 var(--ink); margin-top: 14px; }
.btn.primary:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(3px); }
.btn.ghost { background: transparent; }
.btn.text { border: 0; background: none; padding: 8px 4px; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }
.icon-btn {
  font-size: 1.1rem; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink);
  background: var(--cream); color: var(--ink); cursor: pointer; flex: none;
}

.mastery { background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; padding: 14px 16px; }
.mastery-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.mastery-row strong { font-family: var(--display); font-weight: 400; font-size: 1.4rem; color: var(--leaf); }
.bar { height: 14px; border-radius: 99px; background: var(--plaster-3); margin: 8px 0; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--leaf); transform-origin: left; transform: scaleX(0); transition: transform 0.8s var(--ease); }
.hint-line { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }

.modes { display: grid; gap: 14px; margin: 22px 0 18px; }
.mode {
  text-align: left; font: inherit; color: var(--cream); border: 3px solid var(--ink); border-radius: 20px;
  padding: 20px 20px 22px; cursor: pointer; box-shadow: 0 6px 0 var(--ink); transition: transform 0.15s var(--ease);
  display: grid; gap: 4px;
}
.mode:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.mode.cafe { background: var(--red); }
.mode.escape { background: var(--teal); }
.mode-title { font-family: var(--display); font-size: clamp(1.7rem, 6vw, 2.2rem); }
.mode-sub { font-size: 1rem; max-width: 34ch; }
.row-links { display: flex; gap: 10px; flex-wrap: wrap; }
.you-total { margin-top: 18px; color: var(--ink-soft); }
.you-total strong { color: var(--ink); }

.topline { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; flex-wrap: wrap; }
.topline h2 { font-size: clamp(1.6rem, 6vw, 2.2rem); color: var(--red); }

/* ---------- café ---------- */
.cafe-screen { display: flex; flex-direction: column; gap: 10px; min-height: calc(100dvh - 40px); position: relative; }
.hud { display: flex; align-items: center; gap: 8px; }
.hud-stat {
  flex: 1; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 4px 10px;
  display: flex; flex-direction: column; line-height: 1.1;
}
.hud-stat span { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.hud-stat strong { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.hud-stat.low strong { color: var(--red); }
.hud-stat.combo.hot { background: var(--saffron); }

.queue { display: flex; gap: 10px; align-items: flex-end; min-height: 92px; padding: 0 4px; border-bottom: 6px solid var(--red); position: relative; }
.queue::after { content: ""; position: absolute; left: -4px; right: -4px; bottom: -14px; height: 8px; background: repeating-linear-gradient(90deg, var(--saffron) 0 18px, var(--red-deep) 18px 36px); border-radius: 0 0 6px 6px; }
.cust { display: grid; justify-items: center; gap: 4px; animation: walk-in 0.5s var(--ease) both; }
.cust .face { font-size: 2.2rem; line-height: 1; transition: transform 0.3s var(--ease); }
.cust.front .face { font-size: 3.2rem; }
.cust:not(.front) { opacity: 1; filter: saturate(0.6); }
.cust.leaving { animation: walk-out 0.45s var(--ease) both; }
.cust.angry .face { animation: shake 0.4s; }
.pat { width: 54px; height: 9px; border-radius: 9px; background: var(--plaster-3); overflow: hidden; border: 2px solid var(--ink); }
.pat i { display: block; height: 100%; width: 100%; background: var(--leaf); transform-origin: left; }
.pat.warn i { background: var(--saffron-deep); }
.pat.crit i { background: var(--red); }
.tag { font-size: 0.7rem; font-weight: 600; background: var(--teal); color: var(--cream); padding: 1px 7px; border-radius: 99px; }
@keyframes walk-in { from { transform: translateX(80px); opacity: 0; } }
@keyframes walk-out { to { transform: translateX(-80px); opacity: 0; } }

.ticket {
  background: var(--cream); border: 3px solid var(--ink); border-radius: 6px 6px 18px 18px; padding: 12px 14px;
  margin-top: 10px; box-shadow: 0 5px 0 var(--shadow); position: relative;
}
.ticket-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.ticket-items { display: flex; flex-wrap: wrap; gap: 8px 10px; margin-top: 6px; align-items: center; }
.ti { font-family: var(--display); font-size: clamp(1.7rem, 7vw, 2.4rem); line-height: 1.1; color: var(--ink); transition: color 0.2s; }
.ti.done { color: var(--leaf); text-decoration: line-through; text-decoration-thickness: 3px; }
.plus { color: var(--saffron-deep); font-family: var(--display); font-size: 1.4rem; }

.plate {
  height: 54px; border-radius: 50%; background: radial-gradient(ellipse at center, var(--cream) 0 55%, var(--plaster-3) 56% 70%, transparent 71%);
  display: flex; justify-content: center; align-items: center; gap: 2px; font-size: 1.7rem;
}
.plate span { animation: drop 0.35s var(--ease) both; }
@keyframes drop { from { transform: translateY(-40px) scale(1.4); opacity: 0; } }
.plate.serve { animation: serve 0.4s var(--ease) both; }
@keyframes serve { to { transform: translateY(-120px) scale(0.6); opacity: 0; } }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: auto; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  font: inherit; font-weight: 600; font-size: 1.12rem; color: var(--ink); cursor: pointer;
  background: var(--saffron); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 5px 0 var(--ink);
  min-height: 74px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; text-align: left;
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease);
}
.tile .em { font-size: 1.6rem; flex: none; min-width: 1.6em; text-align: center; font-family: var(--display); }
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.tile.used { background: var(--plaster-2); box-shadow: 0 1px 0 var(--ink); transform: translateY(4px); color: var(--ink-soft); }
.tile.wrong { background: var(--red); color: var(--cream); animation: shake 0.4s; }
.tile small { display: block; font-size: 0.85rem; font-weight: 500; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; font-family: var(--display); font-size: 1.6rem; color: var(--leaf); text-shadow: 2px 2px 0 var(--cream); animation: pop 0.9s var(--ease) both; }
.pop.bad { color: var(--red); }
@keyframes pop { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 20% { opacity: 1; transform: translateY(-10px) scale(1.1); } 100% { transform: translateY(-70px) scale(1); opacity: 0; } }
.banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--display); font-size: clamp(2.2rem, 10vw, 3.4rem);
  color: var(--cream); background: var(--red); border: 3px solid var(--ink); padding: 8px 22px; border-radius: 16px; white-space: nowrap;
  animation: banner 1.2s var(--ease) both;
}
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-6deg); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1) rotate(-3deg); } }

/* ---------- results ---------- */
.stars { font-size: 2.6rem; letter-spacing: 6px; margin: -6px 0 10px; }
.stars .off { filter: grayscale(1) opacity(0.35); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 16px; }
.stats div { background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; }
.stats dt { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.stats dd { margin: 0; font-family: var(--display); font-size: 1.8rem; }
.missed h3 { font-family: var(--display); font-weight: 400; font-size: 1.4rem; margin: 6px 0; color: var(--red); }
.wl { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.wl li { display: flex; gap: 10px; align-items: center; background: var(--cream); border-radius: 12px; padding: 6px 8px 6px 12px; border: 2px solid var(--plaster-3); }
.wl b { font-family: var(--display); font-weight: 400; font-size: 1.2rem; }
.wl .m { color: var(--ink-soft); flex: 1; }
.wl li.ok { border-color: var(--leaf); }
.wl li.ok::before { content: "✓"; color: var(--leaf); font-weight: 700; }

/* ---------- escape ---------- */
.room-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.room-list button {
  width: 100%; font: inherit; text-align: left; cursor: pointer; display: grid; grid-template-columns: 3.2rem 1fr auto; align-items: center; gap: 12px;
  background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 14px; min-height: 64px;
}
.room-list .num { font-family: var(--display); font-size: 1.6rem; color: var(--teal); }
.room-list .nm { font-weight: 600; }
.room-list .nm small { display: block; font-weight: 500; color: var(--ink-soft); }
.room-list .done { background: oklch(0.92 0.06 150); }
.room-list .badge { font-family: var(--display); color: var(--leaf); }

.room-screen { display: flex; flex-direction: column; gap: 14px; }
.door {
  background: var(--teal); border: 3px solid var(--ink); border-radius: 120px 120px 14px 14px; padding: 34px 18px 18px;
  box-shadow: inset 0 0 0 8px oklch(0.40 0.07 205); transition: transform 0.6s var(--ease);
}
.door.open { animation: swing 0.9s var(--ease) both; }
@keyframes swing { 50% { transform: scale(1.04); } to { transform: perspective(600px) rotateY(-70deg); opacity: 0.2; } }
.seals { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.seal { width: 26px; height: 26px; border-radius: 50%; background: var(--red); border: 3px solid var(--ink); transition: transform 0.3s var(--ease); }
.seal.broken { background: var(--saffron); transform: scale(0.8); }
.seal.cur { transform: scale(1.25); box-shadow: 0 0 0 3px var(--cream); }
.riddle { background: var(--cream); border: 3px solid var(--ink); border-radius: 18px; padding: 14px 16px; }
.riddle-label { margin: 0; font-weight: 600; color: var(--ink-soft); font-size: 0.95rem; }
.riddle-word { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.riddle-word span { font-family: var(--display); font-size: clamp(1.9rem, 8vw, 2.8rem); line-height: 1.05; }
.answer { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.answer .btn.primary { margin-top: 0; }
.answer.shake { animation: shake 0.4s; }
.feedback { min-height: 1.4em; margin: 10px 0 0; font-weight: 600; }
.feedback.good { color: var(--leaf); }
.feedback.bad { color: var(--red-deep); }
.room-score { margin: 0; color: var(--ink-soft); }

/* ---------- board & scroll ---------- */
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: r; }
.board li { counter-increment: r; display: grid; grid-template-columns: 2.4rem 1fr auto; gap: 10px; align-items: center; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; }
.board li::before { content: counter(r); font-family: var(--display); font-size: 1.5rem; color: var(--teal); }
.board li:nth-child(1) { background: var(--saffron); }
.board li.me { outline: 3px solid var(--red); outline-offset: 2px; }
.board .who { font-weight: 700; }
.board .who small { display: block; font-weight: 500; color: var(--ink-soft); }
.board .pts { font-family: var(--display); font-size: 1.4rem; }
.lesson-h { font-family: var(--display); font-weight: 400; color: var(--teal); margin: 18px 0 8px; font-size: 1.3rem; }
.wl button.say-row { all: unset; display: contents; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.tag.vip { background: var(--saffron-deep); color: var(--ink); }
.tag.rush { background: var(--red); }
.cafe-screen::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s var(--ease); z-index: 5; }
.cafe-screen.fever::before { opacity: 1; box-shadow: inset 0 0 0 8px var(--saffron), inset 0 0 60px oklch(0.84 0.15 80 / 0.6); animation: glow 0.8s ease-in-out infinite alternate; }
.cafe-screen.panic::before { opacity: 1; box-shadow: inset 0 0 0 6px var(--red), inset 0 0 50px oklch(0.5 0.17 28 / 0.45); animation: glow 0.35s ease-in-out infinite alternate; }
.cafe-screen.fever .pop { font-size: 2.3rem; }
@keyframes glow { from { opacity: 0.55; } to { opacity: 1; } }
.rank { margin-top: 16px; display: grid; }
.rank strong { font-family: var(--display); font-weight: 400; font-size: 1.5rem; color: var(--teal); }
.rank span { color: var(--ink-soft); font-size: 0.95rem; }
.you-total .btn.text { font-size: 0.95rem; padding: 0 4px; min-height: 44px; }
.board .pts small { font-family: var(--body); font-size: 0.85rem; color: var(--ink-soft); }
.shop h3 { font-family: var(--display); font-weight: 400; font-size: 1.4rem; margin: 10px 0 8px; color: var(--teal); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.shop h3 span { font-family: var(--body); font-size: 1rem; font-weight: 600; color: var(--ink); }
.shop { display: grid; gap: 8px; margin-bottom: 8px; }
.up { font: inherit; color: var(--ink); text-align: left; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; min-height: 56px; }
.up b { font-weight: 700; } .up span { grid-column: 1; color: var(--ink-soft); font-size: 0.92rem; }
.up em { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-style: normal; font-family: var(--display); font-size: 1.2rem; }
.up:disabled { cursor: default; background: var(--plaster-2); color: var(--ink-soft); }
.up:disabled b { color: var(--ink-soft); }
.stats dd small { display: block; font-family: var(--body); font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
