/* 우산 폴짝 — 화면 배치. 캔버스 크기와 패드 높이는 main.js layout()이 정한다. */
:root {
  --bg: #0b1222; --panel: #152038; --panel2: #1c2b4a; --line: #2b3d63; --ink: #eef3f8; --dim: #93a6c4;
  --accent: #e8b04a; --warm: #e2703a; --blue: #a9d3ee; --ok: #5fa66a; --bad: #c8423c;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif; font-size: 15px; line-height: 1.45;
  overflow: hidden; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* 상단 바 */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: calc(40px + var(--sat)); padding: var(--sat) 8px 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; background: #0d1629; border-bottom: 1px solid var(--line);
}
.back-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 14px; flex: none;
  color: var(--ink); text-decoration: none; font-size: 13px; background: var(--panel2); border: 1px solid var(--line);
}
.back-btn:hover { background: #26395f; }
.hud { flex: 1; display: flex; justify-content: center; gap: 12px; font-size: 13px; white-space: nowrap; min-width: 0; }
.hud-item b { color: var(--accent); }
.hud-item small { color: var(--dim); }
.tools { display: flex; gap: 4px; flex: none; }
.mini {
  width: 30px; height: 28px; padding: 0; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; line-height: 1; flex: none;
}
.mini:hover { background: #26395f; }

.screen { position: fixed; inset: calc(40px + var(--sat)) 0 0 0; }

/* 메뉴 */
.menu { overflow-y: auto; padding: 14px 12px calc(24px + var(--sab)); -webkit-overflow-scrolling: touch; }
.menu > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.title { text-align: center; padding: 8px 0 12px; }
.title h1 { font-size: 30px; letter-spacing: -0.5px; }
.title p { color: var(--dim); font-size: 14px; margin-top: 4px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--dim); font-weight: 600; }
.tabs button.on { background: var(--panel2); color: var(--ink); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--ink); font-weight: 600; text-decoration: none;
}
.btn:hover { background: #26395f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #23180a; }
.btn.primary:hover { background: #f1c165; }
.btn.big { min-height: 48px; width: 100%; font-size: 16px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 12px; }
.card h3 { font-size: 16px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h3 small { color: var(--dim); font-weight: 400; font-size: 12px; }
.card .sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.zone-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.zone-head .cnt { font-size: 12px; color: var(--accent); white-space: nowrap; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.room-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; min-height: 108px;
  border: 1px solid var(--line); background: var(--panel2); text-align: center;
}
.room-tile:hover:not(:disabled) { border-color: var(--accent); }
.room-tile:disabled { opacity: 0.45; cursor: default; }
.room-tile .no { font-weight: 700; font-size: 13px; }
.room-tile .nm { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.room-tile canvas { image-rendering: pixelated; width: 48px; height: 54px; object-fit: contain; border-radius: 4px; background: #0d1629; }
.room-tile .st { font-size: 13px; letter-spacing: 1px; color: var(--accent); }
.room-tile .st i { font-style: normal; color: #3c4d70; }
.room-tile .tm { font-size: 11px; color: var(--dim); white-space: nowrap; }
.clean { font-weight: 700; color: var(--ok); font-size: 10px; }
.side .clean { font-size: 12px; }
.mir { font-size: 10px; padding: 0 4px; margin-left: 2px; border-radius: 6px; border: 1px solid var(--line); color: var(--blue); white-space: nowrap; }
.room-tile.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.list-row:first-of-type { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .nm { font-weight: 600; }
.list-row .sub { color: var(--dim); font-size: 12px; }
.medal { font-size: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 10px; }
.stat { background: var(--panel2); border-radius: 10px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 18px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--dim); }
.umbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; margin-top: 10px; }
.umb { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); text-align: left; }
.umb.on { border-color: var(--accent); }
.umb:disabled { opacity: 0.5; cursor: default; }
.umb .sw { width: 22px; height: 14px; border-radius: 12px 12px 2px 2px; flex: none; border-bottom: 3px solid; }
.umb b { font-size: 13px; display: block; }
.umb small { font-size: 11px; color: var(--dim); }

/* 플레이 */
.play { display: flex; flex-direction: column; align-items: stretch; user-select: none; -webkit-user-select: none; touch-action: none; }
.phead { height: 30px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 6px; background: #101b31; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; overflow: hidden; }
.phead .mini { height: 24px; width: 28px; font-size: 13px; }
.room-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); color: var(--blue); flex: none; }
.tag.assist { color: #23180a; background: var(--accent); border-color: var(--accent); }
.tag.bolt { color: var(--dim); padding: 1px 4px; }
.tag.bolt.warn { color: #23180a; background: var(--accent); border-color: var(--accent); animation: bolt-blink 0.2s steps(2) infinite; }
.tag.bolt.flash { color: #0b1222; background: #f2f6f8; border-color: #f2f6f8; }
@keyframes bolt-blink { 50% { opacity: 0.45; } }
.grow { flex: 1; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--blue); min-width: 44px; text-align: right; }
.best { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.deaths { color: var(--dim); font-variant-numeric: tabular-nums; }
.boat-ico { opacity: 0.25; filter: grayscale(1); }
.boat-ico.got { opacity: 1; filter: none; }
/* 무대(캔버스)와 안내 줄은 한 덩어리로 남는 높이의 가운데에 둔다. 세로 휴대폰(.port)은 위에 붙이고 남는 높이를 패드가 쓴다 */
.stage { flex: 0 0 auto; margin-top: auto; padding-top: 4px; display: flex; align-items: center; justify-content: center; gap: 16px; position: relative; }
.play.port .stage { margin-top: 0; padding-top: 0; }
.cv-wrap { flex: none; line-height: 0; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
#cv { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #101a30; }
.side { width: 190px; flex: none; font-size: 12px; color: var(--dim); display: none; }
.side h4 { margin: 0 0 6px; color: var(--ink); font-size: 13px; }
.side p { margin-bottom: 4px; }
.side kbd { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); font: inherit; font-size: 11px; text-align: center; }
.wide .side { display: block; }
.hint { height: 24px; flex: none; margin-bottom: auto; display: flex; align-items: center; justify-content: center; padding: 0 8px; font-size: 12px; color: var(--blue); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint.pop { color: var(--accent); font-weight: 700; }
.play.port .hint { margin-bottom: 0; }
/* 좁은 화면: 안내 글귀를 두 줄까지 보여 준다(높이는 layout()이 36px로 잡는다) — 한 줄에 가두면 긴 글귀의 앞뒤가 잘린다 */
.play.narrow .hint { white-space: normal; line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; text-wrap: balance; }
/* 10번 넘어진 방: 방 글귀 + '어려우면 [도움 옵션] [이 방 건너뛰기]' */
.hint.acts { gap: 10px; }
.hint .htxt { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hint .hacts { display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap; color: var(--dim); }
.play.narrow .hint.acts { flex-direction: column; gap: 3px; }
.play.narrow .hint.acts .htxt { overflow: visible; }
.hint .hbtn { height: 22px; padding: 0 10px; border-radius: 11px; border: 1px solid var(--accent); background: var(--panel2); color: var(--accent); font-size: 12px; font-weight: 700; touch-action: manipulation; }
.hint .hbtn:hover { background: #26395f; }

/* 가상 패드: 캔버스·안내 줄 아래 영역 전체가 판정 영역 */
.pad { position: relative; flex: 1 1 auto; min-height: 170px; margin-bottom: var(--sab); touch-action: none; -webkit-touch-callout: none; overflow: hidden; }
.pad > div { position: absolute; display: flex; align-items: center; justify-content: center; pointer-events: none; color: var(--dim); }
.pad-dir { border-radius: 42px; background: rgba(169, 211, 238, 0.08); border: 2px solid rgba(169, 211, 238, 0.28); justify-content: space-between !important; padding: 0 22px; font-size: 26px; }
.pad-dir i { font-style: normal; opacity: 0.6; transition: transform 0.05s; }
.pad-dir i.on { opacity: 1; color: var(--ink); transform: scale(1.35); }
.pad-jump, .pad-umb { border-radius: 50%; border: 2px solid rgba(169, 211, 238, 0.35); background: rgba(169, 211, 238, 0.1); font-weight: 700; flex-direction: column; }
.pad-jump { font-size: 17px; color: var(--ink) !important; border-color: rgba(232, 176, 74, 0.6); background: rgba(232, 176, 74, 0.13); }
.pad-umb { font-size: 22px; line-height: 1; }
.pad-umb small { font-size: 11px; margin-top: 2px; }
.pad-jump.on, .pad-umb.on { background: rgba(232, 176, 74, 0.45); color: var(--ink); transform: scale(0.95); }
/* 가로 휴대폰: 패드가 무대 전체를 덮고 캔버스 양옆을 쓴다 */
.play.land .pad { position: absolute; inset: 30px 0 0 0; height: auto; min-height: 0; margin: 0; }
/* 그 위에서도 안내 줄의 버튼은 눌려야 한다: 버튼 줄만 패드 위로 올리고, 줄의 빈 곳은 패드로 통과시킨다 */
.play.land .hint.acts { position: relative; z-index: 3; pointer-events: none; }
.play.land .hint.acts .hbtn { pointer-events: auto; }

/* 겹침 창 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(6, 10, 20, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { width: min(440px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 16px; }
.dlg h2 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.dlg p { color: var(--dim); font-size: 14px; text-align: center; }
.dlg .big-num { text-align: center; font-size: 30px; font-weight: 800; color: var(--accent); margin: 6px 0; font-variant-numeric: tabular-nums; }
.dlg .col { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.dlg table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.dlg td { padding: 3px 4px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.dlg td:last-child { text-align: right; }
.help-list { margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.help-list li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.help-list li b { flex: none; width: 92px; color: var(--accent); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.opt small { display: block; color: var(--dim); font-size: 11px; }
.opt input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--panel2); padding: 5px 9px; font-size: 12px; color: var(--dim); }
.seg button.on { background: var(--accent); color: #23180a; font-weight: 700; }
.dlg h4 { margin: 14px 0 2px; font-size: 13px; color: var(--blue); }
.end-cv { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: 8px; border: 1px solid var(--line); }
.end-lines { margin: 12px 0 4px; }
.end-lines p { color: var(--ink); font-size: 15px; line-height: 1.9; opacity: 0; animation: end-in 0.9s ease forwards; }
.end-lines p:nth-child(2) { animation-delay: 1.1s; }
.end-lines p:nth-child(3) { animation-delay: 2.4s; color: var(--blue); }
@keyframes end-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .end-lines p { animation: none; opacity: 1; } .tag.bolt.warn { animation: none; } }
.error .dlg { border-color: var(--bad); }
.error pre { white-space: pre-wrap; word-break: break-all; font-size: 11px; color: var(--dim); background: #0d1629; border-radius: 8px; padding: 8px; max-height: 120px; overflow: auto; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); z-index: 60; background: var(--panel2); border: 1px solid var(--accent); color: var(--ink); padding: 8px 14px; border-radius: 12px; font-size: 13px; max-width: 90vw; text-align: center; }

@media (max-width: 420px) {
  .back-btn { padding: 0 8px; font-size: 12px; }
  .hud { gap: 6px; font-size: 12px; }
  .hud-item small { display: none; }
  .title h1 { font-size: 26px; }
  .best { display: none; }
}
