/* Sijak: manhwa status-window look. Ink, paper, hard panel shadows, screentone. */
:root {
  --ink: #121016;
  --ink-2: #1d1a23;
  --paper: #f7f0e1;
  --paper-2: #ece2cc;
  --line: #121016;
  --red: #e63946;
  --blue: #3a86ff;
  --bronze: #c98a4b;
  --silver: #b9c0cc;
  --gold: #f4c430;
  --muted: #6d6576;
  --display: "Black Han Sans", "Noto Sans KR", system-ui, sans-serif;
  --body: "Noto Sans KR", system-ui, -apple-system, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background-color: var(--ink);
  background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1.2px);
  background-size: 7px 7px;
  color: var(--paper);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--safe-b) + 96px);
}

/* ---------- Panels ---------- */
.panel {
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--line); border-radius: 6px;
  box-shadow: 5px 5px 0 var(--line), 5px 5px 0 2px var(--paper);
  position: relative;
}
.tone { /* screentone fill */
  background-image: radial-gradient(rgba(18,16,22,.18) 1px, transparent 1.3px);
  background-size: 5px 5px;
}
.kr { font-family: var(--display); letter-spacing: .02em; }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { font-family: var(--display); font-size: 30px; line-height: 1; color: var(--paper); }
.brand small { display: block; font-family: var(--body); font-size: 11px; color: var(--gold); letter-spacing: .08em; margin-top: 4px; }
.icon-btn {
  width: 50px; height: 50px; border-radius: 50%;
  background: var(--paper); color: var(--ink); border: 3px solid var(--line);
  box-shadow: 3px 3px 0 var(--red); font-size: 26px; display: grid; place-items: center;
}

