@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&family=Noto+Serif+KR:wght@600;900&display=swap");

:root {
  --bg: #0c0e14;
  --bg2: #12151e;
  --panel: #171b26;
  --panel2: #1e2331;
  --line: #2a3042;
  --line2: #394057;
  --text: #e8e6e1;
  --muted: #9097a8;
  --dim: #626a7d;
  --gold: #d9b36c;
  --gold2: #f0d59b;
  --crimson: #d0564b;
  --hp: #d0564b;
  --mp: #5b8fd9;
  --ok: #6cc08b;
  --warn: #e3a04f;
  --party: #6fb3d2;
  --enemy: #d0564b;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #1c2233 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.5 "Noto Sans KR", system-ui, sans-serif;
}
h1, h2, h3, .serif { font-family: "Noto Serif KR", serif; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }

.btn {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #e2bf7a, #b88f45); color: #1b1408; border-color: #e7c88a; font-weight: 700; }
.btn.danger { border-color: #7a3a35; color: #f0a39b; }
.btn.ok { border-color: #3f7a55; color: #9fe0b6; }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.ghost { background: transparent; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 60px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ───── 로그인 ───── */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 4px; font-size: 26px; color: var(--gold2); }
.auth-card form { display: grid; gap: 12px; margin-top: 18px; }
.auth-card .field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.err { color: #f0a39b; min-height: 20px; font-size: 13px; }

/* ───── 게임 레이아웃 ───── */
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }
header.top {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px; border-bottom: 1px solid var(--line);
  background: rgba(12, 14, 20, .8); backdrop-filter: blur(6px);
}
header.top .title { font-family: "Noto Serif KR", serif; font-weight: 900; font-size: 18px; color: var(--gold2); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line2); color: var(--muted); }
.badge.gm { border-color: var(--gold); color: var(--gold); }
.badge.live { border-color: #3f7a55; color: var(--ok); }
.badge.off { border-color: #7a3a35; color: #f0a39b; }
.online { display: flex; gap: 4px; }
.online .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--panel2); border: 1px solid var(--line2); }
.online .dot.gm { border-color: var(--gold); color: var(--gold); }

/* 턴 바 */
.turnbar {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 10px 16px 12px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #131722, #0f121a);
}
.turn-track { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 4px; align-items: flex-end; scrollbar-width: thin; }
.turn-label { font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.tchip {
  position: relative; flex: 0 0 auto; width: 64px; text-align: center; opacity: .8; transition: transform .25s, opacity .25s;
}
.tchip .pt {
  width: 48px; height: 48px; margin: 0 auto; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 18px;
  border: 2px solid var(--line2); background: var(--panel2); background-size: cover; background-position: center; color: #10131b;
}
.tchip.enemy .pt { border-radius: 50%; }
.tchip .nm { font-size: 11px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tchip .spd { font-size: 10px; color: var(--muted); }
.tchip.done { opacity: .45; }
.tchip.dead { opacity: .3; filter: grayscale(1); }
.tchip.dead .pt::after { content: "✕"; position: absolute; font-size: 26px; color: #fff; }
.tchip.current { opacity: 1; transform: translateY(-4px) scale(1.12); z-index: 2; }
.tchip.current .pt { border-color: var(--gold2); box-shadow: 0 0 0 3px rgba(217, 179, 108, .25), 0 0 18px rgba(240, 213, 155, .55); }
.tchip.current .nm { color: var(--gold2); font-weight: 700; }
.tchip.mine .nm::before { content: "● "; color: var(--party); font-size: 8px; vertical-align: 2px; }
.tsep { flex: 0 0 auto; width: 1px; align-self: stretch; background: var(--line2); margin: 0 6px; position: relative; }
.tsep span { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--dim); white-space: nowrap; background: #11141d; padding: 0 3px; }
.gm-arrows { display: flex; justify-content: center; gap: 2px; margin-top: 2px; }
.gm-arrows button { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 10px; padding: 0 3px; }
.gm-arrows button:hover { color: var(--gold); }

.timer { min-width: 190px; text-align: right; }
.timer .big { font-family: "Noto Serif KR", serif; font-size: 34px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.timer .big.warn { color: var(--warn); }
.timer .big.crit { color: var(--crimson); animation: pulse .8s infinite; }
.timer .big.paused { color: var(--dim); }
.timer .bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.timer .bar i { display: block; height: 100%; background: var(--gold); transition: width .2s linear; }
.timer .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.timer .ctrls { display: flex; gap: 4px; justify-content: flex-end; margin-top: 5px; }
@keyframes pulse { 50% { opacity: .5; } }

.main { display: grid; grid-template-columns: 300px 1fr 360px; min-height: 0; }
.col { min-height: 0; overflow-y: auto; padding: 14px; }
.col.left { border-right: 1px solid var(--line); }
.col.right { border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.sect-h { font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; margin: 4px 0 8px; display: flex; justify-content: space-between; align-items: center; }

/* 캐릭터 카드 */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; position: relative;
  transition: border-color .2s, box-shadow .2s;
}
.card.current { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(217, 179, 108, .3), 0 0 24px rgba(217, 179, 108, .12); }
.card.dead { opacity: .55; }
.card.hiddenc { border-style: dashed; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--line2); }
.card.targeted { border-color: var(--party); box-shadow: 0 0 0 2px rgba(111, 179, 210, .35); }
.chead { display: flex; gap: 10px; align-items: center; }
.avatar { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center; font-weight: 900; color: #10131b; background-size: cover; background-position: center; }
.cname { font-weight: 700; }
.cowner { font-size: 11px; color: var(--muted); }
.res { margin-top: 7px; }
.res .lab { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.res .lab b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.meter { height: 7px; background: #0b0d13; border-radius: 4px; overflow: hidden; border: 1px solid #0a0c11; }
.meter i { display: block; height: 100%; border-radius: 4px; transition: width .4s ease; }
.statuses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.st { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #2a2336; border: 1px solid #4a3d61; color: #d7c7f0; }
.st.buff { background: #1f3326; border-color: #3f7a55; color: #b6e6c6; }
.cds { font-size: 11px; color: var(--warn); margin-top: 4px; }

.boss-zone { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 14px; }
.card.enemy { background: linear-gradient(180deg, #1f1719, var(--panel)); border-color: #3b2527; }
.card.enemy.current { border-color: var(--crimson); box-shadow: 0 0 24px rgba(208, 86, 75, .2); }
.card.boss { padding: 14px; }
.card.boss .avatar { width: 56px; height: 56px; border-radius: 50%; font-size: 22px; }
.card.boss .cname { font-family: "Noto Serif KR", serif; font-size: 20px; color: #f3c0b9; }
.card.boss .meter { height: 12px; }

/* 패널 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.panel.hl { border-color: var(--gold); background: linear-gradient(180deg, #221f18, var(--panel)); }
.panel h3 { margin: 0 0 10px; font-size: 16px; color: var(--gold2); display: flex; align-items: center; gap: 8px; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.skill {
  text-align: left; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; transition: border-color .15s;
}
.skill:hover { border-color: var(--line2); }
.skill.sel { border-color: var(--gold); background: #231f16; }
.skill.cd { opacity: .6; }
.skill .sn { font-weight: 700; font-size: 13px; }
.skill .sm { font-size: 11px; color: var(--muted); }
.skill-desc { font-size: 12px; color: var(--muted); background: var(--bg2); border-radius: 8px; padding: 8px 10px; margin-top: 8px; white-space: pre-wrap; }
.tchips { display: flex; flex-wrap: wrap; gap: 5px; }
.tpick { font-size: 12px; padding: 4px 10px; border-radius: 99px; border: 1px solid var(--line2); background: var(--bg2); cursor: pointer; }
.tpick.enemy { border-color: #5a3330; }
.tpick.on { background: var(--gold); color: #1b1408; border-color: var(--gold); font-weight: 700; }
.tpick.off { opacity: .4; }
.field-l { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }

.pending { border: 1px solid var(--line2); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--bg2); }
.pending .ph { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pending .quote { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--gold); background: #1a1c24; white-space: pre-wrap; border-radius: 0 6px 6px 0; }
.warns { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.warns span { font-size: 11px; color: var(--warn); border: 1px solid #6b4d26; border-radius: 99px; padding: 0 7px; }
.rolls { margin: 6px 0; display: grid; gap: 3px; }
.rolls div { font-size: 12px; font-family: ui-monospace, Menlo, monospace; background: #12141b; padding: 3px 8px; border-radius: 5px; }
.rolls b { color: var(--gold2); font-size: 14px; }
.eff { display: grid; grid-template-columns: 1fr 70px 80px auto; gap: 4px; margin-bottom: 4px; }
.eff2 { display: grid; grid-template-columns: 1fr 1fr 60px auto; gap: 4px; margin-bottom: 4px; }
.subbox { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 8px; }
.waiting { display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 로그 */
.log { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.lg { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.lg .t { font-size: 10px; color: var(--dim); margin-right: 6px; }
.lg.chat .who { font-weight: 700; color: var(--party); margin-right: 4px; }
.lg.chat.gm .who { color: var(--gold); }
.lg.system, .lg.adjust, .lg.status { color: var(--muted); font-size: 12px; }
.lg.turn { color: var(--gold2); font-weight: 700; margin-top: 6px; }
.lg.round, .lg.initiative { color: var(--gold); text-align: left; background: #1a1810; border: 1px solid #3a321f; padding: 6px 8px; border-radius: 8px; }
.lg.roll { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #151822; padding: 4px 8px; border-radius: 6px; }
.lg.roll.secret { border: 1px dashed var(--gold); }
.lg.declare { background: #161b26; border-left: 3px solid var(--party); padding: 5px 8px; border-radius: 0 6px 6px 0; }
.lg.judge { padding: 5px 8px; border-radius: 6px; border: 1px solid; }
.lg.judge.approve { border-color: #3f7a55; background: #14211a; }
.lg.judge.partial { border-color: #6b5a26; background: #211d12; }
.lg.judge.reject { border-color: #7a3a35; background: #241514; }
.lg.narration { font-family: "Noto Serif KR", serif; font-size: 15px; color: #efe5cf; background: linear-gradient(90deg, #221d12, transparent); border-left: 3px solid var(--gold); padding: 8px 10px; }
.lg.down { color: #f0a39b; font-weight: 700; }
.lg.timer { color: var(--warn); }
.chatbar { border-top: 1px solid var(--line); padding: 10px; display: grid; gap: 6px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--gold2); border-bottom-color: var(--gold); }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 6, 10, .7); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal .mh h2 { margin: 0; font-size: 18px; color: var(--gold2); }
.modal .mb { padding: 16px 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kv .mono { white-space: nowrap; }
.kv { display: grid; grid-template-columns: 44px 120px minmax(50px,1fr) auto; gap: 6px; align-items: center; margin-bottom: 6px; }
table.users { width: 100%; border-collapse: collapse; }
table.users td, table.users th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a1717; border: 1px solid #7a3a35; color: #f5c2bc; padding: 10px 16px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); }
.toast.info { background: #221f16; border-color: var(--gold); color: var(--gold2); }
.myturn-flash { position: fixed; inset: 0; pointer-events: none; z-index: 40; box-shadow: inset 0 0 120px rgba(217, 179, 108, .45); animation: flash 1.6s ease-out forwards; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

@media (max-width: 1180px) {
  .main { grid-template-columns: 260px 1fr; }
  .col.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); height: 420px; }
  .app { height: auto; min-height: 100vh; }
}
@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; }
  .col.left { border-right: 0; }
  .col.center { order: -1; }
  .turnbar { grid-template-columns: 1fr; }
  .timer { text-align: left; }
  .timer .ctrls { justify-content: flex-start; }
  header.top { flex-wrap: wrap; }
  .grid2 { grid-template-columns: 1fr; }
}
