:root {
  --bg: #0d0d0d;
  --bg-2: #171717;
  --line: #2b2b2b;
  --ink: #f4f1ea;
  --muted: #9b968c;
  --red: #ff2e3e;
  --red-dark: #b3121f;
  --yellow: #ffe500;
  --green: #2ee59d;
  --cyan: #26d9ff;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.logo { font-weight: 900; font-size: 22px; letter-spacing: 0; }
.logo b { color: var(--red); }
.wallet { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; white-space: nowrap; }
.pill.bp { color: var(--yellow); }
.pill.coin { color: var(--green); }
.pill.gear { cursor: pointer; padding: 5px 8px; }

main { flex: 1; padding: 16px 16px 96px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--muted); margin: 22px 0 10px; }

.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(4, 1fr); background: #111; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { background: none; border: 0; padding: 10px 0 12px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; }
.tabs button.on { color: var(--ink); }
.tabs button.on span { filter: drop-shadow(0 0 6px var(--red)); }

.btn { display: block; width: 100%; border: 0; border-radius: var(--radius); padding: 15px 16px; font-weight: 800; font-size: 16px; background: var(--bg-2); border: 1px solid var(--line); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.yellow { background: var(--yellow); border-color: var(--yellow); color: #111; }
.btn.ghost { background: none; }
.btn + .btn { margin-top: 10px; }
.btn.danger { background: none; border-color: var(--red-dark); color: var(--red); margin-top: 10px; }
.btn.small { display: inline-block; width: auto; padding: 8px 12px; font-size: 13px; }

.fight { position: relative; margin-top: 8px; padding: 28px 18px 22px; border: 2px solid var(--red); border-radius: var(--radius); background: repeating-linear-gradient(-45deg, #140707 0 14px, #0d0d0d 14px 28px); text-align: center; overflow: hidden; }
.fight h1 { margin: 0; font-size: 44px; font-weight: 900; line-height: 1; color: var(--ink); text-shadow: 3px 3px 0 var(--red-dark); }
.fight p { margin: 10px 0 18px; color: var(--muted); font-size: 14px; }
.fight .btn { font-size: 19px; padding: 17px; }
.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.record div { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-align: center; }
.record b { display: block; font-size: 20px; }
.record small { color: var(--muted); font-size: 12px; }

.items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item { position: relative; padding: 12px 6px 10px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--line); text-align: center; height: 88px; }
.item .em { font-size: 26px; display: block; }
.item .nm { font-size: 13px; font-weight: 800; margin-top: 4px; display: block; }
.item .qty { position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--muted); }
.item.on { border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow); }
.item.empty { opacity: .4; }
.equip-hint { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }

.judges { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.judge-chip { flex: 0 0 132px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.judge-chip .em { font-size: 30px; }
.judge-chip b { display: block; font-size: 14px; margin-top: 4px; }
.judge-chip small { color: var(--muted); font-size: 12px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.list-row .rank { width: 28px; font-weight: 900; color: var(--muted); text-align: center; }
.list-row .rank.top { color: var(--yellow); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row small { color: var(--muted); font-size: 12px; }

.product { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 8px; }
.product .grow { flex: 1; }
.product .grow small { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.product .price { min-width: 84px; padding: 10px; border-radius: var(--radius); border: 0; background: var(--yellow); color: #111; font-weight: 800; }
.product .price.coin { background: var(--green); }
.product.featured { border-color: var(--yellow); }

/* 배틀 화면 */
.battle { flex: 1; display: flex; flex-direction: column; padding: 14px 16px 16px; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.fighter { min-width: 0; }
.fighter b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fighter small { color: var(--muted); font-size: 12px; }
.fighter.right { text-align: right; }
.vs .mark { font-weight: 900; font-style: italic; font-size: 26px; color: var(--red); }
.effect-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; min-height: 20px; }
.fighter.right .effect-tags { justify-content: flex-end; }
.tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: #2a1a00; color: var(--yellow); }
.tag.hit { background: #2a0a0d; color: var(--red); }

.card { margin-top: 16px; border-radius: var(--radius); background: var(--ink); color: #111; padding: 18px; position: relative; }
.card .em { font-size: 34px; }
.card .target { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 800; background: #111; color: var(--yellow); padding: 3px 8px; border-radius: 4px; }
.card p { margin: 10px 0 0; font-size: 17px; line-height: 1.5; font-weight: 700; }
.card.compact { padding: 12px 14px; }
.card.compact .em { font-size: 22px; }
.card.compact p { font-size: 14px; margin-top: 4px; }
.card.reveal { animation: slam .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes slam { from { transform: scale(1.4) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }

.judge-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
.judge-bar .em { font-size: 28px; }
.judge-bar .grow { flex: 1; min-width: 0; }
.judge-bar small { color: var(--muted); font-size: 12px; display: block; }
.judge-bar button { border: 1px solid var(--yellow); background: none; color: var(--yellow); border-radius: var(--radius); padding: 8px 10px; font-size: 13px; font-weight: 800; }

.countdown { margin-top: 18px; text-align: center; font-size: 64px; font-weight: 900; color: var(--yellow); font-variant-numeric: tabular-nums; }
.timer { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.timer i { display: block; height: 100%; background: var(--yellow); transform-origin: left; }
.timer.danger i { background: var(--red); }
.timer-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.timer-row b { color: var(--ink); font-size: 18px; }

.writer { margin-top: 12px; position: relative; }
.writer textarea { width: 100%; min-height: 128px; resize: none; border-radius: var(--radius); border: 2px solid var(--line); background: #111; padding: 14px; font-size: 18px; line-height: 1.5; outline: none; }
.writer textarea:focus { border-color: var(--red); }
.writer .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.seal-badge { color: var(--red); font-weight: 800; }
.peek-box { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px dashed var(--cyan); color: var(--cyan); font-size: 14px; min-height: 44px; word-break: break-all; }
.typing { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 18px; }

.mom { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .78); padding: 24px; }
.mom-box { width: 100%; max-width: 360px; background: #fff3c4; color: #111; border-radius: var(--radius); padding: 22px; text-align: center; animation: shake .4s; }
.mom-box .em { font-size: 54px; }
.mom-box p { font-size: 19px; font-weight: 900; margin: 10px 0 16px; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-10px) rotate(-2deg); } 75% { transform: translateX(10px) rotate(2deg); } }

.judging { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.judging .em { font-size: 84px; animation: think 1s ease-in-out infinite; }
@keyframes think { 50% { transform: rotate(-8deg) scale(1.06); } }
.judging .lines { width: 100%; text-align: left; }
.quote { background: var(--bg-2); border-left: 3px solid var(--line); padding: 10px 12px; border-radius: 0 var(--radius) var(--radius) 0; margin-top: 8px; font-size: 15px; line-height: 1.5; word-break: break-all; }
.quote.mine { border-left-color: var(--yellow); }
.quote.theirs { border-left-color: var(--red); }
.quote small { display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }

.result-head { text-align: center; padding: 18px 0 6px; }
.result-head h1 { margin: 0; font-size: 56px; font-weight: 900; line-height: 1; }
.result-head.win h1 { color: var(--yellow); text-shadow: 3px 3px 0 var(--red-dark); }
.result-head.lose h1 { color: var(--muted); }
.result-head.draw h1 { color: var(--cyan); }
.result-head .delta { margin-top: 8px; font-size: 14px; color: var(--muted); }
.speech { position: relative; margin-top: 14px; padding: 14px; border-radius: var(--radius); background: var(--ink); color: #111; font-size: 15px; line-height: 1.55; font-weight: 600; }
.speech-who { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-weight: 800; }
.speech-who .em { font-size: 30px; }
.best { margin-top: 12px; font-size: 14px; color: var(--yellow); font-weight: 800; }
.scores { margin-top: 16px; display: grid; gap: 8px; }
.score-row { display: grid; grid-template-columns: 1fr 92px 1fr; align-items: center; gap: 8px; font-size: 12px; }
.score-row .lbl { text-align: center; color: var(--muted); }
.bar { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; display: flex; }
.bar.left { justify-content: flex-end; }
.bar i { display: block; height: 100%; }
.bar.left i { background: var(--yellow); }
.bar.right i { background: var(--red); }
.foul { margin-top: 10px; padding: 10px; border-radius: var(--radius); background: #2a0a0d; color: var(--red); font-weight: 800; font-size: 14px; }
.provisional { margin-top: 8px; font-size: 12px; color: var(--muted); }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.row-actions .btn + .btn { margin-top: 0; }
.link { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; margin-top: 14px; }

.onboard { padding: 32px 16px; }
.onboard h1 { font-size: 52px; margin: 18px 0 6px; font-weight: 900; line-height: 1; }
.onboard h1 b { color: var(--red); }
.onboard .lead { color: var(--muted); margin: 0 0 26px; line-height: 1.5; }
.field { width: 100%; padding: 15px; border-radius: var(--radius); border: 2px solid var(--line); background: #111; font-size: 17px; outline: none; }
.field:focus { border-color: var(--red); }
.field + .field, .field-label + .field { margin-top: 10px; }
.field-label { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
.field[type="date"] { color-scheme: dark; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--red); }
.rules { margin-top: 22px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; line-height: 1.6; color: var(--muted); }
.rules b { color: var(--ink); }

.queue { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 24px 16px; }
.queue .spinner { width: 76px; height: 76px; border: 6px solid var(--bg-2); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.queue h2 { margin: 0; font-size: 22px; }
.queue p { margin: 0; color: var(--muted); font-size: 14px; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; font-size: 14px; }
.history-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.history-item .head { display: flex; justify-content: space-between; font-size: 13px; }
.res-win { color: var(--yellow); font-weight: 900; }
.res-lose { color: var(--muted); font-weight: 900; }
.res-draw { color: var(--cyan); font-weight: 900; }

#toast { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #111; padding: 10px 16px; border-radius: var(--radius); font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--bg-2); border-radius: var(--radius); margin-bottom: 12px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 6px; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--red); color: #fff; }
.onboard .field + .field { margin-top: 10px; }
.tabs { grid-template-columns: repeat(5, 1fr); }
.my-tier { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--yellow); border-radius: var(--radius); background: var(--bg-2); }
.my-tier .em { font-size: 36px; }
.my-tier .grow { flex: 1; min-width: 0; }
.my-tier small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tier-ladder { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 10px; text-align: center; font-size: 22px; }
.tier-ladder span { padding: 6px 0; border-radius: 6px; opacity: .45; }
.tier-ladder span.on { opacity: 1; background: var(--bg-2); outline: 1px solid var(--yellow); }
.tier-ladder small { display: block; font-size: 10px; color: var(--muted); }
.list-row.locked { opacity: .45; }
.tier-up { margin-top: 12px; padding: 10px; border-radius: var(--radius); text-align: center; font-weight: 900; }
.tier-up.up { background: #2a2400; color: var(--yellow); }
.tier-up.down { background: var(--bg-2); color: var(--muted); }
.ach-pop { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius); background: #0d2a1f; color: var(--green); font-size: 14px; }
.onboard .btn.primary { margin-top: 14px; }