/* ---------- Status window ---------- */
.status { padding: 14px; margin-bottom: 22px; }
.status-tag {
  position: absolute; top: -13px; left: 12px; background: var(--red); color: #fff;
  border: 3px solid var(--line); font-family: var(--display); font-size: 13px; padding: 2px 10px; border-radius: 4px;
}
.status-row { display: flex; gap: 14px; align-items: center; }
.avatar {
  width: 74px; height: 74px; flex: none; font-size: 42px; display: grid; place-items: center;
  border: 3px solid var(--line); border-radius: 6px; background: var(--paper-2);
}
.who { flex: 1; min-width: 0; }
.who-name { font-family: var(--display); font-size: 24px; line-height: 1.1; border: 0; background: none; padding: 0; text-align: left; }
.who-title { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { border: 2px solid var(--line); border-radius: 4px; padding: 6px 4px; text-align: center; background: #fff8ea; }
.stat b { display: block; font-family: var(--display); font-size: 20px; }
.stat span { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }

/* ---------- Skill grid ---------- */
.section-title { font-family: var(--display); font-size: 18px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title span { font-family: var(--body); font-size: 12px; color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile {
  background: var(--paper); color: var(--ink); border: 3px solid var(--line); border-radius: 6px;
  padding: 10px 6px 8px; text-align: center; position: relative;
  box-shadow: 4px 4px 0 var(--rank, var(--bronze));
  transition: transform .08s;
}
.tile:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--rank, var(--bronze)); }
.tile.r1 { --rank: var(--bronze); }
.tile.r2 { --rank: var(--silver); }
.tile.r3 { --rank: var(--gold); background: linear-gradient(160deg, #fff6d4, var(--paper)); }
.tile.running { outline: 3px dashed var(--red); outline-offset: 3px; }
.tile .emo { font-size: 34px; line-height: 1.1; }
.tile .nm { font-size: 12px; font-weight: 900; margin-top: 4px; line-height: 1.15; min-height: 28px; display: flex; align-items: center; justify-content: center; }
.tile .hrs { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 3px; }
.badge-star { position: absolute; top: -10px; right: -8px; font-size: 20px; filter: drop-shadow(1px 1px 0 var(--ink)); }
.bar { height: 8px; border: 2px solid var(--line); border-radius: 4px; background: #fff; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--rank, var(--bronze)); }
.add-tile {
  border: 3px dashed var(--paper); border-radius: 6px; background: transparent; color: var(--paper);
  display: grid; place-items: center; min-height: 128px; font-size: 13px; font-weight: 700;
}
.add-tile b { display: block; font-size: 30px; font-family: var(--display); }

.empty { text-align: center; padding: 18px 10px 4px; color: var(--paper-2); font-size: 14px; line-height: 1.5; }
.quote { text-align: center; margin: 28px 0 0; color: var(--muted); font-size: 12px; }
.quote .kr { color: var(--paper-2); font-size: 16px; display: block; margin-bottom: 2px; }

.install-hint { padding: 20px 14px 12px; margin: 22px 0 26px; box-shadow: 5px 5px 0 var(--red); }
.install-why { margin: 0; font-size: 14px; line-height: 1.45; }
.steps { margin: 10px 0 0; padding-left: 22px; font-size: 14px; line-height: 1.5; }
.steps b { color: var(--red); }

/* ---------- Timer view ---------- */
.back { background: none; border: 0; color: var(--paper); font-weight: 700; font-size: 15px; padding: 6px 0; }
.timer-card { text-align: center; padding: 22px 16px 18px; margin-top: 10px; }
.timer-card .emo { font-size: 64px; line-height: 1; }
.timer-card h2 { font-family: var(--display); font-size: 30px; margin: 8px 0 2px; }
.rank-pill {
  display: inline-block; border: 2px solid var(--line); border-radius: 999px; padding: 2px 12px;
  font-weight: 900; font-size: 12px; background: var(--rank, var(--bronze));
}
.ring { position: relative; width: 230px; height: 230px; margin: 18px auto 8px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--paper-2); stroke-width: 16; }
.ring .prog { fill: none; stroke: var(--ink); stroke-width: 16; stroke-linecap: butt; transition: stroke-dashoffset .4s; }
.ring .prog.over { stroke: var(--gold); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; }
.clock { font-family: var(--display); font-size: 40px; font-variant-numeric: tabular-nums; }
.ring-sub { font-size: 12px; font-weight: 700; color: var(--muted); }
.ticks { display: flex; justify-content: space-between; font-size: 11px; font-weight: 900; margin: 6px 4px 0; color: var(--muted); }
.ticks .hit { color: var(--ink); }

.big-btn {
  display: block; width: 100%; margin-top: 18px; padding: 18px; border: 3px solid var(--line); border-radius: 6px;
  font-family: var(--display); font-size: 24px; background: var(--red); color: #fff; box-shadow: 5px 5px 0 var(--line);
}
.big-btn.pause { background: var(--ink); color: var(--paper); box-shadow: 5px 5px 0 var(--red); }
.big-btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--line); }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.4; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.sub-panel { padding: 14px; margin-top: 22px; }
.sub-panel h3 { font-family: var(--display); margin: 0 0 8px; font-size: 18px; }
.ref-item { margin: 0 0 10px; font-size: 14px; line-height: 1.4; }
.ref-item b { display: block; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.link-btn { background: none; border: 0; color: var(--red); font-weight: 900; padding: 6px 0; font-size: 14px; }
.danger { color: var(--muted); }
.skill-actions { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 24px; }

/* ---------- Sheets & forms ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(10,8,12,.72); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  background: var(--paper); color: var(--ink); border: 3px solid var(--line); border-bottom: 0;
  border-radius: 14px 14px 0 0; padding: 16px 16px calc(var(--safe-b) + 20px);
  animation: up .22s ease-out; position: relative; overscroll-behavior: contain;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-wrap { transition: background .18s; }
.sheet-wrap.closing { background: transparent; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: rgba(18,16,22,.25); margin: -6px auto 10px; }
.sheet-x {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff; color: var(--ink); font-size: 16px; font-weight: 900;
  display: grid; place-items: center; z-index: 2;
}
.sheet h2 { font-family: var(--display); margin: 0 0 12px; font-size: 24px; padding-right: 44px; }
.field { width: 100%; border: 3px solid var(--line); border-radius: 6px; padding: 12px; font-size: 16px; background: #fff; color: var(--ink); font-family: var(--body); }
textarea.field { min-height: 74px; resize: vertical; }
.chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 12px -16px 0; padding: 8px 16px;
  position: sticky; top: -16px; z-index: 1; background: var(--paper);
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; border: 2px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink);
  padding: 6px 12px; font-weight: 900; font-size: 13px;
}
.chips button.on { background: var(--ink); color: var(--gold); }
.request { grid-column: 1 / -1; padding: 4px 0; }
.request .btn { width: 100%; margin-top: 10px; }
.who-name .pencil { font-family: var(--body); font-size: 24px; color: var(--muted); margin-left: 8px; vertical-align: middle; }
.preset-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.preset {
  border: 2px solid var(--line); border-radius: 6px; background: #fff8ea; padding: 8px 4px; font-size: 12px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink);
}
.preset span { font-size: 24px; }
.preset[disabled] { opacity: .35; }
.custom-row { display: flex; gap: 8px; margin-top: 10px; }
.custom-row .field:first-child { width: 64px; text-align: center; font-size: 22px; padding: 8px; }
.btn {
  border: 3px solid var(--line); border-radius: 6px; padding: 12px 16px; font-weight: 900; font-size: 15px;
  background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--red);
}
a.btn { text-decoration: none; text-align: center; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1; }
.q { margin-top: 14px; }
.q label { display: block; font-weight: 900; font-size: 14px; margin-bottom: 6px; }
.q label small { font-weight: 700; color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.scale button, .choice button {
  border: 2px solid var(--line); border-radius: 4px; background: #fff; padding: 9px 0; font-weight: 900; font-size: 14px; color: var(--ink);
}
.scale button.on, .choice button.on { background: var(--ink); color: var(--gold); }
.choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Celebration overlay (manhwa panel) ---------- */
#overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
#overlay[hidden] { display: none; }
.burst-bg {
  position: absolute; inset: -50%;
  background: repeating-conic-gradient(from 0deg, var(--ink) 0deg 4deg, #2a2531 4deg 7deg);
  animation: spin 18s linear infinite;
}
.burst-bg.gold { background: repeating-conic-gradient(from 0deg, #1a1405 0deg 4deg, #5a4610 4deg 7deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.celebrate {
  position: relative; width: 100%; max-width: 380px; text-align: center; padding: 26px 18px 18px;
  transform: rotate(-2deg); animation: slam .45s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes slam { from { transform: scale(2.2) rotate(-8deg); opacity: 0; } }
.sfx {
  font-family: var(--display); font-size: 64px; line-height: 1; color: var(--red);
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill;
  position: absolute; top: -44px; left: 50%; transform: translateX(-50%) rotate(-6deg); white-space: nowrap;
}
.sfx.gold { color: var(--gold); }
.celebrate .emo { font-size: 72px; margin-top: 18px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.celebrate h2 { font-family: var(--display); font-size: 30px; margin: 6px 0 4px; }
.celebrate p { margin: 0 0 4px; font-weight: 700; color: var(--muted); }
.medal {
  display: inline-block; margin: 10px 0 2px; border: 3px solid var(--line); border-radius: 999px;
  padding: 6px 16px; font-weight: 900; background: var(--gold); box-shadow: 3px 3px 0 var(--line);
}
.medal.silver { background: var(--silver); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 24px); transform: translateX(-50%);
  background: var(--paper); color: var(--ink); border: 3px solid var(--line); border-radius: 6px;
  padding: 10px 16px; font-weight: 900; font-size: 14px; z-index: 60; box-shadow: 3px 3px 0 var(--red);
  animation: up .2s ease-out;
}
