/* 한 숟갈 — 낮에는 상아빛 도자기, 밤에는 깊은 바다 */

:root {
  --bg: #f3ede2;
  --surface: #fbf8f2;
  --ink: #1d2730;
  --ink-soft: #46515a;
  --muted: #7b776e;
  --line: #e2d8c6;
  --accent: #c24f28;
  --accent-ink: #fff8f0;
  --yes: #2c7a5f;
  --no: #b5392a;
  --meh: #7b776e;
  --mild: #3f8152;
  --medium: #a8701c;
  --hot: #c23c26;
  --glow: rgb(255 205 140 / 0.38);
  --steam: rgb(110 90 70 / 0.22);
  --rim-1: #fffdf8;
  --rim-2: #dcd3c2;
  --rim-line: #cfc4b0;
  --band: hsl(212 45% 45% / 0.45);
  --piece: #f4e3bf;
  --shadow-bowl: rgb(70 45 20 / 0.32);
  --shadow-soft: 0 12px 28px -18px rgb(70 45 20 / 0.45);

  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Gowun Batang', 'Nanum Myeongjo', 'AppleMyungjo', serif;
  --fs-1: 13px;
  --fs-2: 16px;
  --fs-3: 20px;
  --fs-4: 28px;
  --fs-5: 40px;
  --r-1: 10px;
  --r-2: 18px;
  --r-3: 28px;

  --drops: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g fill='rgb(255 238 200 / .3)' stroke='rgb(255 255 255 / .5)' stroke-width='.8'><circle cx='62' cy='58' r='7'/><circle cx='78' cy='71' r='3.5'/><circle cx='121' cy='50' r='5'/><circle cx='137' cy='63' r='2.5'/><circle cx='151' cy='96' r='8'/><circle cx='141' cy='121' r='3'/><circle cx='112' cy='141' r='6'/><circle cx='88' cy='152' r='3'/><circle cx='60' cy='128' r='9'/><circle cx='43' cy='100' r='3'/><circle cx='71' cy='101' r='2.5'/><circle cx='100' cy='84' r='4'/><circle cx='128' cy='92' r='2'/><circle cx='96' cy='119' r='2.5'/><circle cx='160' cy='136' r='4'/><circle cx='52' cy='150' r='2'/><circle cx='108' cy='38' r='2.5'/><circle cx='150' cy='152' r='2'/><circle cx='84' cy='32' r='2'/><circle cx='168' cy='80' r='2.5'/></g></svg>");
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141c;
    --surface: #111d27;
    --ink: #ece4d5;
    --ink-soft: #c3bbad;
    --muted: #87929b;
    --line: #1e2d39;
    --accent: #e3713f;
    --accent-ink: #1c0f07;
    --yes: #5cc39d;
    --no: #f07a63;
    --meh: #87929b;
    --mild: #7cc08a;
    --medium: #e2ad57;
    --hot: #f07a63;
    --glow: rgb(70 120 160 / 0.22);
    --steam: rgb(220 230 240 / 0.2);
    --rim-1: #34495b;
    --rim-2: #182634;
    --rim-line: #2c3f4f;
    --band: hsl(195 55% 62% / 0.32);
    --piece: #efdcb2;
    --shadow-bowl: rgb(0 0 0 / 0.6);
    --shadow-soft: 0 12px 28px -18px rgb(0 0 0 / 0.8);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(1100px 720px at 50% -8%, var(--glow), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 var(--fs-2) / 1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── 그릇 ─────────────────────────────────────────── */

.stage {
  position: relative;
  aspect-ratio: 300 / 310;
}

.bowl {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.bowl-shadow {
  fill: var(--shadow-bowl);
}

.rim-hi {
  stroke: rgb(255 255 255 / 0.5);
  stroke-width: 1.5;
}

.rim-band {
  stroke: var(--band);
  stroke-width: 1.5;
}

.rim-in {
  fill: var(--rim-2);
  stroke: var(--rim-line);
  stroke-width: 1;
}

.soup-edge {
  stroke: rgb(255 255 255 / 0.18);
  stroke-width: 1.5;
}

.empty-floor {
  fill: var(--rim-1);
}

/* 국물 위 기름방울. 그릇 안 국물 원과 같은 자리에 겹쳐 천천히 돈다. */
.sheen {
  position: absolute;
  left: 14.667%;
  top: 13.548%;
  width: 70.667%;
  height: 68.387%;
  border-radius: 50%;
  background: var(--drops) center / cover;
  opacity: 0.85;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: swirl 120s linear infinite;
}

@keyframes swirl {
  to {
    transform: rotate(360deg);
  }
}

/* 건더기: 가라앉은 그림자(shade)와 떠오른 조각(pc) */
.shade {
  transition: opacity 0.5s ease;
}

.shade.on {
  opacity: 0;
}

.pc {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  transform: translateY(10px) scale(0.6);
  transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

.pc.on {
  opacity: 1;
  transform: none;
}

.pc.ghost {
  opacity: 0.5;
}

.pc .bob {
  transform-box: fill-box;
  transform-origin: center;
  animation: bob 6s ease-in-out infinite;
}

.pc-body {
  fill: var(--piece);
  stroke-width: 1.5;
}

@keyframes bob {
  50% {
    transform: translateY(-2.5px) rotate(4deg);
  }
}

.ripple {
  fill: none;
  stroke: rgb(255 255 255 / 0.6);
  stroke-width: 2;
  transform-box: view-box;
  transform-origin: 150px 148px;
  opacity: 0;
}

.stage.ping .ripple {
  animation: ripple 1.1s ease-out;
}

.stage.busy .ripple {
  animation: ripple 1.3s ease-out infinite;
}

@keyframes ripple {
  from {
    opacity: 0.85;
    transform: scale(0.12);
  }
  to {
    opacity: 0;
    transform: scale(1);
  }
}

/* 김 */
.steam {
  position: absolute;
  left: 26%;
  width: 48%;
  top: -10%;
  height: 56%;
  pointer-events: none;
}

.steam span {
  position: absolute;
  bottom: 0;
  width: 34%;
  aspect-ratio: 1 / 1.3;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--steam), transparent);
  filter: blur(10px);
  opacity: 0;
  animation: steam 7s ease-out infinite;
}

.steam span:nth-child(1) {
  left: 4%;
}

.steam span:nth-child(2) {
  left: 34%;
  animation-delay: 2.3s;
}

.steam span:nth-child(3) {
  left: 62%;
  animation-delay: 4.6s;
}

@keyframes steam {
  0% {
    opacity: 0;
    transform: translate(0, 40%) scale(0.6);
  }
  30% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(12%, -150%) scale(1.3);
  }
}

.tag {
  position: absolute;
  right: 2%;
  bottom: 9%;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--fs-1);
  font-weight: 700;
  transform: rotate(-5deg);
  box-shadow: var(--shadow-soft);
}

