@font-face {
  font-family: 'S-CoreDream-3Light';
  src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/S-CoreDream-3Light.woff') format('woff');
  font-weight: normal; font-style: normal; font-display: swap;
}
:root {
  --bg: #0d0720; --bg2: #1b0f3d; --panel: #241552; --ink: #fff; --dim: #9a91c8;
  --yellow: #ffe135; --pink: #ff3b8d; --orange: #ff9a1f; --green: #3ddc6b; --red: #ff3b3b; --cyan: #35c8ff;
  --font: "S-CoreDream-3Light", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; /* 메인 페이지와 같은 글꼴 */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, var(--bg2), var(--bg) 70%) fixed; color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5; overflow-x: hidden; image-rendering: pixelated;
}
body::after { /* CRT 스캔라인 */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 900;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.14) 0 1px, transparent 1px 3px);
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar { position: absolute; top: 100px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 8px 16px; z-index: 50; }
#app { min-height: 100vh; padding: 156px 24px 31px; display: flex; justify-content: center; }
#screen { width: 100%; max-width: 1180px; }
.screen { display: flex; flex-direction: column; gap: 20px; align-items: center; }

/* 버튼·패널: 픽셀 테두리 */
.btn {
  background: var(--panel); border: 3px solid var(--yellow); padding: 8px 16px; cursor: pointer; font-weight: 700;
  box-shadow: 4px 4px 0 #000; transition: transform .05s; border-radius: 0;
}
.btn:hover:not(:disabled) { background: #3a2380; }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-big { font-size: 22px; padding: 12px 36px; background: var(--pink); border-color: #fff; }
.btn-big:hover:not(:disabled) { background: #ff5fa3; }
.btn-ghost { background: transparent; border-color: var(--dim); box-shadow: none; font-size: 14px; }
.panel { background: var(--panel); border: 4px solid var(--cyan); box-shadow: 6px 6px 0 #000; padding: 24px; display: flex; flex-direction: column; gap: 12px; width: min(520px, 100%); }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.row.space { justify-content: space-between; width: 100%; align-items: center; }
.note { color: var(--dim); margin: 0; font-size: 14px; }
.form-msg { color: var(--pink); min-height: 1.5em; margin: 0; font-weight: 700; }

/* S1 */
.logo { font-size: clamp(48px, 9vw, 96px); margin: 40px 0 0; letter-spacing: -2px; color: var(--yellow); text-shadow: 4px 4px 0 var(--pink), 8px 8px 0 #000; }
.logo em { color: var(--cyan); font-style: normal; }
.tagline { color: var(--dim); margin: 0; }
.nick-row { display: flex; gap: 8px; }
.nick-input { flex: 1; min-width: 0; background: #0d0720; border: 3px solid var(--dim); padding: 10px 12px; font-size: 20px; }
.nick-input:focus { border-color: var(--yellow); outline: none; }

/* S2 (모드 선택 카드는 더 이상 쓰지 않음) */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; width: 100%; }
.mode-card { background: var(--panel); border: 4px solid var(--yellow); box-shadow: 6px 6px 0 #000; padding: 28px 20px; display: flex; flex-direction: column; gap: 10px; text-align: left; cursor: pointer; border-radius: 0; min-height: 220px; }
.mode-card:hover { background: #3a2380; transform: translateY(-4px); }
.mode-card strong { font-size: 26px; color: var(--orange); }
.mode-card span { color: var(--dim); }
.mode-tag { font-size: 13px; color: var(--cyan) !important; letter-spacing: 3px; }

/* S3 플레이 */
.play-screen { align-items: stretch; }
.play { display: flex; flex-direction: column; gap: 16px; position: relative; min-height: 0; }
.hud { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hud > div { background: var(--panel); border: 3px solid var(--dim); padding: 6px 18px; min-width: 120px; text-align: center; display: flex; flex-direction: column; }
.hud span { font-size: 12px; color: var(--dim); }
.hud b { font-size: 28px; color: var(--yellow); display: inline-block; }
.hud .mult { color: var(--orange); }
.play-main { display: flex; gap: 16px; flex: 1; align-items: stretch; }
.arena { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-height: max(240px, calc((100vh - 370px) * .8)); } /* 높이를 이전보다 20% 줄임 */
.gauges { display: flex; gap: 32px; width: 100%; padding: 0 24px; }
.gauge-block { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.gauge-label { font-weight: 700; color: var(--cyan); }
.gauge { position: relative; height: 64px; background: #05030f; border: 5px solid #fff; box-shadow: 5px 5px 0 #000; overflow: hidden; }
.gauge-fill { height: 100%; width: 0; background: var(--green); transition: width .06s linear, background .2s; }
.gauge-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; font-weight: 900; text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; }
.stage-row { display: flex; gap: 14px; align-items: baseline; justify-content: center; flex-wrap: wrap; }
.stage-name { font-size: 22px; font-weight: 900; border: 3px solid currentColor; padding: 0 10px; }
.stage-text { font-size: 22px; transition: opacity .15s; }
.stage-text.fading { opacity: 0; }
.hint { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 30px; color: var(--yellow); animation: blink 1s steps(2) infinite; pointer-events: none; }
.hint.gone { display: none; }
@keyframes blink { 50% { opacity: .2; } }
.mini-rank { width: 240px; background: var(--panel); border: 3px solid var(--dim); padding: 12px; align-self: flex-start; }
.mini-rank h3 { margin: 0 0 8px; font-size: 16px; color: var(--cyan); }
.mini-rank ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mini-rank li { display: grid; grid-template-columns: 44px 1fr auto; gap: 6px; font-size: 14px; padding: 3px 6px; }
.mini-rank li.me { background: var(--pink); font-weight: 900; }
.mini-rank .nick, .rank-row .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* S4 */
.lobby-body { align-items: center; text-align: center; }
.or { color: var(--dim); }
.code-input { text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.room-code { display: flex; flex-direction: column; }
.room-code strong { font-size: 56px; letter-spacing: 10px; color: var(--yellow); }
.players { list-style: none; padding: 0; margin: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.players li { display: flex; gap: 8px; justify-content: space-between; background: #0d0720; padding: 8px 12px; border: 2px solid var(--dim); }
.players li.off { opacity: .5; }
.players em { font-style: normal; color: var(--green); }
.status { font-size: 20px; color: var(--orange); margin: 0; min-height: 1.5em; }

/* S6 */
.result-grid { display: grid; grid-template-columns: 360px 1fr; gap: 32px; align-items: start; width: 100%; max-width: 900px; }
.card-canvas { width: 360px; height: 480px; image-rendering: auto; border: 4px solid #000; box-shadow: 6px 6px 0 #000; }
.result-info { display: flex; flex-direction: column; gap: 16px; }
.big-rp small { display: block; color: var(--dim); }
.big-rp strong { font-size: 64px; color: var(--orange); line-height: 1; }
.big-rp em { display: block; color: var(--green); font-style: normal; }
.rank-line { font-size: 30px; color: var(--yellow); }
.rank-list { list-style: none; padding: 0; margin: 0; display: flex; gap: 20px; flex-wrap: wrap; }
.rank-list b { color: var(--cyan); font-size: 20px; }
.title-chip { background: var(--pink); padding: 4px 12px; border: 3px solid #fff; margin-right: 8px; display: inline-block; }
.battle-result { border: 5px solid; padding: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--panel); }
.battle-result strong { font-size: 40px; }
.battle-result p { font-size: 24px; margin: 4px 0; }
.battle-result.win { border-color: var(--yellow); color: var(--yellow); }
.battle-result.lose { border-color: var(--red); color: #ff8a8a; }
.battle-result.draw { border-color: var(--cyan); }
.battle-result small { color: var(--dim); }
.badge-pop { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); background: var(--yellow); color: #000; border: 5px solid #000; padding: 16px 36px; text-align: center; z-index: 700; box-shadow: 8px 8px 0 var(--pink); animation: popin .4s steps(6); display: flex; flex-direction: column; }
.badge-pop strong { font-size: 30px; }

/* S7 */
.ranking { align-items: stretch; width: 100%; max-width: 820px; margin: 0 auto; padding-bottom: 90px; }
.tabs-box { display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; }
.tabs { display: flex; }
.tab { background: var(--panel); border: 3px solid var(--dim); padding: 6px 18px; cursor: pointer; border-radius: 0; margin-right: -3px; }
.tab.on { background: var(--yellow); color: #000; border-color: #fff; font-weight: 900; }
.season-banner { background: var(--pink); border: 4px solid #fff; padding: 10px; text-align: center; font-weight: 900; font-size: 20px; }
.rank-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-row { display: grid; grid-template-columns: 56px 1fr 120px 120px; gap: 10px; align-items: center; background: var(--panel); border: 3px solid #3a2a7e; padding: 8px 12px; }
.rank-row.me { border-color: var(--pink); background: #3f1a5a; }
.rank-row .rk { font-size: 22px; text-align: center; }
.rank-row .rp { color: var(--orange); text-align: right; font-size: 20px; }
.rank-row .at { color: var(--dim); font-size: 13px; text-align: right; }
.rise { color: var(--green); font-style: normal; margin-left: 10px; font-weight: 900; animation: blink .5s steps(2) 4; }
.empty { text-align: center; color: var(--dim); padding: 30px; }
.my-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--pink); border-top: 5px solid #fff; padding: 12px 24px; display: flex; gap: 28px; justify-content: center; align-items: center; z-index: 60; font-size: 20px; }
.my-bar em { font-style: normal; color: var(--yellow); }

/* 설정 모달 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 800; }
.modal-box { background: var(--panel); border: 4px solid var(--yellow); box-shadow: 8px 8px 0 #000; padding: 24px; width: min(480px, 92vw); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-box h2 { margin: 0; }
.set-list { display: flex; flex-direction: column; gap: 6px; }
.set-row { display: flex; gap: 12px; align-items: center; cursor: pointer; padding: 4px 0; }
.set-row input { width: 22px; height: 22px; accent-color: var(--pink); }
.set-row small { display: block; color: var(--dim); }
.boss-guide { border-top: 2px dashed var(--dim); padding-top: 10px; }
.boss-guide p { margin: 4px 0 0; color: var(--dim); }

#toasts { position: fixed; top: 156px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 850; align-items: flex-end; }
.toast { background: var(--yellow); color: #000; border: 4px solid #000; padding: 10px 16px; box-shadow: 4px 4px 0 var(--pink); font-weight: 700; animation: popin .3s steps(5); max-width: 380px; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.toast, .badge-pop { }
.badge-pop { transform-origin: center; }

.error p { color: var(--dim); }

/* 모드 전환 버튼 (가상 키보드 자리) */
.mode-nav { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; padding: 8px 0 21px; }
.mode-btn { background: var(--panel); border: 4px solid var(--dim); box-shadow: 5px 5px 0 #000; padding: 14px 28px; font-size: 20px; font-weight: 700; cursor: pointer; border-radius: 0; min-width: 190px; }
.mode-btn:hover { background: #3a2380; }
.mode-btn.on { background: var(--yellow); color: #000; border-color: #fff; cursor: default; }
.mode-btn.rank-btn { border-color: var(--cyan); min-width: 0; }

/* 단어 타이핑 */
.gauges { flex-direction: column; align-items: stretch; gap: 20px; }
.mode-slot { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.word-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.word-wrap[hidden] { display: none; }
.word-target { font-size: clamp(40px, 8vw, 84px); font-weight: 900; letter-spacing: 4px; text-shadow: 4px 4px 0 #000; word-break: keep-all; text-align: center; }
.word-target .ch { color: #fff; }
.word-target .ch.ok { color: var(--green); }
.word-target.hit { animation: popin .25s steps(5); }
.word-input { width: min(420px, 100%); background: #0d0720; border: 4px solid var(--yellow); padding: 10px 14px; font-size: 28px; text-align: center; border-radius: 0; }
.word-input:focus { outline: none; border-color: var(--cyan); }
.word-input.bad { animation: wrongshake .3s; border-color: var(--red); }
@keyframes wrongshake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.save-panel { width: min(460px, 100%); }
.arena { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.hint { padding: 0 12px; }

/* 모바일·좁은 화면 */
@media (max-width: 900px) {
  #app { padding: 152px 12px 21px; }
  .play-main { flex-direction: column; }
  .mini-rank { width: 100%; align-self: stretch; }
  .arena { min-height: 37vh; }
  .gauges { padding: 0 4px; }
  .gauge { height: 52px; }
  .gauge-pct { font-size: 24px; }
  .stage-text { font-size: 18px; text-align: center; }
  .hud { gap: 6px; }
  .hud > div { min-width: 0; padding: 4px 10px; flex: 1; }
  .hud b { font-size: 22px; }
  .hint { font-size: 20px; }
  .big-overlay { font-size: 96px; }
  .banner { font-size: 30px; padding: 14px 24px; white-space: normal; text-align: center; width: 86vw; }
  .combo-text { font-size: 36px; }
  .mode-btn { min-width: 0; flex: 1 1 28%; padding: 12px 8px; font-size: 16px; }
  .result-grid { grid-template-columns: 1fr; justify-items: center; }
  .card-canvas { width: min(360px, 100%); height: auto; aspect-ratio: 3 / 4; }
  .rank-row { grid-template-columns: 40px 1fr 90px; }
  .rank-row .at { display: none; }
  .my-bar { flex-wrap: wrap; gap: 8px 16px; font-size: 16px; padding: 8px 12px; }
  .topbar { padding: 6px 8px; }
}

/* 게이지: 입력 중인 글(가운데) + 게이지 % (오른쪽) */
.gauge-pct { padding: 0 64px; font-size: 26px; white-space: nowrap; overflow: hidden; }
.gauge-val { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 16px; font-weight: 900; text-shadow: 2px 2px 0 #000; }
.hud-title b { font-size: 20px; }

/* 하드 모드 안내 */
.mode-note { margin: 0; text-align: center; color: var(--orange); font-weight: 700; font-size: 18px; padding: 0 8px; word-break: keep-all; }
.mode-slot.reserve { min-height: 170px; justify-content: center; }
.word-guide { width: min(560px, 100%); min-height: 150px; border: 4px solid var(--red); background: rgba(255, 59, 59, .12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 8px; }
.word-guide b { font-size: 32px; color: var(--red); }
.word-guide span { color: var(--red); }
.word-guide[hidden] { display: none; }

/* 사이트 공통 nav·footer (메인 페이지와 동일) */
header img { image-rendering: auto; }
body > footer { margin-top: 60px; position: relative; z-index: 1000; image-rendering: auto; }
body > footer a { margin-left: 15px; }
@media (max-width: 768px) { body > footer { margin-top: 40px; } body > footer a { margin-left: 0; } }
