:root {
  --bg: #08080b;
  --panel: rgba(16, 16, 22, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8e8f0;
  --dim: #9a9aa8;
  --red: #c8202a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
}

#game { display: block; image-rendering: pixelated; }

.hidden { display: none !important; }

kbd {
  background: #23232c;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font: 600 11px ui-monospace, monospace;
  color: #d8d8e4;
}

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, #16161f 0%, #06060a 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 40;
  padding: 24px;
}

.screen h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 62px);
  letter-spacing: 6px;
  font-weight: 800;
}
.screen h1 span { color: var(--red); }
.tag { margin: 0; color: var(--dim); letter-spacing: 1px; }
.keys { color: var(--dim); font-size: 13px; margin-top: 6px; }

#roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 118px));
  gap: 10px;
  max-width: 760px;
  justify-content: center;
  margin-top: 8px;
}

.card {
  background: #12121a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text);
  transition: transform .1s, border-color .1s, background .1s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--red);
  background: #1a1420;
}
.card canvas { image-rendering: pixelated; }
.card.lead { border-color: #c8a02a; }
.card.lead .crole { color: #ffd65a; }
.cname { font-weight: 700; font-size: 14px; }
.crole { font-size: 10px; color: var(--dim); text-align: center; }

#end h2 { font-size: clamp(24px, 4vw, 40px); margin: 0; letter-spacing: 2px; }
#end p { color: var(--dim); max-width: 520px; text-align: center; line-height: 1.5; }
#replay {
  margin-top: 10px;
  background: var(--red);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

#topbar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  backdrop-filter: blur(6px);
}

.angerwrap { width: min(46vw, 420px); }
.angerlabel {
  display: flex;
  justify-content: space-between;
  font: 700 11px ui-monospace, monospace;
  letter-spacing: 2px;
  color: #ff8a7a;
  margin-bottom: 5px;
}
.bar {
  height: 12px;
  background: #1c1c24;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.bar.small { height: 7px; }
.bar > div { height: 100%; width: 0; transition: width .15s linear; }

#clockwrap { text-align: right; min-width: 96px; }
#clock { font: 700 17px ui-monospace, monospace; }
.shiftbar {
  height: 4px;
  background: #1c1c24;
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}
#shiftFill { height: 100%; background: #6a8fd0; width: 0; }

#tasklist {
  position: absolute;
  top: 84px;
  right: 14px;
  width: 236px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px 10px;
  backdrop-filter: blur(6px);
  pointer-events: auto;          /* draggable, unlike the rest of the HUD */
  resize: horizontal;
  overflow: hidden;
  min-width: 150px;
  max-width: 420px;
}
#taskhead {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  cursor: grab;
}
#taskhead:active { cursor: grabbing; }
#taskhead .grip { color: #55555f; font-size: 12px; line-height: 1; }
#taskToggle {
  margin-left: auto;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #1a1a22;
  color: var(--dim);
  font: 700 13px/1 ui-monospace, monospace;
  cursor: pointer;
}
#taskToggle:hover { color: var(--text); border-color: var(--red); }
#tasklist.collapsed { resize: none; }
#tasklist.collapsed #tasks { display: none; }
#tasklist.collapsed { padding-bottom: 8px; }
#tasklist h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--dim);
  text-transform: uppercase;
}

/* ---------- Inventory ---------- */
#invbar {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}
#invslots { display: flex; gap: 5px; }
.slot {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(16, 16, 22, 0.85);
  position: relative;
  display: grid;
  place-items: center;
}
.slot.sel { border-color: #ffd65a; box-shadow: 0 0 0 1px rgba(255, 214, 90, 0.4); }
.slot canvas { image-rendering: pixelated; }
.slot span {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  text-align: center;
  font: 600 7.5px/1.3 system-ui, sans-serif;
  color: #c8c8d4;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 0 0 7px 7px;
  padding: 1px 0 2px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.slot .num {
  position: absolute;
  top: 1px;
  left: 3px;
  bottom: auto;
  right: auto;
  background: none;
  color: #55555f;
  font: 600 8px ui-monospace, monospace;
  padding: 0;
}
.invhint { font-size: 10px; color: var(--dim); }
.invhint kbd { font-size: 9px; padding: 0 3px; }
#tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
#tasks li { font-size: 12.5px; line-height: 1.25; }
#tasks li b { margin-right: 5px; }
#tasks li em { display: block; font-size: 10px; color: var(--dim); font-style: normal; }
#tasks li i { font-style: normal; color: #ffd65a; font-size: 11px; }
/* Target times are guidance, not a countdown — deliberately quiet. */
#tasks li i.due { color: var(--dim); font-size: 10px; }
#tasks li.done { color: #5ad07a; text-decoration: line-through; opacity: .7; }
#tasks li.failed { color: #ff6b5a; }
#tasks li.later { opacity: .45; }
#tasks li.active b { color: #ffd65a; }

#progress {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
}
#progFill { background: #ffd65a; }

#toast {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}

#question {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  background: var(--panel);
  border: 1px solid #6a2a2a;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 14px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}
#question.urgent { border-color: #ff3b30; animation: pulseRed .5s infinite alternate; }
@keyframes pulseRed {
  to { box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.18); }
}
.qhead {
  display: flex;
  justify-content: space-between;
  font: 700 10px ui-monospace, monospace;
  letter-spacing: 2px;
  color: #ff8a7a;
  margin-bottom: 6px;
}
#qAsks { color: #ff3b30; }
.qtimer {
  height: 4px;
  background: #26262e;
  border-radius: 2px;
  overflow: hidden;
  margin: 0 0 9px;
}
#qFill { height: 100%; width: 100%; background: #5ad07a; }
.portrait {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 8px;
  background: linear-gradient(160deg, #8e1119, #3a1014);
  border: 1px solid #6a2a2a;
}
.dlgbody { flex: 1; }
#qLine { margin: 0 0 8px; font-size: 15px; line-height: 1.4; }
#qOpts { display: grid; gap: 6px; }
#qOpts button {
  text-align: left;
  background: #191922;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
#qOpts button:hover { background: #23232f; border-color: var(--red); }

/* ---------- Breakroom keypad ---------- */
#keypad {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 236px;
  background: #14141b;
  border: 1px solid #3a3a46;
  border-radius: 14px;
  padding: 14px;
  pointer-events: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.kp-head {
  font: 700 10px ui-monospace, monospace;
  letter-spacing: 2px;
  color: #ffb85a;
  text-align: center;
  margin-bottom: 10px;
}
.kp-entry {
  background: #05060a;
  border: 1px solid #2a2a34;
  border-radius: 6px;
  color: #6cff9a;
  font: 700 20px ui-monospace, monospace;
  letter-spacing: 6px;
  text-align: center;
  padding: 9px 0;
  margin-bottom: 12px;
  min-height: 42px;
}
.kp-entry.err { color: #ff3b30; animation: shake .25s; }
@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.kp-grid button {
  background: #232330;
  border: 1px solid #3a3a46;
  border-bottom-width: 2px;
  border-radius: 7px;
  color: #e8e8f0;
  font: 700 17px ui-monospace, monospace;
  padding: 11px 0;
  cursor: pointer;
}
.kp-grid button:hover { background: #2e2e3d; }
.kp-grid button:active { transform: translateY(1px); border-bottom-width: 1px; }
.kp-foot { margin-top: 10px; font-size: 10px; color: var(--dim); text-align: center; }

#paused {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 4, 8, 0.6);
  font: 800 34px ui-monospace, monospace;
  letter-spacing: 8px;
}