.taste-mild {
  color: var(--mild);
}

.taste-medium {
  color: var(--medium);
}

.taste-hot {
  color: var(--hot);
}

/* 판정 도장 */
.stamp {
  position: absolute;
  left: 27%;
  top: 25%;
  width: 46%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 5px double currentColor;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(2px);
  font-family: var(--font-serif);
  font-size: var(--fs-4);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transform: rotate(-12deg) scale(1.5);
  pointer-events: none;
}

.stamp.long {
  font-size: var(--fs-3);
}

.stamp.show {
  animation: stamp 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.stamp.stay {
  animation: stamp-stay 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes stamp {
  0% {
    opacity: 0;
    transform: rotate(-12deg) scale(1.5);
  }
  10% {
    opacity: 1;
    transform: rotate(-12deg) scale(1);
  }
  78% {
    opacity: 1;
    transform: rotate(-12deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(-12deg) scale(0.96);
  }
}

@keyframes stamp-stay {
  from {
    opacity: 0;
    transform: rotate(-12deg) scale(1.5);
  }
  to {
    opacity: 1;
    transform: rotate(-12deg) scale(1);
  }
}

.tone-yes {
  color: var(--yes);
}

.tone-no {
  color: var(--no);
}

.tone-meh {
  color: var(--meh);
}

.tone-done {
  color: var(--accent);
}

/* ── 버튼 ─────────────────────────────────────────── */

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 32px;
  border-radius: 999px;
  font-size: var(--fs-3);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 14px 28px -14px var(--accent);
  transition: transform 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-ghost {
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-size: var(--fs-2);
}

/* ── 게임 화면 ─────────────────────────────────────── */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
}

.back:hover {
  background: var(--surface);
}

.brand {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-left: 4px;
  font-family: var(--font-serif);
  font-size: var(--fs-3);
  font-weight: 700;
}

.brand img {
  width: 30px;
  height: 30px;
}

.bar-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip {
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: var(--fs-1);
  color: var(--muted);
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
}

.icon-btn:hover {
  background: var(--surface);
}

.bar {
  padding-inline: max(12px, calc((100% - 1120px) / 2 + 8px));
}

.game {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px 0;
  display: grid;
  gap: 24px;
}

.table {
  display: grid;
  gap: 20px;
  justify-items: center;
}

.soup-title {
  margin: 8px 0 0;
  font-family: var(--font-serif);
  font-size: var(--fs-4);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.story {
  width: 100%;
  margin: 0;
  padding: 20px 22px;
  border-radius: var(--r-2);
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--font-serif);
  line-height: 1.85;
  box-shadow: var(--shadow-soft);
}

.table .stage {
  width: min(64vw, 280px);
}

.count {
  margin: -4px 0 0;
  font-size: var(--fs-1);
  color: var(--muted);
}

.count b {
  color: var(--ink);
  font-weight: 700;
}

.talk {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

@media (min-width: 900px) {
  .game {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 56px;
    padding-top: 16px;
  }

  .table {
    position: sticky;
    top: 76px;
    align-self: start;
  }

  .soup-title {
    font-size: var(--fs-5);
  }

  .story {
    font-size: var(--fs-3);
    padding: 26px 28px;
  }

  .table .stage {
    width: 340px;
  }

  .stamp {
    font-size: var(--fs-5);
  }

  .stamp.long {
    font-size: var(--fs-4);
  }

  .talk {
    min-height: calc(100dvh - 76px);
  }
}

/* 주고받은 말 */
.log {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 16px;
  padding: 14px 6px;
  scroll-margin-bottom: 220px;
  border-bottom: 1px solid var(--line);
  animation: row-in 0.35s ease;
}

.row p {
  margin: 0;
  overflow-wrap: anywhere;
}

.ans {
  font-family: var(--font-serif);
  font-weight: 700;
  white-space: nowrap;
}

.row small {
  grid-column: 1 / -1;
  font-size: var(--fs-1);
  color: var(--muted);
}

.row.is-key {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 12%, transparent), transparent 75%);
}

.key {
  margin-right: 8px;
  font-size: var(--fs-1);
  font-weight: 700;
  color: var(--accent);
}

.row-g p {
  font-family: var(--font-serif);
}

.row-h {
  grid-template-columns: auto 1fr;
}

.row-h .label {
  font-size: var(--fs-1);
  font-weight: 700;
  color: var(--accent);
}

.row-h p {
  color: var(--ink-soft);
}

.log-empty {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* 입력 */
.dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 16px 0 calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 22px);
}

