* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1b1d23;
  --panel: #262a33;
  --panel2: #2f3440;
  --accent: #ffb347;
  --accent2: #6ec5ff;
  --text: #e8eaed;
  --muted: #9aa0ac;
  --good: #6fcf6f;
  --bad: #ff6b6b;
  --warn: #ffd166;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-card, .final-card {
  background: var(--panel);
  padding: 36px 40px;
  border-radius: 16px;
  width: 460px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  text-align: center;
}
.final-card { width: 560px; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.subtitle { color: var(--muted); margin-bottom: 22px; }
.login-avatar {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: block;
  background: var(--panel2);
  border: 3px solid var(--accent);
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}
.login-card label, .field-row label { display: block; text-align: left; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login-card input, .login-card select {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid #3a3f4b;
  background: var(--panel2); color: var(--text); font-size: 15px;
}
.field-row { margin-top: 4px; }
button {
  cursor: pointer; border: none; border-radius: 10px;
  background: var(--accent); color: #1b1d23; font-weight: 700; font-size: 15px;
  padding: 12px 18px; margin-top: 20px; transition: transform .05s ease, filter .15s;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
.error { color: var(--bad); min-height: 18px; margin-top: 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; }
.hint code { background: #00000033; padding: 1px 5px; border-radius: 4px; }

/* ---------- HUD ---------- */
#game-screen { justify-content: flex-start; }
#hud {
  width: 100%; height: 54px; background: var(--panel);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid #00000040; z-index: 5;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 18px; }
#clock-canvas { display: block; }
.hud-clock { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent2); }
.hud-stat { font-size: 16px; }
.hud-stress { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.stress-bar { width: 156px; height: 12px; background: #00000055; border-radius: 8px; overflow: hidden; }
#stress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); transition: width .3s; }
.hud-name { color: var(--muted); font-size: 14px; }
#btn-tasks { margin-top: 0; padding: 8px 14px; font-size: 14px; }

/* ---------- Stage ---------- */
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
#canvas { background: #14161b; display: block; max-width: 100%; max-height: 100%; }
.interact-prompt {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #000000bb; padding: 8px 16px; border-radius: 20px; font-size: 14px;
  border: 1px solid #ffffff22; pointer-events: none;
}
.interact-prompt b { color: var(--accent); }

.carried {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #1b1d23; font-weight: 700; font-size: 14px;
  padding: 7px 16px; border-radius: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.4);
}

.central-speech {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
  max-width: min(560px, 82vw); background: #f4f5f7; color: #1b1d23;
  border-radius: 18px; padding: 12px 18px; font-size: 15px; font-weight: 700;
  box-shadow: 0 12px 30px rgba(0,0,0,.35); pointer-events: none; z-index: 6;
}
.central-speech::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  border-left: 10px solid transparent; border-right: 10px solid transparent; border-top: 10px solid #f4f5f7;
}
.central-speech.warn { border: 2px solid var(--warn); }
.central-speech.danger { border: 2px solid var(--bad); }

/* ---------- Toasts ---------- */
#toast-area { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--panel2); border-left: 4px solid var(--accent);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  animation: toastIn .25s ease, toastOut .3s ease 3.4s forwards; max-width: 460px;
}
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }
.toast.warn { border-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- Panels ---------- */
.panel {
  position: absolute; top: 70px; right: 16px; width: 380px; max-height: calc(100% - 90px);
  background: var(--panel); border-radius: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.5);
  display: flex; flex-direction: column; z-index: 10; overflow: hidden;
}
#dialogue-window { left: 16px; right: auto; width: 420px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #00000040; }
.panel-head h2 { font-size: 17px; }
.close-btn { background: transparent; color: var(--muted); font-size: 16px; margin: 0; padding: 4px 8px; }
.close-btn:hover { color: var(--text); }

/* ---------- Task list ---------- */
.task-list { overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.task-card { background: var(--panel2); border-radius: 10px; padding: 12px; border-left: 4px solid var(--muted); }
.task-card.urgent { border-left-color: var(--bad); }
.task-card.warning { border-left-color: var(--warn); }
.task-card.high { border-left-color: var(--warn); }
.task-card.done { opacity: .5; }
.task-card.delegated { border-left-color: var(--accent2); }
.task-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.task-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.task-badge { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #00000055; white-space: nowrap; }
.task-timer { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; margin-top: 8px; }
.task-bar { height: 8px; background: #00000055; border-radius: 999px; overflow: hidden; }
.task-bar-fill { height: 100%; background: var(--accent2); transition: width .25s linear, background .2s; }
.task-bar-fill.warn { background: var(--warn); }
.task-bar-fill.danger { background: var(--bad); }
.task-deadline { font-variant-numeric: tabular-nums; color: var(--accent2); min-width: 48px; text-align: right; }
.task-deadline.warn { color: var(--warn); font-weight: 700; }
.task-deadline.danger { color: var(--bad); font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 20px; font-size: 14px; }

/* ---------- Dialogue ---------- */
.dlg-who { display: flex; align-items: center; gap: 12px; }
.dlg-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #1b1d23; font-size: 18px; }
.dlg-role { font-size: 12px; color: var(--muted); }
.dlg-history { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; max-height: 320px; }
.bubble { padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.4; max-width: 85%; }
.bubble.npc { background: var(--panel2); align-self: flex-start; border-bottom-left-radius: 3px; }
.bubble.me { background: var(--accent2); color: #10202b; align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble.sys { background: transparent; color: var(--muted); font-size: 12px; align-self: center; font-style: italic; }
.dlg-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid #00000040; }
.dlg-quick button { margin: 0; padding: 6px 11px; font-size: 12px; background: var(--panel2); color: var(--text); font-weight: 600; }
.dlg-quick button:hover { background: #3a4150; }
.dlg-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #00000040; }
.dlg-input-row input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid #3a3f4b; background: var(--panel2); color: var(--text); }
.dlg-input-row button { margin: 0; padding: 10px 16px; }

/* ---------- Final ---------- */
.final-card h1 { margin-bottom: 18px; }
.final-stats { text-align: left; background: var(--panel2); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.final-stats .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 15px; }
.final-stats .row span:last-child { font-weight: 700; }
.final-verdict { font-size: 16px; font-style: italic; color: var(--accent); margin-bottom: 6px; line-height: 1.5; }
.leaderboard { text-align: left; background: #1f232b; border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.leaderboard h2 { font-size: 16px; margin-bottom: 10px; }
.leader-list { display: flex; flex-direction: column; gap: 5px; }
.leader-row { display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; padding: 7px 9px; border-radius: 8px; background: #00000022; font-size: 14px; }
.leader-row.current { background: rgba(255,179,71,.22); outline: 1px solid var(--accent); }
.leader-rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.leader-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-variant-numeric: tabular-nums; color: var(--accent2); }
.leader-gap { color: var(--muted); text-align: center; padding: 2px; }
