:root {
  --bg: #1b0d08;
  --bg2: #2a140c;
  --card: #2f1810;
  --line: rgba(255, 220, 190, 0.12);
  --text: #fff1e6;
  --muted: #c9a894;
  --red: #ff4b2b;
  --orange: #ff8a3d;
  --yellow: #ffcf5a;
  --green: #5ed18a;
  --radius: 18px;
  --display: 'Jua', 'Pretendard', system-ui, sans-serif;
  --body: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --mono: 'Nanum Gothic Coding', 'D2Coding', ui-monospace, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 90, 40, 0.25), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(255, 140, 40, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.screen { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 공통 ── */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card.warn { border-color: rgba(255, 207, 90, 0.5); background: rgba(255, 207, 90, 0.08); }
.card.warn p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-title { font-family: var(--display); font-size: 19px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
code { background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
.row { display: flex; gap: 8px; align-items: center; }

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  transition: transform 0.08s, background 0.2s, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, #ff6a3d, #e8361b);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(255, 75, 43, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn.big { width: 100%; padding: 16px; font-size: 18px; font-family: var(--display); font-weight: 400; letter-spacing: 0.5px; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); display: block; margin: 8px auto 0; }

input[type='text'], input:not([type]) {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--orange); }

/* ── 홈 ── */
.home-wrap { padding-top: 4vh; }
.logo { text-align: center; margin-bottom: 26px; }
.logo-pot { font-size: 84px; filter: drop-shadow(0 10px 30px rgba(255, 90, 40, 0.5)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.logo h1 { font-family: var(--display); font-weight: 400; font-size: 40px; margin: 6px 0 8px; }
.logo h1 span { color: var(--orange); }
.tagline { color: var(--muted); margin: 0; line-height: 1.6; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.divider { text-align: center; position: relative; margin: 18px 0 14px; color: var(--muted); font-size: 13px; }
.divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.divider span { position: relative; background: var(--card); padding: 0 10px; }
#btn-join { flex: none; white-space: nowrap; }
#join-code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
.foot { text-align: center; color: var(--muted); font-size: 13px; }

/* ── 대기실 ── */
.room-code-card { text-align: center; }
.room-code-card .label { color: var(--muted); font-size: 13px; }
.room-code { font-family: var(--display); font-size: 56px; letter-spacing: 10px; color: var(--yellow); margin: 2px 0 10px; text-shadow: 0 4px 24px rgba(255, 207, 90, 0.35); }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, 0.22); border-radius: 12px; padding: 10px 12px; font-weight: 700; min-width: 0; }
.player-list li.off { opacity: 0.4; }
.player-list .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 10px currentColor; }
.player-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .me { color: var(--muted); font-weight: 400; font-size: 12px; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.setting:first-of-type { border-top: none; padding-top: 0; }
.setting-label { font-weight: 700; }
.setting-label small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 3px; }
.broth-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.broth-opt { background: rgba(0, 0, 0, 0.25); border: 2px solid transparent; border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 13px; }
.broth-opt .e { font-size: 24px; display: block; }
.broth-opt.on { border-color: var(--orange); background: rgba(255, 138, 61, 0.15); }
.broth-opt:disabled { cursor: default; opacity: 1; }
.seg { display: flex; background: rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 3px; }
.seg button { border: none; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--orange); color: #fff; }
.seg button:disabled { cursor: default; }

.switch { position: relative; width: 54px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: rgba(255, 255, 255, 0.15); border-radius: 30px; transition: 0.2s; cursor: pointer; }
.slider::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(24px); }
.switch input:disabled + .slider { cursor: default; opacity: 0.75; }

/* 채팅 */
.chat-log { height: 180px; overflow-y: auto; background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; overscroll-behavior: contain; }
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; }
.chat-msg { max-width: 85%; align-self: flex-start; background: rgba(255, 255, 255, 0.08); border-radius: 4px 14px 14px 14px; padding: 6px 10px; font-size: 14px; line-height: 1.4; word-break: break-word; }
.chat-msg.mine { align-self: flex-end; background: rgba(255, 106, 61, 0.35); border-radius: 14px 4px 14px 14px; }
.chat-nick { display: block; font-size: 11.5px; font-weight: 800; margin-bottom: 1px; }
.chat-form input { flex: 1; min-width: 0; }
.chat-form .btn { flex: none; white-space: nowrap; padding: 10px 14px; }

/* ── 플레이 ── */
#screen-play {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
}
html.playing, html.playing body { overflow: hidden; height: 100%; overscroll-behavior: none; }
.hud { flex: none; display: flex; align-items: center; gap: 12px; }
.timer { font-family: var(--display); font-size: 30px; min-width: 84px; color: var(--yellow); }
.timer.hurry { color: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.gauges { flex: 1; display: grid; gap: 4px; }
.gauge { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.gauge .bar { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 8px; overflow: hidden; }
.gauge .bar i { display: block; height: 100%; width: 0; border-radius: 8px; transition: width 0.4s; }
#g-spicy { background: linear-gradient(90deg, var(--orange), var(--red), #a00); }
#g-sweet { background: linear-gradient(90deg, #ffd6e7, #ff7eb6); }
.gauge b { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.mission-pill { border: 1px dashed var(--yellow); background: rgba(255, 207, 90, 0.12); color: var(--yellow); border-radius: 20px; padding: 6px 12px; font-weight: 700; font-size: 13px; }
.broth-name { text-align: center; color: var(--muted); font-size: 13px; margin-top: 4px; }

.pot-area { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding-bottom: 14px; }
#pot { display: block; width: 300px; height: 300px; touch-action: none; }
.score-hint { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.feed { position: absolute; top: 4px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 2; }
.feed-item { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); border-radius: 20px; padding: 5px 12px; font-size: 13px; animation: feedIn 0.25s ease, feedOut 0.5s ease 3.2s forwards; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.feed-item.chaos { background: rgba(120, 20, 40, 0.75); }
.feed-item.anon { background: rgba(20, 20, 30, 0.85); border: 1px solid rgba(255, 255, 255, 0.2); }
@keyframes feedIn { from { opacity: 0; transform: translateY(-8px) scale(0.9); } }
@keyframes feedOut { to { opacity: 0; transform: translateY(-6px); } }

.tray { flex: none; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.tray-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { border: none; background: none; white-space: nowrap; padding: 7px 10px; border-radius: 10px; color: var(--muted); font-weight: 700; font-size: 14px; }
.tab.active { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.btn.anon { white-space: nowrap; padding: 7px 12px; font-size: 14px; border-radius: 12px; background: rgba(40, 40, 60, 0.8); }
.btn.anon b { background: rgba(255, 255, 255, 0.15); border-radius: 8px; padding: 0 6px; margin-left: 2px; }
.btn.anon.armed { background: #111; border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 0 20px rgba(160, 120, 255, 0.5); animation: pulse 0.6s infinite alternate; }
.tray-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; }
.ing {
  touch-action: none;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 5px 1px 4px;
  text-align: center;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
  color: var(--muted);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ing .e { display: block; font-size: 24px; line-height: 1.15; }
.ing.held { border-color: var(--yellow); background: rgba(255, 207, 90, 0.15); color: var(--text); }
.ing.chaos { background: rgba(160, 60, 255, 0.1); }
.tray-hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
@media (max-height: 700px) { .tray-hint { display: none; } }
.tray.disabled { opacity: 0.5; pointer-events: none; }

/* 집게 */
#tongs-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.tongs { position: absolute; left: 0; top: 0; will-change: transform; transition: transform 90ms linear; }
.tongs.me { transition: none; }
.tongs svg { display: block; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5)); }
.tongs .tag { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 10px; white-space: nowrap; color: #1b0d08; }
.tongs .held { position: absolute; left: 50%; top: 38px; transform: translateX(-50%); font-size: 28px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }
@media (pointer: fine) { #screen-play.cooking .pot-area, #screen-play.cooking .tray-grid { cursor: none; } }

/* 오버레이 */
.overlay { position: fixed; inset: 0; background: rgba(10, 4, 2, 0.75); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fadeIn 0.25s; }
.boil-box { text-align: center; }
.lid { font-size: 96px; animation: rattle 0.18s infinite alternate; }
@keyframes rattle { from { transform: rotate(-4deg) translateY(0); } to { transform: rotate(4deg) translateY(-6px); } }
.boil-text { font-family: var(--display); font-size: 30px; margin: 10px 0 6px; }

.mission-card {
  width: min(340px, 100%);
  background: linear-gradient(160deg, #3d2a10, #1e1206);
  border: 2px solid var(--yellow);
  border-radius: 22px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 207, 90, 0.2);
  animation: flip 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes flip { from { transform: rotateY(90deg) scale(0.8); opacity: 0; } }
.mc-top { color: var(--yellow); font-weight: 700; font-size: 14px; }
.mc-name { font-family: var(--display); font-size: 32px; margin: 12px 0 8px; }
.mc-desc { font-size: 16px; line-height: 1.5; margin-bottom: 14px; }
.mc-warn { font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.mission-card .btn { width: 100%; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: rgba(0, 0, 0, 0.85); padding: 10px 18px; border-radius: 20px; z-index: 200; font-size: 14px; animation: fadeIn 0.2s; max-width: 90vw; text-align: center; }

/* ── 영수증 ── */
.receipt-wrap { padding-bottom: 20px; }
.receipt {
  position: relative;
  background: #fbf8f1;
  color: #2b2118;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.55;
  padding: 26px 22px 30px;
  margin: 18px auto 26px;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: print 0.9s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes print { from { clip-path: inset(0 0 100% 0); transform: translateY(-20px); } to { clip-path: inset(0 0 0 0); } }
.receipt.saving { animation: none; }
.receipt::before, .receipt::after { content: ''; position: absolute; left: 0; right: 0; height: 8px; }
.receipt::before { top: -8px; background: radial-gradient(circle at 5px 0, transparent 5px, #fbf8f1 5.5px) 0 0 / 10px 8px repeat-x; }
.receipt::after { bottom: -8px; background: radial-gradient(circle at 5px 8px, transparent 5px, #fbf8f1 5.5px) 0 0 / 10px 8px repeat-x; }
.rc-head { text-align: center; }
.rc-shop { font-family: var(--display); font-size: 24px; color: #1b0d08; }
.rc-meta { font-size: 12px; color: #7a6a5c; }
.rc-hr { border: none; border-top: 1.5px dashed #b9a995; margin: 12px 0; }
.rc-title { display: flex; gap: 10px; align-items: center; }
.rc-swatch { width: 44px; height: 44px; border-radius: 50%; flex: none; border: 3px solid #2b2118; box-shadow: inset -4px -6px 10px rgba(0, 0, 0, 0.25), inset 4px 4px 8px rgba(255, 255, 255, 0.3); }
.rc-title-text { font-family: var(--display); font-size: 18px; line-height: 1.35; color: #1b0d08; }
.rc-stats { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12.5px; }
.rc-score { font-size: 15px; font-weight: 700; margin-top: 10px; display: flex; justify-content: space-between; }
.rc-table { width: 100%; border-collapse: collapse; }
.rc-table th { text-align: left; font-weight: 700; font-size: 12px; color: #7a6a5c; padding-bottom: 4px; }
.rc-table td { vertical-align: top; padding: 2px 0; }
.rc-table td.q { text-align: center; width: 36px; }
.rc-table td.who { text-align: right; font-size: 12.5px; }
.rc-reveal { color: #c0261b; font-weight: 700; }
.rc-sec { font-weight: 700; margin-bottom: 6px; }
.rc-ruin { display: grid; grid-template-columns: 64px 1fr 42px; gap: 6px; align-items: center; margin: 3px 0; font-size: 12.5px; }
.rc-ruin .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-ruin .bar { height: 10px; background: #ece3d6; border-radius: 2px; overflow: hidden; }
.rc-ruin .bar i { display: block; height: 100%; background: #2b2118; }
.rc-ruin .pct { text-align: right; }
.rc-award { display: flex; justify-content: space-between; gap: 8px; margin: 2px 0; }
.rc-award .nm { font-weight: 700; white-space: nowrap; }
.rc-mission { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; font-size: 12.5px; }
.rc-mission .md { color: #7a6a5c; font-size: 11.5px; }
.rc-verdict { text-align: center; font-weight: 700; margin: 4px 0; }
.rc-thanks { text-align: center; font-size: 12px; color: #7a6a5c; }
.rc-barcode { height: 40px; margin: 12px auto 4px; width: 80%; background: repeating-linear-gradient(90deg, #2b2118 0 2px, transparent 2px 4px, #2b2118 4px 5px, transparent 5px 8px, #2b2118 8px 11px, transparent 11px 12px); }
.rc-id { text-align: center; font-size: 11px; color: #7a6a5c; letter-spacing: 2px; }
.receipt-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; max-width: 400px; margin: 0 auto; }
.receipt-actions > .btn:not(.primary):not(.ghost) { padding: 12px 6px; font-size: 14px; white-space: nowrap; }
.receipt-actions .primary, .receipt-actions p, .receipt-actions .ghost { grid-column: 1 / -1; }
.receipt-actions p { margin: 4px 0; }

/* 영수증: 요리사별 정산 */
.rc-total { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rc-top { margin-top: 2px; }
.rc-sub { font-weight: 400; font-size: 11px; color: #7a6a5c; margin-left: 6px; }
.rc-person { padding: 9px 0; }
.rc-person + .rc-person { border-top: 1px dotted #cdbfae; }
.rc-p-head { display: flex; align-items: baseline; gap: 8px; }
.rc-p-name { font-weight: 700; white-space: nowrap; }
.rc-p-name .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.rc-p-award { font-size: 12px; color: #5b4c3f; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-p-ruin { font-weight: 700; }
.rc-p-bar { height: 6px; background: #ece3d6; border-radius: 3px; overflow: hidden; margin: 5px 0 2px; }
.rc-p-bar i { display: block; height: 100%; background: #2b2118; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rc-chip { display: inline-flex; align-items: center; gap: 1px; background: #f1ebe1; border-radius: 6px; padding: 1px 6px; font-size: 15px; line-height: 1.5; }
.rc-chip b { font-size: 11px; font-weight: 700; margin-left: 1px; }
.rc-chip.anon { background: #fde4e1; outline: 1.5px dashed #c0261b; outline-offset: -1.5px; }
.rc-chip.anon i { font-style: normal; font-size: 11px; margin-right: 1px; }
.rc-none { font-size: 12px; color: #7a6a5c; }
.rc-p-mission { font-size: 12px; margin-top: 5px; color: #5b4c3f; }
.rc-p-mission b { color: #2b2118; }