.dock.is-end {
  position: static;
  background: none;
  scroll-margin-top: 72px;
}

.composer {
  display: grid;
  gap: 10px;
}

.seg {
  justify-self: start;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.seg button {
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-1);
  font-weight: 600;
}

.seg button[aria-selected='true'] {
  background: var(--ink);
  color: var(--bg);
}

.field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 20px;
  border-radius: var(--r-3);
  background: var(--surface);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.2s ease;
}

.field:focus-within {
  border-color: var(--ink-soft);
}

.field textarea {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  max-height: 200px;
  padding: 14px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

.field textarea::placeholder {
  color: var(--muted);
}

.send {
  flex: none;
  min-width: 92px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-3);
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.send:active {
  transform: scale(0.96);
}

.send:disabled {
  opacity: 0.55;
  cursor: progress;
}

.composer[data-mode='guess'] .send {
  background: var(--ink);
  color: var(--bg);
}

.notice {
  margin: 0;
  padding: 0 8px;
  font-size: var(--fs-1);
  color: var(--no);
}

.notice:empty {
  display: none;
}

.aux {
  display: flex;
  justify-content: space-between;
}

.aux button {
  min-height: 36px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fs-1);
}

.aux button:hover:not(:disabled) {
  color: var(--ink);
}

.aux button:disabled {
  opacity: 0.4;
  cursor: default;
}

