/* SPDX-License-Identifier: GPL-3.0-or-later — 룬 타이머 웹 */
:root {
  --bg: #0b0d0e;
  --surface: #121516;
  --panel: #171b1c;
  --panel-2: #1e2324;
  --line: #272d2f;
  --text: #eef2f3;
  --muted: #8b9497;
  --mint: #4af1ae;
  --mint-2: #1bc9cd;
  --mint-ink: #04140d;
  --rune: #c96dff;
  --rune-soft: #e5b2ff;
  --rune-deep: #2b1233;
  --warn: #ff8a4c;
  --danger: #ff5d6c;
  --radius: 18px;
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 50% -120px, rgba(74, 241, 174, .09), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 12px; padding: 9px 14px; font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s, transform .08s;
}
button:hover { background: #252b2c; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--mint); color: var(--mint-ink); border-color: transparent; }
button.primary:hover { background: #33e09b; }
button.ghost { background: transparent; }
.top-actions button, .share button { white-space: nowrap; }
button.danger { color: var(--danger); }
a { color: var(--mint); }

/* 넓은 화면: 한 화면에 다 보이게(왼쪽 상태, 오른쪽 탭 설정). 좁거나 낮은 창은 아래 @media에서 세로로 쌓는다. */
.app { max-width: 1280px; height: 100vh; height: 100dvh; min-height: 640px; margin: 0 auto; padding: 18px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 16px; }
.status-col { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; fill: var(--rune); stroke: var(--rune-soft); stroke-width: 2.4; filter: drop-shadow(0 0 10px rgba(201,109,255,.45)); }
h1 { font-size: 20px; margin: 0; letter-spacing: -.02em; }
h1 span { color: var(--mint); font-weight: 700; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

.share {
  display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 620px;
  padding: 6px 6px 6px 14px; border-radius: 999px;
  border: 1px solid rgba(255, 93, 108, .35); background: rgba(255, 93, 108, .06);
}
.share.on { border-color: rgba(74, 241, 174, .35); background: rgba(74, 241, 174, .06); }
.share-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.share.on .share-dot { background: var(--mint); }
.share-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.share-text strong { font-size: 13px; white-space: nowrap; }
.share-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share button { flex-shrink: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; }

.countdown {
  display: flex; align-items: center; gap: 20px; padding: 18px 20px; cursor: pointer; user-select: none;
  background: radial-gradient(circle at 20% 50%, #1a2120, var(--panel) 70%);
}
.ring-wrap { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #222829; stroke-width: 12; }
.ring-fg {
  fill: none; stroke: var(--mint); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 603.19; stroke-dashoffset: 603.19; transition: stroke-dashoffset .25s linear, stroke .2s;
  filter: drop-shadow(0 0 6px rgba(74, 241, 174, .35));
}
.countdown.paused .ring-fg { stroke: #4f5a5c; filter: none; }
.countdown.alert .ring-fg { stroke: var(--warn); }
.count-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; font-weight: 200; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.count-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.count-side strong { font-size: 15px; }
.count-label { color: var(--muted); font-size: 13px; }
.play { width: 44px; height: 44px; margin-top: 6px; border-radius: 50%; padding: 0; font-size: 15px; background: #fff; color: #0b0d0e; border: none; }
.play:hover { background: #e9eded; }

.runebar { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.rune-row { display: flex; align-items: center; gap: 10px; }
.rune-mark { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: var(--rune); stroke-width: 2.4; }
.rune-status { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.rune-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.rune-actions button { height: 40px; padding: 0 10px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.rune-status.active { color: var(--rune-soft); }
.rune-status.muted { color: var(--warn); }
.rune-cool { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #222829; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--mint-2)); transition: width .4s; }
.runebar.active .bar-fill { width: 100% !important; background: var(--rune); }

.janus { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; user-select: none; }
.janus[hidden] { display: none; }
.janus:hover { border-color: #323a3c; }
.janus-row { display: flex; align-items: center; gap: 12px; }
.janus .sun { width: 26px; height: 26px; flex-shrink: 0; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.janus .sun circle { fill: var(--muted); stroke: none; }
.janus-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.janus-text strong { font-size: 14px; }
.janus-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.janus-time { font-size: 28px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--muted); }
.janus .bar-fill { background: linear-gradient(90deg, #ffd36b, #ffb347); transition: width .25s linear; }
.janus.running .sun { stroke: #ffc65c; }
.janus.running .sun circle { fill: #ffc65c; }
.janus.running .janus-time { color: var(--text); }
.janus.soon .janus-time, .janus.soon .janus-text span, .janus.ended .janus-time, .janus.ended .janus-text span { color: var(--warn); }
.janus.soon .bar-fill { background: var(--warn); }
.janus.ended { border-color: rgba(255, 138, 76, .55); }

#scanBtn { border-color: rgba(255, 93, 108, .5); }
#scanBtn.ok { border-color: rgba(74, 241, 174, .55); }
.rune-btn svg { width: 18px; height: 18px; }
.rune-btn .diamond { stroke: var(--text); stroke-width: 2.4; fill: transparent; }
.rune-btn.active .diamond { fill: var(--rune); stroke: var(--rune-soft); }
.rune-btn.active.blink .diamond { fill: var(--rune-deep); stroke: #76458c; }
.rune-btn.active { border-color: rgba(201, 109, 255, .6); box-shadow: 0 0 22px rgba(201, 109, 255, .25); }

.status-card { flex-shrink: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.status-card strong { font-size: 13px; color: var(--muted); }
.status-list { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; font-size: 13px; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 설정 탭 */
.tabs-card { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; }
.tabs button { flex-shrink: 0; height: 40px; padding: 0 16px; border-radius: 10px; border-color: transparent; background: transparent; color: var(--muted); }
.tabs button:hover { background: #1b2021; color: var(--text); }
.tabs button.on { background: #262d2e; color: var(--text); border-color: #3a4346; }
.tabs button:focus-visible { outline: 2px solid var(--mint); outline-offset: 1px; }
.tab-body { flex: 1; min-height: 0; overflow: auto; padding: 22px 24px; }
.pane { display: flex; flex-direction: column; gap: 18px; }
.pane[hidden] { display: none; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.two-col .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
button.fit { align-self: flex-start; }

#previewCanvas { width: 100%; height: auto; background: #050606; border-radius: 12px; border: 1px solid var(--line); image-rendering: pixelated; }
.diag-info { margin: 0; white-space: pre-wrap; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; line-height: 1.6; color: #c8d0d2; background: var(--surface); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row button { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.field b { color: var(--text); font-weight: 600; }
.field.grow { flex: 1; }
input[type=number], input[type=text], select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--text); width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--mint); }
.apply-row { display: flex; align-items: flex-end; gap: 10px; }
.field small { color: var(--muted); font-size: 11px; font-weight: 400; margin-left: 4px; }

.sound-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.sound-head, .sound-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 150px minmax(80px, 130px) 32px; align-items: center; gap: 12px; }
.sound-head { padding: 0 12px; font-size: 12px; color: var(--muted); }
.sound-head small { margin-left: 4px; }
.sound-row { padding: 9px 12px; background: var(--surface); color: var(--text); font-size: 14px; }
.seg.mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg); }
.seg.mini button { padding: 6px 0; font-size: 12px; border-radius: 7px; }
.sound-row + .sound-row { border-top: 1px solid var(--line); }
.sound-row select { padding: 7px 9px; }
.sound-row b { text-align: right; font-size: 12px; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

.icon-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.icon-row canvas { width: 32px; height: 32px; border-radius: 6px; background: #050606; image-rendering: pixelated; flex-shrink: 0; }
.icon-state { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.icon-row button { padding: 6px 10px; font-size: 12px; }
.icon-row button[hidden] { display: none; }
.apply-row .seg { align-self: auto; }

.toggle-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; font-size: 14px; background: var(--surface); }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { flex-shrink: 0; width: 44px; height: 24px; border-radius: 99px; background: #2a3031; position: relative; transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #f4f6f7; transition: transform .15s; }
.toggle input:checked + i { background: var(--mint); }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 2px solid var(--mint); outline-offset: 2px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; align-self: flex-start; }
.seg button { border: none; background: transparent; padding: 7px 16px; border-radius: 9px; color: var(--muted); }
.seg button.on { background: var(--mint); color: var(--mint-ink); }

.note { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.mute-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mute-list:empty::before { content: "등록된 맵이 없습니다."; color: var(--muted); font-size: 13px; }
.mute-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.mute-item canvas { background: #050606; border-radius: 6px; image-rendering: pixelated; max-width: 130px; height: auto; }
.mute-item .name { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mute-item.hit { border-color: rgba(255, 138, 76, .6); }
.mute-item button { padding: 6px 10px; font-size: 12px; }
.license { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .82); display: flex; flex-direction: column; }
.overlay[hidden] { display: none; }
.select-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; font-weight: 600; }
.select-stage { position: relative; flex: 1; margin: 0 16px 16px; display: grid; place-items: center; overflow: hidden; }
#selectCanvas.zoom { max-width: none; max-height: none; image-rendering: pixelated; }
#selectCanvas { max-width: 100%; max-height: 100%; cursor: crosshair; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.select-box { position: absolute; border: 2px solid var(--mint); background: rgba(74, 241, 174, .12); pointer-events: none; }

.modal-wrap { align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; max-width: 480px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.modal h2 { margin: 0; font-size: 18px; }
.modal-body { overflow: auto; font-size: 13.5px; line-height: 1.65; color: #cfd6d8; }
.modal-body h3 { font-size: 14px; margin: 14px 0 4px; color: var(--text); }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { margin: 0; }
.confirm { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; cursor: pointer; }
.confirm input { margin-top: 3px; accent-color: var(--mint); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: #f4f6f7; color: #0b0d0e; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }

/* ───── 위젯 (Document Picture-in-Picture 창) ───── */
.widget { height: 100vh; display: flex; flex-direction: column; background: var(--surface); user-select: none; }
.w-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; }
.w-count { cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.w-num { font-size: 46px; font-weight: 200; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.w-count.paused .w-num { color: var(--muted); }
.w-bar { height: 6px; background: #222829; border-radius: 99px; overflow: hidden; }
.w-bar div { height: 100%; width: 0; background: var(--mint); border-radius: inherit; }
.w-count.paused .w-bar div { background: #4f5a5c; }
.w-side { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.w-side svg { width: 44px; height: 44px; }
.w-side .diamond { fill: transparent; stroke: var(--text); stroke-width: 2.4; }
.w-side.active .diamond { fill: var(--rune); stroke: var(--rune-soft); }
.w-side.active.blink .diamond { fill: var(--rune-deep); stroke: #76458c; }
.w-cool { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.w-side.muted .w-cool { color: var(--warn); }
.w-janus { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 0 14px; height: 50px; border-top: 1px solid var(--line); cursor: pointer; }
.w-janus[hidden] { display: none; }
.w-jname { font-size: 13px; font-weight: 600; color: var(--muted); }
.w-jtime { font-size: 24px; font-weight: 300; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 64px; text-align: right; }
.w-janus .w-bar div { background: #ffc65c; }
.w-janus.running .w-jname { color: #ffc65c; }
.w-janus.running .w-jtime { color: var(--text); }
.w-janus.soon .w-jtime, .w-janus.ended .w-jtime, .w-janus.ended .w-jname { color: var(--warn); }
.w-janus.soon .w-bar div { background: var(--warn); }
.w-janus.ended { background: rgba(255, 138, 76, .1); }

@media (max-width: 960px), (max-height: 600px) {
  .app { height: auto; min-height: 0; max-width: 600px; padding: 16px 16px 40px; }
  .top { flex-wrap: wrap; }
  .top-actions { width: 100%; }
  .share { flex: 1; max-width: none; }
  .layout { display: flex; flex-direction: column; }
  .status-col { overflow: visible; }
  .tabs-card { overflow: visible; }
  .tab-body { overflow: visible; padding: 18px 16px; }
}
@media (max-width: 560px) {
  .two-col { grid-template-columns: 1fr; }
  .sound-head { display: none; }
  .sound-row { grid-template-columns: 52px minmax(0, 1fr) 32px; row-gap: 8px; }
  .sound-row select, .sound-row .seg { grid-column: 2 / 4; }
  .sound-row input[type=range] { grid-column: 2 / 3; }
  .countdown { gap: 14px; padding: 14px; }
  .ring-wrap { width: 120px; height: 120px; }
  .count-num { font-size: 44px; }
  .apply-row { flex-wrap: wrap; }
  .share-text span { display: none; }
}
