:root {
  --main: #FF5A36; --main-d: #C93A1B; --ink: #2B2140; --cream: #FFF8EC; --gold: #FFD23F; --green: #34C27B; --blue: #2F9BFF; --red: #E5383B;
  --sans: "Pretendard Variable", Pretendard, -apple-system, system-ui, sans-serif;
  --disp: "Bagel Fat One", "Pretendard Variable", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #BFE6F5; color: var(--ink); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
body { touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; word-break: keep-all; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 700 12px/1 var(--sans); background: #fff; border: 1px solid #E3D6C2; border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; margin: 0 1px; }

/* 화면들 */
.screen { position: fixed; inset: 0; display: none; place-items: safe center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); z-index: 20; background: radial-gradient(120% 90% at 50% 10%, rgba(43,33,64,.12), rgba(43,33,64,.5)); overflow: auto; }
.screen.show { display: grid; }
.card, .title-card, .load-card { background: var(--cream); border-radius: 24px; box-shadow: 0 20px 60px rgba(43,33,64,.35), inset 0 0 0 1px rgba(255,255,255,.7); padding: 26px 22px; width: min(440px, 100%); text-align: center; }
h2 { margin: 0 0 14px; font: 400 30px/1.1 var(--disp); }

#loading { background: linear-gradient(180deg, #FFB86B, #FFE3B0 60%, #FFF8EC); }
.load-title { font: 400 44px/1 var(--disp); white-space: nowrap; color: var(--main); }
.load-bar { height: 10px; background: #F1E3CC; border-radius: 99px; overflow: hidden; margin: 18px 0 10px; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--main), var(--gold)); transition: width .2s; }
#loadText { margin: 0; color: #6B5F7A; font-size: 14px; }

#title { background: linear-gradient(180deg, rgba(43,33,64,.02), rgba(43,33,64,.42)); }
.title-card { width: min(460px, 100%); padding: 20px 20px 16px; }
.brand-row { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; font-size: 15px; background: #fff; padding: 6px 14px 6px 10px; border-radius: 99px; box-shadow: 0 2px 10px rgba(43,33,64,.12); }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--main); }
.brand-sub { font-weight: 600; color: #8A7F99; font-size: 13px; }
h1 { margin: 12px 0 4px; line-height: 1; }
h1 .t1 { display: block; white-space: nowrap; font: 400 clamp(40px, 12.5vw, 68px)/1.05 var(--disp); color: var(--main); text-shadow: 0 4px 0 var(--main-d), 0 10px 24px rgba(255,90,54,.3); }
h1 .t2 { display: block; font-weight: 900; font-size: 18px; margin-top: 12px; }
.lead { margin: 8px auto 14px; max-width: 26em; color: #54496B; font-size: 15px; line-height: 1.55; }
.big-btn { display: block; width: 100%; border: 0; border-radius: 18px; padding: 13px 16px; color: #fff; background: linear-gradient(180deg, #FF7A52, var(--main)); box-shadow: 0 6px 0 var(--main-d), 0 12px 24px rgba(255,90,54,.3); margin: 6px 0 14px; transition: transform .08s, box-shadow .08s; }
.big-btn b { display: block; font-weight: 900; font-size: 21px; }
.big-btn span { display: block; font-size: 13px; font-weight: 600; opacity: .92; margin-top: 2px; }
.big-btn.alt { background: linear-gradient(180deg, #4FD397, #25A866); box-shadow: 0 6px 0 #1A7F4C, 0 12px 24px rgba(37,168,102,.3); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--main-d); }
.big-btn.alt:active { box-shadow: 0 2px 0 #1A7F4C; }
.big-btn:focus-visible, .ghost-btn:focus-visible, .round-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.ghost-btn { display: block; width: 100%; border: 1.5px solid #E6D8C1; background: #fff; border-radius: 14px; padding: 12px; font-weight: 800; font-size: 15px; margin-top: 8px; text-decoration: none; color: var(--ink); }
.ghost-btn:empty { display: none; }
.howto { text-align: left; background: #fff; border-radius: 14px; padding: 10px 14px; font-size: 13px; color: #453A5C; }
.howto summary { font-weight: 800; cursor: pointer; }
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.howto ul { margin: 6px 0 0; padding-left: 16px; line-height: 1.7; }
.tips { border-top: 1px dashed #E6D8C1; padding-top: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; }
.dot.red { background: var(--red); } .dot.green { background: var(--green); } .dot.blue { background: var(--blue); }
.round { margin: -6px 0 12px; font-weight: 800; font-size: 13px; color: #54496B; min-height: 1.2em; }
.best { margin: 0 0 10px; font-weight: 800; color: var(--main-d); font-size: 14px; min-height: 1.2em; }
.fine { margin: 10px 0 0; font-size: 11.5px; color: #8A7F99; line-height: 1.6; }
.fine a { color: inherit; }
@media (max-width: 420px) { .howto-grid { grid-template-columns: 1fr; } }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
body.playing #hud { display: block; }
.hud-time { position: absolute; left: calc(12px + var(--safe-l)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; align-items: flex-start; }
.hud-time b { font: 400 34px/1 var(--disp); color: #fff; text-shadow: 0 2px 0 rgba(43,33,64,.7), 0 0 12px rgba(43,33,64,.35); font-variant-numeric: tabular-nums; }
.hud-time span { font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(43,33,64,.8); margin-top: 2px; }
.hud-time.hurry b { color: #FFE14D; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }
.hud-size { position: absolute; left: 50%; top: calc(10px + var(--safe-t)); transform: translateX(-50%); width: min(150px, 37vw); background: rgba(43,33,64,.72); border-radius: 14px; padding: 6px 10px 8px; color: #fff; }
.size-row { display: flex; align-items: baseline; gap: 5px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.size-row b { font: 400 22px/1 var(--disp); color: var(--gold); }
.size-row em { font-style: normal; opacity: .85; overflow: hidden; text-overflow: ellipsis; }
.gauge { height: 8px; background: rgba(255,255,255,.22); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.gauge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #FF9A3D); border-radius: 99px; transition: width .15s; }
.theme-tag { margin-top: 5px; font-size: 10px; font-weight: 800; text-align: center; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-size.grew { animation: sizepop .5s; }
@keyframes sizepop { 30% { transform: translateX(-50%) scale(1.18); } }
.hud-btns { position: absolute; right: calc(10px + var(--safe-r)); top: calc(10px + var(--safe-t)); display: flex; gap: 6px; pointer-events: auto; }
.round-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(43,33,64,.72); color: #fff; font-weight: 900; font-size: 16px; display: grid; place-items: center; }
.round-btn.off { color: rgba(255,255,255,.4); text-decoration: line-through; }
.board { position: absolute; left: calc(10px + var(--safe-l)); top: calc(66px + var(--safe-t)); margin: 0; padding: 5px 6px; list-style: none; background: rgba(43,33,64,.6); border-radius: 12px; color: #fff; font-size: 12px; font-weight: 700; min-width: 124px; }
.board:empty { display: none; }
.board li { display: flex; align-items: center; gap: 5px; padding: 2px 3px; border-radius: 6px; white-space: nowrap; }
.board li.me { background: rgba(255,255,255,.22); }
.board li.out { opacity: .45; }
.board .n { width: 12px; text-align: center; opacity: .8; }
.board .c { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.board .nm { flex: 1; }
.board .s { font-variant-numeric: tabular-nums; opacity: .9; }
.effects { position: absolute; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; }
.fx-chip { background: rgba(43,33,64,.78); color: #fff; font-size: 12px; font-weight: 800; border-radius: 99px; padding: 6px 12px 6px 8px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.fx-chip i { width: 10px; height: 10px; border-radius: 50%; }
.combo { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); font: 400 30px/1 var(--disp); color: var(--gold); text-shadow: 0 3px 0 rgba(43,33,64,.75); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.combo.on { opacity: 1; }
.combo.bump { animation: bump .18s; }
@keyframes bump { 50% { transform: translateX(-50%) scale(1.25); } }
.center-msg { position: absolute; left: 50%; top: 33%; transform: translate(-50%, -50%); text-align: center; font: 400 clamp(34px, 10vw, 54px)/1.1 var(--disp); color: #fff; text-shadow: 0 4px 0 rgba(43,33,64,.8), 0 0 24px rgba(43,33,64,.4); opacity: 0; white-space: nowrap; }
.center-msg small { display: block; font: 800 15px/1.4 var(--sans); margin-top: 6px; text-shadow: 0 1px 3px rgba(43,33,64,.9); }
.center-msg.show { animation: msg 1.6s forwards; }
@keyframes msg { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 20% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
.toast { position: absolute; left: 50%; bottom: calc(64px + var(--safe-b)); transform: translateX(-50%); background: rgba(43,33,64,.82); color: #fff; font-size: 14px; font-weight: 800; border-radius: 99px; padding: 9px 16px; opacity: 0; transition: opacity .25s; white-space: nowrap; max-width: 92vw; }
.toast.show { opacity: 1; }
.drag-hint { position: absolute; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); margin: 0; background: #fff; color: var(--ink); font-weight: 800; font-size: 15px; border-radius: 99px; padding: 10px 18px; box-shadow: 0 6px 18px rgba(43,33,64,.25); white-space: nowrap; transition: opacity .3s; }
.drag-hint.hide { opacity: 0; }
.pointer { position: absolute; left: 0; top: 0; width: 0; height: 0; border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 26px solid var(--gold); filter: drop-shadow(0 2px 2px rgba(43,33,64,.7)); display: none; }
.label { position: absolute; left: 0; top: 0; font-size: 11px; font-weight: 800; color: #fff; background: rgba(43,33,64,.7); border-radius: 99px; padding: 2px 8px; white-space: nowrap; will-change: transform; }
.label.me { background: var(--main); }
.pop { position: absolute; left: 0; top: 0; font: 400 20px/1 var(--disp); color: #fff; text-shadow: 0 2px 0 rgba(43,33,64,.8); opacity: 0; will-change: transform, opacity; white-space: nowrap; }
.pop.brand { color: var(--gold); font-size: 26px; }
.pop.go { animation: popup .7s ease-out forwards; }
@keyframes popup { 0% { opacity: 0; margin-top: 0; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -46px; } }

/* 끌기 표시 */
#stick { position: fixed; left: -56px; top: -56px; width: 112px; height: 112px; border-radius: 50%; border: 3px solid rgba(255,255,255,.75); background: rgba(255,255,255,.14); display: none; z-index: 11; pointer-events: none; }
#stick i { position: absolute; left: 31px; top: 31px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.88); box-shadow: 0 2px 8px rgba(43,33,64,.35); }

/* 결과 */
.result-card { padding: 22px 20px 18px; }
.r-kicker { margin: 0; font-weight: 900; color: var(--main); letter-spacing: .08em; font-size: 14px; }
#resultH { margin: 2px 0 0; font: 400 72px/1 var(--disp); color: var(--ink); }
#resultH small { font-size: 30px; margin-left: 2px; }
.r-sub { margin: 4px 0 12px; color: #54496B; font-size: 14px; font-weight: 700; }
.r-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.r-stats div { background: #fff; border-radius: 14px; padding: 10px 4px 8px; }
.r-stats b { display: block; font: 400 26px/1 var(--disp); color: var(--main); }
.r-stats span { display: block; font-size: 12px; color: #6B5F7A; font-weight: 700; margin-top: 4px; }
.r-best { margin: 10px 0 8px; font-weight: 800; font-size: 14px; color: var(--main-d); min-height: 1.2em; }
.r-table { list-style: none; margin: 0 0 10px; padding: 6px 8px; background: #fff; border-radius: 14px; font-size: 14px; font-weight: 700; text-align: left; }
.r-table:empty { display: none; }
.r-table li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.r-table li.me { background: #FFE9DF; }
.r-table .n { width: 16px; text-align: center; color: #8A7F99; }
.r-table .c { width: 11px; height: 11px; border-radius: 50%; }
.r-table .nm { flex: 1; }
.r-table .s { font-variant-numeric: tabular-nums; color: #54496B; }
.ad-slot { margin: 6px 0 10px; min-height: 100px; background: #fff; border-radius: 12px; position: relative; overflow: hidden; }
.ad-label { position: absolute; left: 6px; top: 4px; font-size: 10px; color: #8A7F99; }
.noscript { position: fixed; inset: auto 0 0 0; margin: 0; padding: 14px; background: var(--ink); color: #fff; text-align: center; z-index: 99; }

@media (min-width: 720px) {
  .board { font-size: 13px; min-width: 150px; }
  .hud-size { width: 200px; }
}
@media (max-height: 520px) {
  .title-card { padding: 14px 18px 12px; }
  h1 .t1 { font-size: 40px; }
  .lead { display: none; }
  .round { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .hud-time.hurry b, .combo.bump, .hud-size.grew { animation: none; }
}