.aux button.armed {
  color: var(--no);
  font-weight: 700;
}

/* 결말 */
.ending {
  padding: 8px 0 24px;
  animation: row-in 0.5s ease;
}

.ending-title {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: var(--fs-4);
  color: var(--accent);
}

.truth {
  margin: 0 0 22px;
  font-family: var(--font-serif);
  line-height: 1.9;
}

.pieces-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.pieces-list li {
  padding: 12px 16px;
  border-radius: var(--r-1);
  background: var(--surface);
  color: var(--muted);
}

.pieces-list li.got {
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
}

.ending-act {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* 기록 숫자 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 24px;
  padding: 18px 8px;
  border-radius: var(--r-2);
  background: var(--surface);
  text-align: center;
}

.stats dt {
  font-size: var(--fs-1);
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--fs-4);
  font-weight: 700;
  line-height: 1.3;
}

.ending-act {
  align-items: center;
  justify-content: space-between;
}

.next {
  margin: 0;
  font-size: var(--fs-1);
  color: var(--muted);
}

.next b {
  display: block;
  font-size: var(--fs-3);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* 기록 창 */
.sheet {
  width: min(92vw, 440px);
  max-height: 86dvh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.5);
}

.sheet::backdrop {
  background: rgb(10 16 22 / 0.45);
  backdrop-filter: blur(3px);
}

.sheet[open] {
  animation: row-in 0.25s ease;
}

.sheet-body {
  padding: 12px 20px 22px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--fs-3);
}

.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
}

.shelf li {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.shelf-bowl {
  width: 100%;
  max-width: 52px;
  aspect-ratio: 300 / 310;
  display: grid;
  place-items: center;
}

.ghost-bowl {
  width: 84%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1.5px dashed var(--line);
}

.shelf-no {
  font-size: var(--fs-1);
  color: var(--muted);
}

.shelf-state {
  min-height: 1.4em;
  font-size: var(--fs-1);
  font-weight: 700;
  color: var(--muted);
}

.shelf .solved .shelf-state {
  color: var(--accent);
}

.shelf .today .shelf-state {
  color: var(--ink);
}

.sheet-note {
  margin: 18px 0 0;
  font-size: var(--fs-1);
  color: var(--muted);
  text-align: center;
}

/* ── 차림표 (골라 풀기) ───────────────────────────────── */

.menu {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px 96px;
}

.menu-title {
  margin: 8px 0 20px;
  font-family: var(--font-serif);
  font-size: var(--fs-4);
  text-align: center;
}

.dishes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 16px;
}

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

@media (min-width: 960px) {
  .menu-title {
    font-size: var(--fs-5);
    margin-bottom: 36px;
  }

  .dishes {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 40px 24px;
  }
}

.dish {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px 4px 12px;
  border-radius: var(--r-2);
  text-align: center;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.dish:hover {
  background: var(--surface);
}

.dish:active {
  transform: scale(0.98);
}

.dish-bowl {
  position: relative;
  width: min(100%, 150px);
  aspect-ratio: 300 / 310;
  margin-bottom: 6px;
}

.dish-stamp {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 52%;
  height: 52%;
  display: grid;
  place-items: center;
  border: 3px double var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: var(--fs-2);
  font-weight: 700;
  transform: rotate(-12deg);
  top: -6%;
}

.dish-name {
  font-family: var(--font-serif);
  font-size: var(--fs-3);
  font-weight: 700;
  line-height: 1.3;
}

.dish-meta {
  display: flex;
  gap: 8px;
  font-size: var(--fs-1);
  font-weight: 600;
}

.dish-mark {
  color: var(--muted);
  font-weight: 400;
}

.redo {
  display: block;
  margin: 20px 0 0;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fs-1);
}

.redo:hover {
  color: var(--ink);
}

.fail {
  max-width: 28em;
  margin: 18vh auto 0;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
}

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

  .pc.on,
  .stamp.show,
  .stamp.stay {
    opacity: 1;
    transform: rotate(-12deg);
  }

  .pc.on {
    transform: none;
  }
}
