/* 타자 대모험 화면 (게임만의 모양: 연보라 하늘 + 동글동글) */
:root { --bg: #eef0ff; --ink: #24264f; --sub: #5d6088; --main: #6b5cff; --main2: #8c7dff; --ok: #12a150; --bad: #e03131; --pend: #ff8a00; --card: #fff; --line: #dfe2fb; --vh: 100vh; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Pretendard, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; background: radial-gradient(circle at 20% 0%, #fff6d8 0, transparent 40%), linear-gradient(#e4e8ff, var(--bg)); color: var(--ink); min-height: 100vh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; max-width: 760px; margin: 0 auto; }
.top h1 { font-size: 18px; margin: 0; font-weight: 900; white-space: nowrap; }
.screen { max-width: 760px; margin: 0 auto; padding: 0 16px 32px; }

/* 처음 화면 */
.hero { text-align: center; padding: 12px 0 4px; }
.title-word { margin: 0; font-size: clamp(36px, 10vw, 60px); font-weight: 900; letter-spacing: -1px; background: linear-gradient(90deg, #6b5cff, #ff6b9a 60%, #ffb020); -webkit-background-clip: text; background-clip: text; color: transparent; }
.title-sub { margin: 4px 0 8px; color: var(--sub); font-weight: 700; }
.badge { margin: 0 auto; display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 15px; min-height: 20px; }
.badge:empty { display: none; }
.badge .tt { font-weight: 900; color: var(--main); }
.phone-note { text-align: center; background: #fff8e1; border: 1px solid #ffe08a; border-radius: 12px; padding: 8px 10px; font-size: 14px; margin: 10px 0 0; }
.lang { display: flex; justify-content: center; gap: 8px; margin: 14px 0 10px; }
.lang-b { min-height: 44px; min-width: 110px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font-weight: 800; padding: 0 16px; }
.lang-b.on { background: var(--main); color: #fff; border-color: var(--main); }
.modes { display: grid; gap: 10px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 14px 18px; min-height: 72px; border-radius: 20px; border: 0; color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); transition: transform .08s; }
.mode:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .12); }
.mode b { font-size: 21px; font-weight: 900; }
.mode small { font-size: 14px; opacity: .95; font-weight: 600; }
.m-def { background: linear-gradient(120deg, #43c27a, #2ea7a0); }
.m-race { background: linear-gradient(120deg, #6b5cff, #a35cff); }
.m-daily { background: linear-gradient(120deg, #ff8a3d, #ff5c8a); }
.howto { margin-top: 14px; background: #fff; border-radius: 16px; border: 1px solid var(--line); padding: 4px 14px; }
.howto summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }
.howto ul { margin: 0 0 10px; padding-left: 18px; line-height: 1.6; font-size: 14.5px; }
.gear { text-align: center; color: var(--sub); font-size: 13.5px; }

/* 위 막대 (지도·경주 고르기) */
.bar { display: flex; align-items: center; gap: 10px; padding: 12px 0; position: sticky; top: 0; background: linear-gradient(var(--bg) 80%, transparent); z-index: 2; }
.bar h2 { margin: 0; font-size: 19px; flex: 1; min-width: 0; }
.stars-total { font-weight: 800; color: #c48a00; white-space: nowrap; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* 지도 */
.world { margin: 8px 0 18px; }
.world h3 { margin: 0 0 8px; font-size: 17px; }
.world h3 small { color: var(--sub); font-weight: 600; font-size: 13px; }
.stg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.stg { min-height: 84px; border-radius: 16px; border: 2px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; }
.stg b { font-size: 20px; font-weight: 900; color: var(--main); }
.stg .nm { font-size: 12px; line-height: 1.2; text-align: center; word-break: keep-all; color: var(--ink); }
.stg .st { font-size: 13px; color: #c48a00; letter-spacing: 1px; }
.stg.done { border-color: #ffd36b; background: #fffaf0; }
.stg.k-boss { background: #f3efff; }
.stg.lock { opacity: .55; background: #f4f5fb; }

/* 경주 상대 */
.rivals { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.rival { min-height: 110px; border-radius: 18px; border: 2px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.rival .re { font-size: 38px; }
.rival b { font-size: 17px; }
.rival small { color: var(--sub); font-size: 13px; text-align: center; padding: 0 6px; }
.rival.ghost { background: #f5f3ff; }
.rival.lock { opacity: .6; }
.center { text-align: center; }

/* 판 화면 */
body.playing { overflow: hidden; }
#play { position: fixed; inset: 0; height: var(--vh); max-width: none; padding: 0; display: flex; flex-direction: column; background: var(--bg); }
.hud { display: flex; align-items: center; gap: 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--line); flex: none; }
.hud-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.hud-mid b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.hud-mid small { color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; }
#defView { position: relative; flex: 1; min-height: 0; }
#cv { display: block; width: 100%; height: 100%; }
.hearts { position: absolute; left: 8px; top: 8px; font-size: 18px; letter-spacing: 1px; pointer-events: none; }
.hearts .off { filter: grayscale(1); opacity: .35; }
.boss-n { background: rgba(255, 255, 255, .85); border-radius: 10px; padding: 2px 8px; font-size: 14px; font-weight: 800; }
.combo { position: absolute; right: 10px; top: 8px; font-weight: 900; font-size: 22px; color: #ff6b00; text-shadow: 0 2px 0 #fff; opacity: 0; pointer-events: none; }
.combo.on { animation: pop .9s ease-out; }
@keyframes pop { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.15); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

#typeView { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; max-width: 820px; width: 100%; margin: 0 auto; }
.track { display: flex; flex-direction: column; gap: 8px; }
.lane { display: flex; align-items: center; gap: 8px; }
.lane .ln { width: 64px; font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.road { position: relative; flex: 1; height: 40px; border-radius: 12px; background: repeating-linear-gradient(90deg, #cfd6c4 0 18px, #c2caB6 18px 36px); border: 2px solid #b6bea8; overflow: hidden; }
.lane.rv .road { background: repeating-linear-gradient(90deg, #d7d2f0 0 18px, #cbc5ea 18px 36px); border-color: #b9b2e0; }
.runner { position: absolute; top: 2px; font-size: 28px; line-height: 32px; width: 34px; text-align: center; transform: scaleX(-1); }
.flag { position: absolute; right: 2px; top: 6px; font-size: 20px; opacity: .8; }
.sentence { background: #fff; border-radius: 18px; border: 2px solid var(--line); padding: 16px; font-size: clamp(20px, 5.4vw, 30px); line-height: 1.6; font-weight: 700; word-break: keep-all; overflow-wrap: anywhere; letter-spacing: .5px; }
.sentence .c { border-radius: 4px; }
.sentence .ok { color: var(--ok); }
.sentence .bad { color: #fff; background: var(--bad); }
.sentence .pend { color: var(--pend); text-decoration: underline; text-underline-offset: 5px; }
.sentence .todo { color: #8a8db0; }
.sentence .cur { box-shadow: inset 0 -3px 0 var(--main); color: var(--ink); }
.live { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; color: var(--sub); font-size: 15px; font-variant-numeric: tabular-nums; }
.live b { color: var(--ink); font-size: 19px; }

.inbar { display: flex; gap: 6px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); flex: none; max-width: 820px; width: 100%; margin: 0 auto; }
#in { flex: 1; min-width: 0; height: 52px; border-radius: 14px; border: 3px solid var(--main2); padding: 0 14px; font: inherit; font-size: 22px; font-weight: 700; color: var(--ink); background: #fbfbff; outline: none; }
#in:focus { border-color: var(--main); box-shadow: 0 0 0 4px rgba(107, 92, 255, .18); }
#in.miss { border-color: var(--bad); background: #fff5f5; }
#in.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.go { width: 56px; height: 52px; border-radius: 14px; border: 0; background: var(--main); color: #fff; font-size: 22px; font-weight: 900; flex: none; }
.ime-tip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); margin: 0; background: #24264f; color: #fff; padding: 8px 14px; border-radius: 12px; font-size: 14px; font-weight: 700; max-width: calc(100% - 32px); text-align: center; z-index: 5; }
.count { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 84px; font-weight: 900; color: var(--main); text-shadow: 0 4px 0 #fff; pointer-events: none; z-index: 6; }

/* 결과 창 */
.res-big { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px 0; }
.res-big > b { font-size: 44px; font-weight: 900; color: var(--main); }
.res-stars { font-size: 44px; color: #ffbf1f; letter-spacing: 4px; }
.res-stars i { color: #d9dbe8; font-style: normal; }
.res-emoji { font-size: 50px; }
.res-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.res-row span { display: flex; flex-direction: column; align-items: center; background: #f4f5ff; border-radius: 12px; padding: 6px 12px; font-size: 12.5px; color: var(--sub); min-width: 70px; }
.res-row b { font-size: 19px; color: var(--ink); }
.res-new { display: inline-block; background: #ffd43b; color: #5c3d00; border-radius: 999px; padding: 3px 12px; font-weight: 900; font-size: 14px; margin-top: 4px; }
.res-title { font-size: 17px; margin-top: 4px; }
.res-actions { flex-wrap: wrap; }

@media (pointer: coarse) { .round { width: 46px; height: 46px; } }
@media (max-width: 400px) {
  .top h1 { font-size: 16px; }
  .mode b { font-size: 19px; }
  .lane .ln { width: 48px; }
  #in { font-size: 20px; }
}
.res-actions .kit-btn { white-space: nowrap; }

/* 📈 내 실력 */
.skill-b { width: 100%; margin-top: 10px; min-height: 56px; border-radius: 18px; border: 2px solid var(--line); background: #fff; font-weight: 900; font-size: 17px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 8px; padding: 8px 12px; }
.skill-b small { font-weight: 600; color: var(--sub); font-size: 13px; }
.sk-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; margin-bottom: 12px; }
.sk-card h3 { margin: 0 0 10px; font-size: 17px; }
.sk-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.sk-nums span { background: #f4f5ff; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; font-size: 13px; color: var(--sub); }
.sk-nums b { font-size: 20px; color: var(--ink); }
.sk-trend { text-align: center; margin: 10px 0 4px; }
.sk-chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.sk-legend { text-align: center; font-size: 13px; margin: 4px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; }
.sk-empty { color: var(--sub); text-align: center; margin: 10px 0; }
.sk-top { margin: 0 0 6px; padding-left: 22px; line-height: 1.8; }
.sk-top b { color: var(--bad); font-size: 18px; }
.sk-kb { display: flex; flex-direction: column; gap: 5px; }
.sk-row { display: flex; gap: 4px; }
.sk-key { position: relative; flex: 1 1 0; min-width: 0; max-width: 56px; aspect-ratio: 1 / 1.05; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid rgba(0, 0, 0, .08); }
.sk-key b { font-size: clamp(13px, 4vw, 20px); }
.sk-key small { font-size: 10px; color: #6b6e90; }
.sk-key i { position: absolute; top: -6px; right: -4px; background: var(--bad); color: #fff; font-style: normal; font-size: 10px; font-weight: 800; border-radius: 999px; padding: 0 4px; min-width: 16px; text-align: center; }
.sk-key.home::after { content: ''; position: absolute; bottom: 2px; width: 12px; height: 2px; border-radius: 2px; background: #24264f; }
.sk-key.space { max-width: none; aspect-ratio: auto; height: 36px; margin: 0 18%; background: #f1f3f5; font-size: 13px; color: var(--sub); }
.sk-legend2 { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 10px 0 4px; font-size: 12.5px; }
.sk-legend2 i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0, 0, 0, .1); }
.sk-tips { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; font-size: 14.5px; }
