:root { --bg: #070b22; --panel: #101a46; --line: #2d3f9a; --text: #e9ecff; --accent: #ff4f8b; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Malgun Gothic", sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
/* 게임 영역은 길게 눌러도 복사 메뉴·선택·이미지 드래그가 나오지 않게 한다 */
#stage, #touch, #bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px; align-items: center; flex: 0 0 auto; background: #0b1130; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
button { white-space: nowrap; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
button:hover { border-color: #5a74ff; }
button:focus-visible { outline: 2px solid #9db0ff; outline-offset: 2px; }
button.primary { background: var(--accent); border-color: #ff8db4; color: #1a0610; font-weight: 700; }
button.big { font-size: 1.2rem; padding: 12px 28px; }
kbd { font: inherit; font-size: .8em; background: #0004; border: 1px solid #fff4; border-radius: 4px; padding: 0 4px; }
#stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
#screen { image-rendering: pixelated; image-rendering: crisp-edges; background: #000; box-shadow: 0 0 0 2px #1b2766; }
#pausedMsg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000a; font-size: 1.4rem; font-weight: 700; }
#soundHint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: #101a46f0; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .8rem; white-space: nowrap; pointer-events: none; }
#iosHint { position: absolute; left: 12px; right: 12px; bottom: 8px; background: #101a46f0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: .85rem; text-align: center; }
#foot { flex: 0 0 auto; text-align: center; font-size: 11px; opacity: .45; padding: 2px; }
body.touch #foot { display: none; }

/* 터치 조작부: 반투명, 게임 화면 바깥(세로 폰에서는 아래, 가로에서는 좌우 빈자리)에 둔다 */
#touch { display: none; }
body.touch #touch { display: flex; justify-content: space-between; align-items: flex-end; flex: 0 0 auto; height: min(34vh, 230px); padding: 8px 18px 14px; pointer-events: none; }
body.touch #touch > * { pointer-events: auto; }
#stick { position: relative; width: min(38vw, 190px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(#fff2, #fff1 60%, #fff0 62%), #1b2766aa; border: 2px solid #8fa2ff88; opacity: .75; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 38%; height: 38%; margin: -19% 0 0 -19%; border-radius: 50%; background: #ffffffb0; box-shadow: 0 2px 8px #0008; pointer-events: none; transition: transform .06s; }
#btns { display: flex; gap: 18px; align-items: flex-end; padding-bottom: 10px; }
#btns button { width: min(22vw, 92px); aspect-ratio: 1; border-radius: 50%; font-size: 1.6rem; font-weight: 800; background: #ff4f8bb0; border: 2px solid #ffd1e2aa; color: #fff; opacity: .78; touch-action: none; }
#btns button[data-btn="b2"] { background: #4f8bffb0; border-color: #d1e2ffaa; margin-bottom: 38px; }
#btns button.on { filter: brightness(1.4); transform: scale(.94); }
@media (orientation: landscape) and (max-height: 520px) {
  body.touch #app { display: grid; grid-template-columns: minmax(150px, 26vw) minmax(0, 1fr) minmax(150px, 26vw); grid-template-rows: auto 1fr; }
  body.touch #bar { grid-column: 1 / -1; }
  body.touch #stage { grid-column: 2; grid-row: 2; }
  body.touch #touch { display: contents; }
  body.touch #stick { grid-column: 1; grid-row: 2; align-self: end; justify-self: start; margin: 0 0 14px 22px; width: min(34vh, 180px); }
  body.touch #btns { grid-column: 3; grid-row: 2; align-self: end; justify-self: end; margin: 0 22px 14px 0; }
}

#overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; text-align: center; background: radial-gradient(circle at 50% 30%, #1a2a7a, #070b22 70%); padding: 24px; }
#overlay[hidden] { display: none; }
#overlay h1 { margin: 0 0 12px; font-size: 2rem; letter-spacing: .08em; color: #ffd23f; text-shadow: 0 3px 0 #b8326a; }
#overlay p { margin: 6px 0; } .small { font-size: .82rem; opacity: .75; }
progress { width: min(70vw, 320px); height: 14px; accent-color: var(--accent); }
dialog { background: #0e1640; color: var(--text); border: 1px solid var(--line); border-radius: 14px; max-width: min(92vw, 520px); }
dialog::backdrop { background: #000a; }
table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .9rem; } th, td { border-bottom: 1px solid #fff2; padding: 5px 6px; text-align: left; }
@media (max-width: 520px) { #bar { gap: 4px; padding: 5px 6px; } #bar button { padding: 6px 7px; font-size: .74rem; } #startBtn kbd { display: none; } }

#netHint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: #101a46f0; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .8rem; max-width: 92%; text-align: center; pointer-events: none; z-index: 3; }
dialog { width: min(92vw, 560px); max-height: 88vh; overflow: auto; }
dialog .row { display: flex; gap: 6px; margin: 8px 0; }
dialog input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: #0a1030; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.status { min-height: 1.2em; font-size: .85rem; color: #ffd23f; margin: 6px 0; }
.code { font-size: 1.3rem; letter-spacing: .2em; color: #ffd23f; }
.memo-row { display: flex; gap: 6px; margin: 8px 0 2px; flex-wrap: nowrap; }
.memo-row input:first-child { flex: 0 0 7.5em; }
button.icon { padding: 3px 7px; line-height: 1; font-size: .95rem; border-radius: 6px; }
button.go { flex: 0 0 auto; background: var(--accent); border-color: #ff8db4; color: #1a0610; font-weight: 800; padding: 6px 12px; }
ul.memos { list-style: none; margin: 8px 0; padding: 0; max-height: 40vh; overflow: auto; }
ul.memos li { display: flex; gap: 8px; align-items: baseline; padding: 4px 2px; border-bottom: 1px solid #fff1; font-size: .88rem; white-space: nowrap; }
ul.memos li b { flex: 0 0 auto; max-width: 7em; overflow: hidden; text-overflow: ellipsis; color: #9db0ff; }
ul.memos li span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
ul.memos li time { flex: 0 0 auto; opacity: .55; font-size: .75rem; }
ul.memos li .icon { opacity: .75; }
ul.memos li.empty, td.empty { opacity: .6; white-space: normal; text-align: center; }
table.rec td, table.rec th { font-size: .82rem; padding: 4px 5px; }
table.rec td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; }
dialog > button:last-child { margin-top: 6px; }
