/* 링크비트 — 어두운 네이비 바탕 + 사선 패널 + 네온 포인트 */
:root {
  --bg: #04060d;
  --panel: rgba(12, 18, 36, 0.86);
  --panel2: #141c34;
  --line: rgba(90, 140, 255, 0.22);
  --line2: rgba(120, 170, 255, 0.45);
  --text: #e9eefc;
  --muted: #8691b3;
  --blue: #3f8cff;
  --cyan: #4de1ff;
  --gold: #ffc83d;
  --red: #ff3b55;
  --green: #4dffa6;
  --purple: #b98cff;
  --cut: 14px;
  --head: 'Orbitron', 'Noto Sans KR', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  font-size: 15px;
  overflow: hidden;
  background:
    linear-gradient(115deg, transparent 0 62%, rgba(63, 140, 255, 0.07) 62% 63%, transparent 63% 100%),
    linear-gradient(115deg, transparent 0 70%, rgba(77, 225, 255, 0.05) 70% 70.6%, transparent 70.6% 100%),
    radial-gradient(1100px 700px at 0% 0%, rgba(63, 140, 255, 0.16), transparent 60%),
    radial-gradient(900px 600px at 100% 100%, rgba(185, 140, 255, 0.10), transparent 60%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 8px 14px; cursor: pointer; transition: transform .08s, background .15s, border-color .15s, filter .15s;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--line2); background: #1b2646; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #04060d; border: none; font-weight: 800; }
button.primary:hover:not(:disabled) { filter: brightness(1.12); background: linear-gradient(135deg, var(--blue), var(--cyan)); }
button.ghost { background: transparent; }
button.danger { border-color: rgba(255, 59, 85, .5); color: var(--red); background: transparent; }
button.skew { transform: skewX(-12deg); }
button.skew:active:not(:disabled) { transform: skewX(-12deg) translateY(1px); }
button.wide { width: 100%; }
input, select {
  background: rgba(6, 10, 22, .9); border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(77, 225, 255, .15); }
kbd {
  font-family: var(--mono); font-size: .8em; padding: 1px 6px; border-radius: 3px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .16);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.warn { color: var(--gold); }
.panel {
  background: var(--panel); border: 1px solid var(--line); padding: 16px;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
h2, h3, h4 { margin: 0 0 10px; }
h3 { font-family: var(--head); font-size: 16px; letter-spacing: 2px; display: flex; align-items: baseline; gap: 10px; }
h3 small { font-family: 'Noto Sans KR'; font-size: 12px; color: var(--muted); letter-spacing: 0; font-weight: 500; }
.tag { font-family: var(--head); font-size: 11px; font-weight: 800; padding: 2px 7px; background: var(--blue); color: #fff; letter-spacing: 1px; display: inline-block; transform: skewX(-12deg); }

.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: flex; flex-direction: column; }

/* 별점 색 */
.star { font-family: var(--head); font-weight: 800; letter-spacing: .5px; }
.s1 { --sc: #4dffa6; } .s2 { --sc: #4de1ff; } .s3 { --sc: #ffc83d; } .s4 { --sc: #ff7a3d; } .s5 { --sc: #ff3b8a; } .s6 { --sc: #b98cff; }
.star.s1, .star.s2, .star.s3, .star.s4, .star.s5, .star.s6 { color: var(--sc); }
.star.s6, .dbox.s6 .dstar { text-shadow: 0 0 8px rgba(185, 140, 255, .7); }
.star-legend { margin-top: 10px; line-height: 2; }
.star-legend .star { margin-left: 6px; }
.star-legend .star:first-child { margin-left: 0; }

/* 등급 색 */
.rank-SS { color: var(--gold); } .rank-S { color: var(--gold); } .rank-A { color: var(--green); }
.rank-B { color: var(--cyan); } .rank-C { color: var(--purple); } .rank-D { color: var(--muted); }
.fc { color: var(--gold); font-weight: 800; font-family: var(--head); font-size: .85em; }

/* ============================================================ 상단 바 */
.topbar { display: flex; align-items: center; gap: 20px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(10, 16, 34, .9), rgba(10, 16, 34, .4)); }
.logo { font-family: var(--head); font-weight: 900; font-size: 26px; margin: 0; letter-spacing: 3px; display: flex; align-items: center; gap: 2px; font-style: italic; }
.logo b { font-weight: 900; color: var(--cyan); }
.logo-mark { width: 26px; height: 26px; margin-right: 10px; background: linear-gradient(135deg, var(--blue), var(--cyan)); clip-path: polygon(30% 0, 100% 0, 70% 100%, 0 100%); }
.seg { display: flex; background: rgba(6, 10, 22, .9); border: 1px solid var(--line); padding: 3px; gap: 3px; transform: skewX(-12deg); }
.seg button { border: none; background: transparent; padding: 6px 16px; color: var(--muted); border-radius: 2px; font-family: var(--head); font-weight: 800; letter-spacing: 1px; }
.seg button.on { background: linear-gradient(135deg, var(--blue), #2a5fd0); color: #fff; box-shadow: 0 0 14px rgba(63, 140, 255, .45); }
.mode-seg button { font-size: 18px; padding: 4px 18px; }
.mode-seg small { font-size: 10px; margin-left: 3px; opacity: .8; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-right input { width: 150px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); flex-shrink: 0; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ============================================================ 곡 선택 */
.select-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 430px) 1fr 320px; gap: 22px; padding: 18px 24px 20px; }
.detail-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; padding-right: 2px; }
.jacket-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; flex-shrink: 0; background: #0a0f20; clip-path: polygon(0 0, 100% 0, 100% 86%, 92% 100%, 0 100%); }
.jacket { width: 100%; height: 100%; object-fit: cover; display: block; }
.jacket-wrap::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(4, 6, 13, .85)); pointer-events: none; }
.jacket-wrap.previewing::after { display: none; }
.yt-slot.jacket-slot { position: absolute; inset: 0; width: auto; aspect-ratio: auto; background: transparent; pointer-events: none; }
.jacket-tag { position: absolute; left: 12px; top: 12px; z-index: 2; font-family: var(--head); font-weight: 900; font-size: 13px; letter-spacing: 2px; padding: 4px 10px; background: var(--blue); transform: skewX(-12deg); }
.d-title-row { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.prev-btn { flex-shrink: 0; width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 17px; border: 1px solid var(--line2); }
.prev-btn.on { background: var(--cyan); color: #04060d; box-shadow: 0 0 16px var(--cyan); }
.d-title { font-size: 22px; font-weight: 900; line-height: 1.25; word-break: keep-all; }
.d-artist { color: var(--muted); margin-top: 2px; }
.d-artist-row { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.edit-mini { padding: 0 6px; font-size: 12px; line-height: 18px; opacity: .55; background: transparent; border: 1px solid var(--line); }
.edit-mini:hover { opacity: 1; border-color: var(--cyan); }
.edit-mini.hidden { display: none; }
.d-meta { display: flex; gap: 0; margin-top: 10px; border: 1px solid var(--line); background: rgba(6, 10, 22, .6); }
.d-meta div { flex: 1; padding: 6px 10px; border-left: 1px solid var(--line); }
.d-meta div:first-child { border-left: none; }
.d-meta span { display: block; font-family: var(--head); font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.d-meta b { font-family: var(--head); font-size: 18px; }

.diff-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.dbox {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 9px 8px 7px 10px; text-align: left; min-width: 0;
  background: rgba(10, 16, 34, .85); border: 1px solid var(--line); border-radius: 0;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.dbox.on { border-color: var(--sc, var(--cyan)); background: linear-gradient(160deg, color-mix(in srgb, var(--sc, var(--cyan)) 26%, transparent), rgba(10, 16, 34, .9)); box-shadow: inset 0 0 0 1px var(--sc, var(--cyan)); }
.dname { font-family: var(--head); font-weight: 900; font-size: 11px; letter-spacing: 1px; white-space: nowrap; color: var(--sc, var(--text)); }
.dname small { display: block; font-family: 'Noto Sans KR'; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; margin: 1px 0 0; }
.dstar { font-family: var(--head); font-size: 22px; color: var(--sc, var(--text)); }
.pips { display: flex; gap: 2px; }
.pips i { width: 5px; height: 9px; background: rgba(255, 255, 255, .1); transform: skewX(-15deg); }
.pips i.f { background: var(--sc, var(--cyan)); box-shadow: 0 0 5px var(--sc, var(--cyan)); }
.dnotes { font-family: var(--head); font-size: 10px; color: var(--muted); letter-spacing: 1px; }

.d-records { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rec { background: rgba(6, 10, 22, .6); border: 1px solid var(--line); padding: 7px 10px; min-width: 0; }
.rec > span { display: block; font-size: 11px; color: var(--muted); }
.rec b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec em { font-style: normal; font-family: var(--head); font-size: 13px; }
.d-actions { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; padding: 0 10px 4px 6px; }
.d-actions .skew { padding: 8px 11px; }
.d-actions .play-btn { min-width: 140px; }
.play-btn {
  flex: 1; min-width: 160px; padding: 12px 18px; font-family: var(--head); font-weight: 900; font-size: 24px; letter-spacing: 4px; font-style: italic;
  background: linear-gradient(135deg, var(--blue), var(--cyan)); color: #04060d; border: none; transform: skewX(-12deg);
  box-shadow: 0 0 24px rgba(63, 140, 255, .45); display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.play-btn small { font-size: 10px; letter-spacing: 2px; opacity: .7; font-style: normal; font-family: 'Noto Sans KR', sans-serif; font-weight: 700; }
body.touch .play-btn small, body.touch .list-keys { display: none; }
body.touch .game-info { padding-right: 62px; }
.play-btn:hover:not(:disabled) { filter: brightness(1.12); background: linear-gradient(135deg, var(--blue), var(--cyan)); }
.play-btn:active:not(:disabled) { transform: skewX(-12deg) translateY(1px); }

.list-col { display: flex; flex-direction: column; min-height: 0; gap: 12px; }
.add-box { background: var(--panel); border: 1px solid var(--line); padding: 12px; }
.add-row { display: flex; gap: 10px; }
.add-row input { flex: 1; }
.add-status { font-size: 13px; margin-top: 8px; color: var(--muted); }
.add-status:empty { display: none; }
.add-status.ok { color: var(--green); }
.add-status.err { color: var(--red); }
.batch-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.batch-row .small-btn { font-size: 12px; padding: 4px 10px; }
#batchInfo { cursor: default; }
#batchInfo.err { color: var(--gold); cursor: help; }
.batch-bar { margin-top: 8px; }
.dl-desktop { display: block; text-align: center; padding: 9px; margin: 6px 0; border: 1px solid var(--line2); color: var(--cyan); text-decoration: none; font-weight: 700; }
.dl-desktop.hidden { display: none; }
.dl-desktop:hover { background: #1b2646; }
.pc-box { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.pc-box.hidden { display: none; }
.pc-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pc-head .small-btn { margin-left: auto; font-size: 11px; padding: 3px 8px; }
.pc-dot { width: 8px; height: 8px; border-radius: 50%; background: #5a6385; flex: none; }
.pc-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pc-dot.work { background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: pcBlink 1s infinite; }
@keyframes pcBlink { 50% { opacity: .35; } }
.pc-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; }
.pc-list:empty { display: none; }
.pc-list li { display: flex; align-items: center; gap: 8px; font-size: 12px; background: rgba(255,255,255,.03); padding: 4px 8px; }
.pc-list li .pt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-list li .pm { color: var(--muted); white-space: nowrap; }
.pc-list li.done .pm { color: var(--green); }
.pc-list li.error .pm, .pc-list li.canceled .pm { color: var(--red); }
.pc-list li .small-btn { font-size: 11px; padding: 2px 7px; }
.req-state { font-size: 11px; color: var(--gold); white-space: nowrap; }
.batch-bar.hidden { display: none; }
.bb-track { height: 6px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bb-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--cyan)); box-shadow: 0 0 10px rgba(77, 225, 255, .6); transition: width .4s; }
.bb-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.bb-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 14px; }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid var(--cyan); border-right-color: transparent; border-radius: 50%; margin-right: 8px; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-head { display: flex; align-items: center; gap: 10px; }
.list-head h2 { margin: 0; flex: 1; font-family: var(--head); font-size: 20px; letter-spacing: 4px; font-style: italic; }
.list-head h2 span { color: var(--cyan); font-size: 14px; margin-left: 6px; }
.list-head input { width: 160px; }
.song-list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 2px 14px 2px 10px; }
.row {
  display: grid; grid-template-columns: 64px 1fr auto 36px; align-items: center; gap: 12px; padding: 6px 12px 6px 6px; cursor: pointer;
  background: rgba(12, 18, 36, .72); border: 1px solid var(--line); transform: skewX(-10deg); transition: background .12s, border-color .12s, margin .12s;
}
.row > * { transform: skewX(10deg); }
.row:hover { background: rgba(26, 38, 72, .85); border-color: var(--line2); }
.row.sel { background: linear-gradient(90deg, rgba(63, 140, 255, .45), rgba(12, 18, 36, .85)); border-color: var(--cyan); box-shadow: 0 0 18px rgba(63, 140, 255, .35); margin-left: -8px; }
.row.roomsel { outline: 2px solid var(--gold); }
.row-thumb { width: 64px; height: 36px; object-fit: cover; background: #111a30; }
.row-info { min-width: 0; }
.row-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-artist { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-stars { display: flex; gap: 3px; }
.mini { font-family: var(--head); font-size: 11px; font-weight: 800; width: 32px; text-align: center; padding: 2px 0; color: var(--sc); background: rgba(255, 255, 255, .04); border: 1px solid transparent; }
.mini.on { border-color: var(--sc); background: color-mix(in srgb, var(--sc) 18%, transparent); }
.row-rank { font-family: var(--head); font-weight: 900; text-align: center; font-size: 15px; }
.list-keys { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; border: 1px dashed var(--line); line-height: 1.8; }

.side-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
.join-row { display: flex; gap: 8px; margin-top: 10px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; font-family: var(--head); min-width: 0; }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; }
.room-code { font-family: var(--head); font-size: 30px; font-weight: 900; letter-spacing: 6px; color: var(--cyan); text-shadow: 0 0 14px rgba(77, 225, 255, .5); }
.small-btn { padding: 5px 10px; font-size: 13px; }
.room-players { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.room-players li { padding: 6px 10px; background: rgba(255, 255, 255, .04); display: flex; align-items: center; gap: 6px; border-left: 3px solid var(--line); }
.room-players li .pn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-players li .pdiff { margin-left: auto; font-family: var(--head); font-size: 10px; letter-spacing: .5px; white-space: nowrap; color: var(--muted); }
.room-players li .pdiff .tag { font-size: 9px; padding: 0 4px; }
.room-players li .small { min-width: 34px; text-align: right; }
.room-players li.me { border-left-color: var(--cyan); }
.room-song { margin-bottom: 12px; }
.room-song-title { font-weight: 700; margin: 2px 0; }
.chat { margin-top: 12px; }
.chat-log { height: 120px; overflow: auto; font-size: 13px; background: rgba(6, 10, 22, .8); border: 1px solid var(--line); padding: 8px; margin-bottom: 6px; }
.chat-log div { margin-bottom: 3px; word-break: break-all; }
.chat-log .sys { color: var(--muted); font-style: italic; }
.chat input { width: 100%; }
.help ul { padding-left: 18px; margin: 8px 0 0; line-height: 1.8; }
.keys-help { display: flex; gap: 6px; flex-wrap: wrap; }
.keys-help kbd { font-size: 15px; padding: 5px 11px; font-family: var(--head); }

/* ============================================================ 플레이 / 에디터 / 싱크 공통 */
.stage { flex: 1; display: flex; gap: 22px; padding: 16px 22px; min-height: 0; }
.field-col { width: clamp(380px, 44vw, 640px); flex-shrink: 0; position: relative; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#screen-editor .field-col { width: auto; flex: 1; }
.field-col canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.info-col { flex: 1; min-width: 300px; display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
#screen-editor .info-col { flex: 0 0 420px; }
.yt-slot { width: 100%; aspect-ratio: 16 / 9; background: #000; flex-shrink: 0; }
#ytWrap { position: fixed; z-index: 5; overflow: hidden; background: #000; }
#ytWrap.parked { left: -10000px !important; top: 0 !important; width: 320px !important; height: 180px !important; }
#ytWrap iframe { width: 100%; height: 100%; display: block; }
.g-title { font-weight: 900; font-size: 18px; margin-bottom: 6px; }
.game-info .star { margin: 0 2px; }
.live h4 { font-family: var(--head); letter-spacing: 2px; font-size: 13px; color: var(--muted); }
.live-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: r; }
.live-board li { display: grid; grid-template-columns: 22px 1fr auto 46px; gap: 8px; align-items: center; padding: 6px 8px; background: rgba(255, 255, 255, .04); font-size: 14px; counter-increment: r; transform: skewX(-10deg); }
.live-board li > * , .live-board li::before { transform: skewX(10deg); }
.live-board li::before { content: counter(r); color: var(--muted); font-family: var(--head); }
.live-board li.me { background: rgba(63, 140, 255, .25); }
.live-board .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-board .s, .live-board .c { font-family: var(--head); font-size: 12px; }
.live-board .c { color: var(--muted); text-align: right; }
.hint { padding: 0 4px; }
.touch-pause { display: none; position: fixed; right: 12px; top: 12px; z-index: 8; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: rgba(4, 6, 13, .7); }
body.touch .touch-pause { display: block; }
#screen-game:not(.active) .touch-pause { display: none; }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(2, 4, 10, .72); display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.overlay-box { background: var(--panel); border: 1px solid var(--line2); padding: 28px 34px; min-width: 300px; text-align: center; clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px); }
.ov-title { font-family: var(--head); font-weight: 900; font-size: 26px; letter-spacing: 3px; font-style: italic; margin-bottom: 6px; }
.ov-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.ov-buttons button { padding: 12px; }

/* ============================================================ 결과 */
.result-wrap { flex: 1; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 24px; overflow: auto; }
.result-main { width: 560px; max-width: 100%; padding: 28px; }
.r-song { color: var(--muted); margin-bottom: 14px; line-height: 1.6; }
.r-top { display: flex; gap: 28px; align-items: center; }
.r-rank { font-family: var(--head); font-weight: 900; font-style: italic; font-size: 110px; line-height: 1; min-width: 160px; text-align: center; text-shadow: 0 0 34px currentColor; }
.r-score { font-family: var(--head); font-size: 40px; font-weight: 900; letter-spacing: 1px; }
.r-badge { color: var(--gold); font-family: var(--head); font-weight: 900; letter-spacing: 3px; min-height: 22px; font-style: italic; }
.r-stats { display: flex; gap: 22px; margin-top: 8px; }
.r-stats div { display: flex; flex-direction: column; }
.r-stats span { color: var(--muted); font-size: 12px; }
.r-stats b { font-family: var(--head); font-size: 20px; }
.r-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0 12px; }
.r-counts div { background: rgba(255, 255, 255, .04); padding: 10px; text-align: center; display: flex; flex-direction: column; gap: 4px; transform: skewX(-10deg); }
.r-counts span { font-family: var(--head); font-size: 10px; font-weight: 900; letter-spacing: 1px; }
.r-counts b { font-family: var(--head); font-size: 22px; }
.c-perfect span { color: #ffe45e; } .c-great span { color: #5effa1; } .c-good span { color: #5ec8ff; } .c-miss span { color: var(--red); }
.r-best { min-height: 22px; color: var(--muted); }
.r-best .nb { color: var(--gold); font-family: var(--head); letter-spacing: 2px; }
.r-best b { color: var(--text); }
.r-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.r-buttons button { min-width: 110px; padding: 10px 18px; transform: skewX(-12deg); }
.r-multi { width: 420px; max-width: 100%; max-height: 520px; overflow: auto; }
.r-multi-list, .rank-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.r-multi-list li { display: grid; grid-template-columns: 26px 1fr auto auto 40px; gap: 10px; align-items: center; padding: 10px 12px; background: rgba(255, 255, 255, .04); }
.r-multi-list li.me, .rank-list li.me { background: rgba(63, 140, 255, .22); }
.pos { font-family: var(--head); font-weight: 900; font-size: 18px; color: var(--muted); }
li:first-child > .pos { color: var(--gold); }
.r-multi-list .n, .rank-list .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.r-multi-list .s, .r-multi-list .a, .rank-list .s, .rank-list .a { font-family: var(--head); font-size: 13px; }
.r-multi-list .a, .rank-list .a, .rank-list .dt { color: var(--muted); }
.rk { font-family: var(--head); font-weight: 900; font-size: 16px; text-align: center; }

/* ============================================================ 순위표 / 설정 창 */
dialog { background: #0c1228; color: var(--text); border: 1px solid var(--line2); padding: 0; width: 460px; max-width: 94vw; border-radius: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(3px); }
#rankDlg { width: 620px; }
.rank-box { padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 84vh; }
.rank-head { display: flex; justify-content: space-between; gap: 12px; }
.rank-head h3 { margin: 0 0 4px; font-family: 'Noto Sans KR', sans-serif; letter-spacing: 0; }
.rank-tabs { display: flex; gap: 12px; flex-wrap: wrap; }
.rank-list { overflow: auto; }
.rank-list li { display: grid; grid-template-columns: 30px 1fr 36px auto 96px 40px; gap: 10px; align-items: center; padding: 9px 12px; background: rgba(255, 255, 255, .04); }
.settings { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.set-row input[type=range] { width: 180px; accent-color: var(--cyan); }
.set-row b { font-family: var(--head); color: var(--cyan); margin-left: 6px; }
.key-set { display: flex; gap: 5px; }
.key-set button { width: 40px; padding: 8px 0; font-family: var(--head); font-weight: 800; font-size: 13px; }
.key-set button.capturing { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(77, 225, 255, .4); }
.settings p { margin: -6px 0 0; }
.set-buttons { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ============================================================ 에디터 / 싱크 */
.editor-panel .panel, .calib-panel { display: flex; flex-direction: column; gap: 12px; }
.ed-time { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#edTime { font-family: var(--head); font-size: 22px; font-weight: 800; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ed-grid input, .ed-grid select { width: 100%; color: var(--text); font-size: 14px; }
.ed-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-buttons button { font-size: 13px; padding: 7px 10px; }
.ed-buttons kbd { font-size: 10px; margin-left: 2px; }
#edRec.rec-on { background: var(--red); color: #fff; border-color: var(--red); }
.ed-more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.ed-help { padding-left: 18px; margin: 0; line-height: 1.7; }
.cal-steps { padding-left: 18px; margin: 0; line-height: 1.8; }
.calib-panel label { display: flex; flex-direction: column; gap: 4px; }
.calib-panel select { width: 100%; color: var(--text); }
.cal-result:empty { display: none; }
.cal-ms { font-family: var(--head); font-size: 34px; font-weight: 900; color: var(--cyan); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #121a36; border: 1px solid var(--line2); padding: 10px 18px; z-index: 50;
  transition: opacity .2s, transform .2s; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================ 키 설정 */
.key-section { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: rgba(6, 10, 22, .6); border: 1px solid var(--line); }
.key-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.key-head .ok { color: var(--green); }
.fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.fn-grid label { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .03); padding: 4px 4px 4px 8px; }
.fn-key { min-width: 54px; padding: 6px 6px; font-family: var(--head); font-weight: 800; font-size: 11px; }
.fn-key.capturing { border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 10px rgba(77, 225, 255, .4); }
.key-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.keys-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.keys-help { cursor: pointer; }
.keys-help:hover kbd { border-color: var(--cyan); }
.key-set button { min-width: 40px; width: auto; padding: 8px 6px; }

/* ============================================================ 꾸미기 창 */
#skinDlg { width: 860px; }
.skin-box { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; max-height: 90vh; }
.skin-head { display: flex; justify-content: space-between; align-items: center; }
.skin-head h3 { margin: 0; }
.skin-body { display: grid; grid-template-columns: 260px 1fr; gap: 18px; min-height: 0; }
.skin-preview { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.skin-canvas-wrap { position: relative; width: 260px; height: 440px; background: #03050b; border: 1px solid var(--line); overflow: hidden; }
.skin-canvas-wrap canvas { position: absolute; inset: 0; display: block; }
.skin-prev-mode button { font-size: 13px; padding: 4px 14px; }
.skin-controls { overflow: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 6px; max-height: calc(90vh - 90px); }
.skin-controls section { background: rgba(6, 10, 22, .6); border: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.skin-controls h4 { margin: 0; font-size: 13px; color: var(--cyan); letter-spacing: 1px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px; font-size: 12px; min-width: 66px; }
.sw .chips { display: flex; gap: 2px; }
.sw .chips i { width: 14px; height: 14px; display: block; transform: skewX(-12deg); border: 1px solid rgba(0, 0, 0, .3); }
.sw.on { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset, 0 0 12px rgba(77, 225, 255, .3); }
.custom-colors { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.custom-colors label { display: flex; align-items: center; gap: 6px; }
.custom-colors input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line); background: none; cursor: pointer; }
.custom-colors.dim { opacity: .55; }
.opt-row { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-row button { font-size: 13px; padding: 6px 12px; }
.opt-row button.on { background: linear-gradient(135deg, var(--blue), #2a5fd0); color: #fff; border-color: transparent; }
.line-sw { gap: 8px; }
.dot-sw { width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid rgba(255, 255, 255, .15); box-shadow: 0 0 8px var(--c); }
.dot-sw:hover:not(:disabled) { background: var(--c); }
.dot-sw.on { border-color: #fff; outline: 2px solid var(--c); outline-offset: 2px; }
.hit-row { display: flex; gap: 6px; align-items: center; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checks input { accent-color: var(--cyan); width: 16px; height: 16px; }
.skin-foot { display: flex; justify-content: flex-end; }
@media (max-width: 820px) {
  .skin-body { grid-template-columns: 1fr; }
  .skin-canvas-wrap { width: 200px; height: 300px; }
  .skin-controls { max-height: none; overflow: visible; }
  .skin-box { overflow: auto; }
}

/* ============================================================ 도트 캐릭터 */
.av-btn { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; }
#topAvatar { width: 28px; height: 28px; image-rendering: pixelated; background: rgba(77, 225, 255, .12); border-radius: 4px; }
#avatarDlg { width: 760px; }
.av-body { display: grid; grid-template-columns: 250px 1fr; gap: 18px; min-height: 0; }
.av-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#avCanvas { width: 250px; height: 300px; background: radial-gradient(circle at 50% 70%, rgba(63, 140, 255, .18), transparent 70%), #03050b; border: 1px solid var(--line); image-rendering: pixelated; }
.av-name { font-weight: 900; font-size: 16px; }
.av-controls section { gap: 6px; }
.av-sws { display: flex; gap: 6px; flex-wrap: wrap; }
.av-sw { width: 28px; height: 28px; padding: 0; background: var(--c); border: 2px solid rgba(0, 0, 0, .35); transform: skewX(-10deg); }
.av-sw:hover:not(:disabled) { background: var(--c); border-color: #fff; }
.av-sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--cyan); }
.stage-panel { padding: 6px; flex: 1; min-height: 180px; display: flex; }
#avatarStage { width: 100%; height: 100%; min-height: 170px; display: block; image-rendering: pixelated; }
.r-left { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.r-avatar { width: 120px; height: 130px; image-rendering: pixelated; }
.mini-av { width: 28px; height: 28px; image-rendering: pixelated; vertical-align: middle; flex-shrink: 0; }
.live-board .mini-av, .r-multi-list .mini-av { width: 24px; height: 24px; }
@media (max-width: 820px) {
  .av-body { grid-template-columns: 1fr; }
  #avCanvas { width: 200px; height: 230px; }
  .stage-panel { display: none; }
  .av-btn { font-size: 0; padding: 4px; gap: 0; }
}

/* ============================================================ 옵션 / 신청함 / 타이밍 */
.mods { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { font-family: var(--head); font-weight: 800; font-size: 11px; letter-spacing: 1px; padding: 6px 10px; transform: skewX(-12deg); color: var(--muted); }
.chip small { font-family: 'Noto Sans KR', sans-serif; font-weight: 500; margin-left: 4px; letter-spacing: 0; }
.chip.on, .chip.on:hover:not(:disabled) { color: #04060d; background: linear-gradient(135deg, var(--gold), #ff9d3d); border-color: transparent; box-shadow: 0 0 12px rgba(255, 200, 61, .4); }
.hl-chip.on, .hl-chip.on:hover:not(:disabled) { background: linear-gradient(135deg, #fff1b8, var(--gold) 45%, #ff5fa2); box-shadow: 0 0 14px rgba(255, 140, 120, .45); }
.hl-chip.on.nohl { opacity: .55; }
.hl-chip:disabled { cursor: default; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 30; }
.hl-range { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--gold); }
.hl-tag { background: linear-gradient(135deg, var(--gold), #ff5fa2); color: #04060d; }
.hl-note { margin-top: 4px; color: var(--gold); font-weight: 700; }
#rankHl button { min-width: 74px; }
.speed-show { margin-left: auto; font-family: var(--head); font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.speed-show b { color: var(--cyan); font-size: 14px; margin: 0 4px; }
.speed-show small { font-family: 'Noto Sans KR', sans-serif; letter-spacing: 0; }
.badge { font-family: var(--head); font-size: 11px; background: var(--red); color: #fff; padding: 1px 7px; border-radius: 9px; letter-spacing: 0; }
.req-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.req-list li { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; align-items: center; padding: 6px; background: rgba(255, 255, 255, .04); }
.req-list li.empty-req { display: block; color: var(--muted); font-size: 13px; background: none; padding: 4px 0; }
.req-list img { width: 56px; height: 32px; object-fit: cover; background: #111a30; }
.req-info { min-width: 0; }
.req-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-by { font-size: 11px; color: var(--muted); }
.req-btns { display: flex; gap: 4px; }
.req-btns button { padding: 4px 8px; font-size: 12px; }
.r-timing { margin: 6px 0 12px; }
.rt-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--head); font-size: 11px; letter-spacing: 2px; color: var(--muted); margin-bottom: 4px; }
.rt-wrap { position: relative; height: 96px; background: rgba(6, 10, 22, .6); border: 1px solid var(--line); }
.rt-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.rt-suggest { margin-top: 6px; color: var(--muted); line-height: 1.9; }
.rt-suggest b { color: var(--text); }
.rt-suggest button { padding: 3px 10px; font-size: 12px; margin-left: 6px; }

/* ============================================================ 화면 폭이 좁을 때 */
@media (max-width: 1280px) {
  .select-grid { grid-template-columns: minmax(320px, 380px) 1fr; }
  .side-col { grid-column: 1 / -1; flex-direction: row; overflow: visible; }
  .side-col > .panel { flex: 1; }
  #screen-lobby { overflow: auto; }
  #screen-lobby .select-grid { min-height: auto; }
  .song-list { max-height: 70vh; }
}
@media (max-width: 820px) {
  body { font-size: 14px; }
  .set-row { flex-wrap: wrap; }
  .key-set { flex-wrap: wrap; }
  .key-set button { min-width: 36px; padding: 7px 4px; font-size: 12px; }
  .set-row input[type=range] { width: 100%; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .logo { font-size: 20px; }
  .top-right { width: 100%; margin-left: 0; }
  .top-right input { flex: 1; width: auto; }
  .select-grid { display: flex; flex-direction: column; padding: 12px; gap: 14px; }
  .detail-col { overflow: visible; }
  .jacket-wrap { aspect-ratio: auto; height: 24vh; min-height: 150px; }
  .d-title { font-size: 18px; }
  .d-meta b { font-size: 15px; }
  .dstar { font-size: 18px; }
  .side-col { flex-direction: column; }
  .list-head { flex-wrap: wrap; }
  .list-head input { flex: 1; width: auto; }
  .row { grid-template-columns: 52px 1fr auto; transform: none; }
  .row > * { transform: none; }
  .row-rank { display: none; }
  .row-thumb { width: 52px; height: 29px; }
  .list-keys { display: none; }
  .stage { flex-direction: column; padding: 8px; gap: 8px; }
  .field-col { width: 100%; flex: 1; order: 2; }
  .info-col { flex: 0 0 auto; min-width: 0; flex-direction: row; gap: 8px; overflow: hidden; order: 1; }
  .info-col .yt-slot { width: 128px; }
  .game-info { flex: 1; min-width: 0; padding: 8px 10px; }
  .g-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #livePanel, .hint { display: none; }
  #screen-calib .info-col { flex-direction: column; overflow: auto; max-height: 50vh; }
  #screen-calib .info-col .yt-slot { width: 100%; max-width: 260px; }
  .r-top { flex-direction: column; gap: 6px; }
  .r-rank { font-size: 80px; }
  .rank-list li { grid-template-columns: 26px 1fr 32px auto; }
  .rank-list .a, .rank-list .dt { display: none; }
  .result-wrap { flex-direction: column; align-items: stretch; justify-content: flex-start; }
}

/* ============================================================ 멀티 관전 (친구 화면) */
.live-board .ld { font-family: var(--head); font-size: 9px; color: var(--muted); letter-spacing: .5px; }
.spec { padding: 8px 10px 10px; flex-shrink: 0; }
.spec h4 { font-family: var(--head); letter-spacing: 2px; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.spec h4 span { font-size: 11px; letter-spacing: 0; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.spec-card { display: flex; flex-direction: column; gap: 2px; min-width: 0; background: rgba(255, 255, 255, .03); padding: 4px; border: 1px solid var(--line); }
.spec-card.ended .spec-field canvas { opacity: .35; }
.spec-head { display: flex; align-items: center; gap: 4px; min-width: 0; }
.spec-head .mini-av { width: 20px; height: 20px; }
.spec-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-sub { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-family: var(--head); font-size: 9px; }
.spec-sub .tag { font-size: 8px; padding: 0 3px; }
.spec-score { color: #fff; letter-spacing: .5px; }
.spec-field { position: relative; height: 150px; }
.spec-field canvas { position: absolute; inset: 0; display: block; }
.spec-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; font-family: var(--head); font-weight: 900; font-size: 11px; letter-spacing: 1px; color: #fff; text-shadow: 0 0 6px #000; pointer-events: none; }
/* 멀티: 정보 칸을 두 줄로 — 왼쪽(영상·곡 정보·순위·캐릭터), 오른쪽(친구 화면) */
#screen-game.multi .info-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-auto-rows: min-content; align-content: start; column-gap: 12px; }
#screen-game.multi .info-col > * { grid-column: 1; }
#screen-game.multi .info-col > #specPanel { grid-column: 2; grid-row: 1 / span 6; align-self: stretch; }
#screen-game.multi .stage-panel { height: 150px; min-height: 0; }
.spec-grid.n1, .spec-grid.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spec-grid.n1 .spec-field, .spec-grid.n2 .spec-field { height: 340px; }
.spec-grid.n3, .spec-grid.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.spec-grid.n3 .spec-field, .spec-grid.n4 .spec-field { height: 210px; }
.spec-grid.n5, .spec-grid.n6, .spec-grid.n7 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.spec-grid.n5 .spec-field, .spec-grid.n6 .spec-field, .spec-grid.n7 .spec-field { height: 150px; }
@media (max-width: 820px) { .spec { display: none !important; } }

/* ============================================================ 프로필 (서버 백업) */
.pf-btn { display: flex; align-items: center; gap: 5px; max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pf-btn .cloud { color: var(--muted); font-size: 15px; transition: color .2s; }
.pf-btn.on { border-color: rgba(77, 225, 255, .45); }
.pf-btn.on .cloud { color: var(--cyan); text-shadow: 0 0 8px rgba(77, 225, 255, .6); }
.pf-btn .cloud.busy { animation: pfPulse .8s ease-in-out infinite alternate; }
@keyframes pfPulse { from { opacity: .35; } to { opacity: 1; } }
.profile-banner { display: flex; align-items: center; gap: 10px; margin: 12px 24px 0; padding: 9px 14px; font-size: 13px;
  background: linear-gradient(90deg, rgba(63, 140, 255, .22), rgba(77, 225, 255, .06)); border: 1px solid rgba(77, 225, 255, .35); }
.profile-banner.hidden { display: none; }
.profile-banner .pb-ico { font-size: 20px; color: var(--cyan); }
.profile-banner .pb-text { flex: 1; min-width: 0; line-height: 1.45; }
.profile-banner .pb-text b { margin-right: 4px; }
.profile-dlg { padding: 22px 24px; width: 420px; }
.profile-dlg h3 { margin: 0 0 10px; font-family: 'Noto Sans KR', sans-serif; letter-spacing: 0; }
.profile-dlg p { margin: 0 0 12px; line-height: 1.55; }
.profile-dlg .seg { margin-bottom: 14px; width: max-content; }
.pf-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.pf-row input { width: 230px; }
.pf-who { display: flex; align-items: center; gap: 8px; font-size: 20px; margin-bottom: 6px; }
.pf-who .cloud { color: var(--cyan); text-shadow: 0 0 8px rgba(77, 225, 255, .6); }
#pfMsg { min-height: 18px; margin-top: 4px; }
.profile-dlg .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
@media (max-width: 820px) {
  .pf-btn { max-width: 44px; font-size: 0; padding: 6px; }
  .pf-btn .cloud { font-size: 16px; }
  .profile-banner { margin: 8px 10px 0; flex-wrap: wrap; }
  .profile-banner .pb-text { flex-basis: 100%; }
}
.pf-btn.err { border-color: rgba(255, 200, 61, .6); }
.pf-btn.err .cloud { color: var(--gold); text-shadow: none; }

/* ================= 시작 화면 · 로그인 ================= */
.gate { position: fixed; inset: 0; z-index: 100; background: radial-gradient(ellipse at 50% 85%, #0d1a40 0%, #05070f 60%, #020309 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; user-select: none; transition: opacity .45s ease; --pulse: 0; }
.gate.hidden { display: none; }
.gate.out { opacity: 0; pointer-events: none; }
.gate-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gate-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(2,3,9,.85) 100%); }
.gate.hit::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, rgba(255,240,200,.55), transparent 60%); animation: gateFlash .5s ease-out forwards; pointer-events: none; }
@keyframes gateFlash { from { opacity: 1; } to { opacity: 0; } }
.gate-logo { position: relative; text-align: center; transition: transform .5s cubic-bezier(.2,.8,.2,1), margin .5s; margin-top: -6vh; }
.gl-sub { font-family: var(--head); font-size: 12px; letter-spacing: 6px; color: var(--cyan); opacity: .8; }
.gl-title { margin: 6px 0 2px; font-family: var(--head); font-weight: 900; font-style: italic; font-size: clamp(56px, 11vw, 132px); letter-spacing: 4px; line-height: 1;
  color: #fff; transform: skewX(-8deg) scale(calc(1 + var(--pulse) * .025));
  text-shadow: 0 0 calc(18px + var(--pulse) * 22px) rgba(77,225,255,.55), 0 0 2px #fff; }
.gl-title span { background: linear-gradient(90deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
  filter: drop-shadow(0 0 calc(10px + var(--pulse) * 16px) rgba(255,200,61,.6)); }
.gl-kr { font-family: 'Black Han Sans', 'Noto Sans KR', sans-serif; font-size: 20px; letter-spacing: 10px; color: rgba(233,238,252,.75); }
.gate-press { position: relative; margin-top: 9vh; font-family: var(--head); font-weight: 800; letter-spacing: 6px; font-size: 18px; color: #fff; text-align: center;
  animation: gatePress 1.4s ease-in-out infinite; }
.gate-press small { display: block; margin-top: 8px; text-shadow: 0 0 6px #000, 0 0 12px #000; font-family: 'Noto Sans KR', sans-serif; letter-spacing: 1px; font-size: 12px; font-weight: 500; color: var(--muted); }
@keyframes gatePress { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.gate-welcome { position: relative; display: none; margin-top: 6vh; font-size: 22px; font-weight: 900; color: var(--gold); text-shadow: 0 0 16px rgba(255,200,61,.5); animation: gateIn .4s ease both; }
.gate-card { position: relative; display: none; width: min(380px, 92vw); margin-top: 4vh; padding: 20px 22px 18px; background: rgba(10,16,34,.88);
  border: 1px solid var(--line2); box-shadow: 0 0 40px rgba(63,140,255,.18); clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  animation: gateIn .35s ease both; }
@keyframes gateIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.gate-tabs { display: flex; margin-bottom: 14px; }
.gate-tabs button { flex: 1; }
.gt-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.gt-row span { width: 64px; font-size: 13px; color: var(--muted); flex: none; }
.gt-row input { flex: 1; min-width: 0; padding: 10px 12px; font-size: 15px; }
.gt-hint { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.gt-msg { font-size: 13px; color: var(--red); min-height: 18px; margin: 6px 0; }
.gt-go { width: 100%; padding: 12px; font-size: 16px; }
.gate[data-stage="login"] .gate-logo, .gate[data-stage="welcome"] .gate-logo { transform: scale(.62); margin-top: -2vh; }
.gate[data-stage="login"] .gate-press, .gate[data-stage="welcome"] .gate-press, .gate[data-stage="busy"] .gate-press { display: none; }
.gate[data-stage="login"] .gate-card { display: block; }
.gate[data-stage="welcome"] .gate-welcome { display: block; }
.gate-auto { position: relative; margin-top: 18px; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--cyan);
  text-shadow: 0 0 6px #000; animation: gateIn .4s ease both; }
.gate-auto.hidden, .gate[data-stage="login"] .gate-auto, .gate[data-stage="welcome"] .gate-auto { display: none; }
.gate-auto .small-btn { font-size: 11px; padding: 3px 9px; }
.gt-autochk { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; cursor: pointer; }
.gt-autochk small { color: var(--muted); font-size: 11px; }
.pf-auto { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 6px 0; cursor: pointer; }
.gate-ver { position: absolute; right: 14px; bottom: 10px; font-size: 11px; color: #3a4266; font-family: var(--mono); }
@media (max-height: 600px) { .gate-press { margin-top: 4vh; } .gate[data-stage="login"] .gate-logo { transform: scale(.5); margin-top: -8vh; } }

/* ================= 스크롤바 (기본 하얀 막대 대신 게임 분위기에 맞게) ================= */
/* 크롬·실행기는 아래 ::-webkit-scrollbar 로 꾸밈 (표준 속성을 같이 쓰면 그쪽이 이겨서 둥근 모양이 사라짐) → 파이어폭스만 표준 속성 */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: rgba(77, 160, 255, .55) transparent; }
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(10, 16, 34, .35); border-radius: 8px; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(77, 225, 255, .55), rgba(63, 140, 255, .55));
  border-radius: 8px; border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--cyan), var(--blue)); background-clip: padding-box; border: 2px solid transparent;
  box-shadow: 0 0 8px rgba(77, 225, 255, .6);
}
::-webkit-scrollbar-thumb:active { background: linear-gradient(180deg, #fff, var(--cyan)); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }

/* 고스트 대결 */
.ghost-chip.on, .ghost-chip.on:hover:not(:disabled) { background: linear-gradient(135deg, #e4d4ff, var(--purple)); color: #0b0618; box-shadow: 0 0 12px rgba(185, 140, 255, .45); }
.r-ghost { margin-top: 6px; font-size: 14px; color: var(--purple); }
.r-ghost.hidden { display: none; }
.r-ghost .win { color: var(--green); }
.r-ghost .lose { color: #ff7a8a; }

/* 업적 · 칭호 */
.ptitle { display: inline-block; font-size: 10px; font-weight: 800; color: #0b0618; background: linear-gradient(135deg, #fff1b8, var(--gold)); padding: 1px 6px; margin-right: 5px;
  transform: skewX(-10deg); letter-spacing: 0; vertical-align: 1px; }
.ptitle.hidden { display: none; }
.my-title { margin-right: 2px; }
.ach-btn { display: inline-flex; align-items: center; gap: 4px; }
.ach-btn span { font-size: 13px; }
.ach-dlg { width: min(780px, 94vw); padding: 18px 20px 20px; }
.ach-top { display: flex; align-items: center; justify-content: space-between; }
.ach-top h3 { margin: 0; }
.ach-top h3 small { font-family: var(--mono); color: var(--gold); margin-left: 6px; font-size: 14px; }
.ach-bar { height: 4px; background: rgba(255,255,255,.08); margin: 10px 0 4px; }
.ach-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9d3d); box-shadow: 0 0 8px rgba(255,200,61,.5); }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; padding: 2px; }
.ach-item { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 10px 10px 10px; min-height: 92px; white-space: normal;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.ach-item:disabled { opacity: .45; cursor: default; }
.ach-item.got { border-color: rgba(255,200,61,.45); background: linear-gradient(160deg, rgba(255,200,61,.12), rgba(255,255,255,.02)); cursor: pointer; }
.ach-item.got:hover { box-shadow: 0 0 12px rgba(255,200,61,.3); }
.ach-item.cur { outline: 2px solid var(--gold); box-shadow: 0 0 16px rgba(255,200,61,.45); }
.ach-item.cur::after { content: '칭호'; position: absolute; top: 28px; right: 8px; font-size: 10px; font-weight: 800; color: #0b0618; background: var(--gold); padding: 1px 6px; transform: skewX(-10deg); }
.ai-ico { font-size: 18px; }
.ai-name { font-weight: 800; font-size: 14px; }
.ai-desc { font-size: 11px; color: var(--muted); line-height: 1.4; white-space: normal; word-break: keep-all; }
.ai-date { position: absolute; right: 8px; top: 8px; font-size: 10px; color: var(--muted); font-family: var(--mono); }
.ach-pop { position: fixed; top: 18px; left: 50%; transform: translate(-50%, -140%); z-index: 120; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 92vw;
  padding: 12px 18px; background: linear-gradient(135deg, rgba(40,30,8,.96), rgba(16,14,30,.96)); border: 1px solid rgba(255,200,61,.7);
  box-shadow: 0 0 28px rgba(255,200,61,.35); animation: achIn .45s cubic-bezier(.2,1.4,.4,1) forwards; cursor: pointer; }
.ach-pop.out { animation: achOut .35s ease forwards; }
@keyframes achIn { to { transform: translate(-50%, 0); } }
@keyframes achOut { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -140%); opacity: 0; } }
.ap-ico { font-size: 28px; filter: drop-shadow(0 0 8px rgba(255,200,61,.8)); }
.ap-head { font-size: 11px; font-weight: 800; letter-spacing: 2px; color: var(--gold); }
.ap-name { font-size: 18px; font-weight: 900; color: #fff; }
.ap-desc { font-size: 12px; color: var(--muted); }

/* 결과: 최고 기록 대비 점수·등급 변화 */
.r-delta { font-family: var(--head); font-weight: 800; font-size: 16px; margin: 2px 0 4px; letter-spacing: .5px; }
.r-delta.hidden, .r-rankup.hidden { display: none; }
.r-delta small { font-family: 'Noto Sans KR', sans-serif; font-weight: 600; font-size: 12px; color: var(--muted); letter-spacing: 0; }
.r-delta.up { color: var(--green); text-shadow: 0 0 12px rgba(77,255,166,.45); animation: deltaIn .5s cubic-bezier(.2,1.4,.4,1) both .35s; }
.r-delta.same { color: var(--text); }
.r-delta.down { color: var(--muted); font-family: 'Noto Sans KR', sans-serif; font-weight: 600; font-size: 13px; }
.r-delta.down b { color: #ff7a8a; }
@keyframes deltaIn { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }
.r-rankup { text-align: center; font-size: 12px; color: var(--muted); margin-top: -2px; font-weight: 700; }
.r-rankup span { font-family: var(--head); font-weight: 900; font-style: italic; font-size: 15px; margin: 0 2px; }
.r-rankup.up { display: grid; grid-template-columns: auto auto auto; align-items: center; justify-content: center; column-gap: 6px; color: var(--gold);
  padding: 4px 12px; margin: 2px auto 0; width: max-content; align-self: center; background: rgba(255,200,61,.1); border: 1px solid rgba(255,200,61,.55);
  box-shadow: 0 0 16px rgba(255,200,61,.3); animation: rankUp .6s cubic-bezier(.2,1.6,.4,1) both .5s, rankGlow 1.6s ease-in-out infinite 1.2s; }
.r-rankup.up span { font-size: 22px; }
.r-rankup.up i { font-style: normal; color: var(--text); }
.r-rankup.up em { font-style: normal; font-family: var(--head); font-size: 10px; letter-spacing: 2px; grid-column: 1 / -1; text-align: center; }
@keyframes rankUp { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes rankGlow { 50% { box-shadow: 0 0 26px rgba(255,200,61,.6); } }
