:root {
  color-scheme: light;
  --ink: #223831;
  --muted: #667367;
  --green: #26483f;
  --green-bright: #356659;
  --paper: #f6f0de;
  --card: #fffaf0;
  --line: #cfcbb4;
  --gold: #e2b24c;
  --red: #b84332;
  --shadow: rgba(20, 40, 34, 0.28);
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #1d312b;
  user-select: none;
}

button, select {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.kairo-shell {
  max-width: 960px;
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 2px solid #405c50;
  border-right: 2px solid #405c50;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

/* 1. Top HUD Bar */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  background: var(--green);
  color: #fff8e4;
  border-bottom: 3px solid var(--gold);
  flex-shrink: 0;
  min-height: 52px;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.hud-pill {
  background: rgba(15, 32, 27, 0.45);
  border: 1px solid rgba(226, 178, 76, 0.45);
  border-radius: 6px;
  padding: 4px 9px;
  display: flex;
  flex-direction: column;
  min-width: 72px;
  position: relative;
}

.hud-pill.clickable {
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.hud-pill.clickable:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hud-pill small {
  font-size: 9px;
  color: #d2d8c5;
  letter-spacing: 0.5px;
  line-height: 1.1;
}

.hud-pill strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: nowrap;
}

.hud-pill.victim-pill {
  border-color: #e07a68;
  background: rgba(150, 38, 26, 0.38);
}

.hud-pill.victim-pill strong {
  color: #ffb8ab;
}

.week-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
}

.week-bar i {
  display: block;
  height: 100%;
  background: var(--gold);
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.hud-btn {
  background: #335b4f;
  color: #fff8e2;
  border: 1px solid #7d9683;
  border-radius: 5px;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-btn.active {
  background: var(--gold);
  color: #20352d;
  border-color: #fff2be;
}

/* 2. Center Main Pixel Stage */
.stage-area {
  position: relative;
  flex: 1;
  min-height: 180px;
  background: radial-gradient(ellipse at 50% 55%, #e8ecd7 0%, #c8d4c0 78%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#office {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: manipulation;
}

.stage-top-overlay {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.office-badge, .schedule-chip {
  pointer-events: auto;
  background: rgba(34, 56, 49, 0.86);
  color: #fff8e4;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(226, 178, 76, 0.6);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.schedule-chip {
  cursor: pointer;
  background: rgba(246, 240, 222, 0.94);
  color: var(--ink);
  border: 1px solid #8a9985;
  font-weight: 600;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #67c26f;
  display: inline-block;
}

.placement-bar {
  position: absolute;
  top: 42px;
  left: 12px;
  right: 12px;
  background: #f5ce6e;
  color: #2b3322;
  border: 2px solid #967223;
  border-radius: 6px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 4;
}

.placement-bar[hidden] {
  display: none !important;
}

.placement-bar button {
  background: #fff9e6;
  border: 1px solid #7d6223;
  border-radius: 4px;
  padding: 3px 9px;
  font-size: 11px;
}

.stage-ticker {
  position: absolute;
  bottom: 7px;
  left: 10px;
  right: 10px;
  background: rgba(34, 56, 49, 0.88);
  color: #f6eed8;
  border: 1px solid rgba(212, 189, 128, 0.5);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ticker-tag {
  background: var(--gold);
  color: #223831;
  font-weight: 700;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.ticker-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

/* 3. Mid Dock: Active Project Slots + Staff Strip */
.mid-dock {
  background: #e9e4cf;
  border-top: 2px solid #b5bca4;
  padding: 7px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.project-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
}

.slot-card {
  background: var(--card);
  border: 1.5px solid #96a48e;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  min-height: 44px;
}

.slot-card.empty-ready {
  border: 1.5px dashed var(--green);
  background: #f3f7ea;
  animation: pulseBorder 2s infinite;
}

.slot-card.crisis-slot {
  background: #fff0ed;
  border: 2px solid var(--red);
  animation: pulseCrisis 1.1s infinite;
}

@keyframes pulseBorder {
  0%, 100% { border-color: #26483f; }
  50% { border-color: #d49d2a; }
}

@keyframes pulseCrisis {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.012); }
}

.slot-info {
  flex: 1;
  min-width: 0;
}

.slot-info strong {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-info small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.slot-bar {
  width: 68px;
  height: 7px;
  background: #dce2d2;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.slot-bar i {
  display: block;
  height: 100%;
  background: var(--green-bright);
  transition: width 0.25s linear;
}

.staff-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.worker-chip {
  background: #f8f4e6;
  border: 1px solid #b6bfa8;
  border-bottom: 2px solid #94a188;
  border-radius: 6px;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 112px;
  flex: 1;
  text-align: left;
}

.worker-chip canvas {
  width: 24px;
  height: 30px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.worker-chip-meta {
  min-width: 0;
  flex: 1;
}

.worker-chip-meta strong {
  display: block;
  font-size: 11px;
  white-space: nowrap;
}

.worker-chip-meta small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fatigue-mini {
  height: 3px;
  background: #dde0d1;
  border-radius: 2px;
  margin-top: 2px;
  overflow: hidden;
}

.fatigue-mini i {
  display: block;
  height: 100%;
  background: #6a9970;
}

/* 4. Bottom Command Bar */
.cmd-dock {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 7px 10px max(8px, env(safe-area-inset-bottom));
  background: var(--green);
  border-top: 2px solid #193029;
  flex-shrink: 0;
}

.cmd-btn {
  background: #f5efdc;
  color: var(--ink);
  border: 1.5px solid #d5c79e;
  border-bottom: 3px solid #b8a472;
  border-radius: 7px;
  padding: 7px 4px;
  min-height: 44px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  position: relative;
}

.cmd-btn:active {
  transform: translateY(1px);
}

.cmd-btn.active {
  background: var(--gold);
  border-color: #fff3c4;
  color: #1d312b;
}

.cmd-badge {
  position: absolute;
  top: -5px;
  right: 4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1.5px solid #fff8e4;
}

.cmd-badge[hidden] {
  display: none !important;
}

/* 5. Kairosoft Pop-up Modal Overlay */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 27, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-window {
  background: var(--paper);
  border: 3px solid var(--green);
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  max-height: 84dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.modal-window.crisis-window {
  border-color: var(--red);
}

.modal-header {
  background: var(--green);
  color: #fff8e4;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}

.crisis-window .modal-header {
  background: var(--red);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 12px;
}

.modal-body {
  padding: 13px 14px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

/* Sub-tabs inside Modals */
.pill-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(66px, 1fr));
  gap: 5px;
  margin-bottom: 11px;
}

.pill-tab {
  background: #e7e2ce;
  border: 1px solid #bfbba4;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.pill-tab small {
  display: block;
  font-size: 9px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.pill-tab.active {
  background: var(--green);
  color: #fff8e4;
  border-color: var(--green);
}

.pill-tab.active small {
  color: #e2b24c;
}

/* Case Situation Box & Action Cards */
.situation-box {
  background: var(--card);
  border: 1px solid #d4ceb8;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.situation-box h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-family: 'Songti SC', 'Noto Serif CJK SC', serif;
}

.situation-box p {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  color: #394a42;
}

.assignee-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #eae5d1;
  padding: 7px 10px;
  border-radius: 6px;
  margin-bottom: 9px;
  font-size: 12px;
}

.assignee-bar select {
  flex: 1;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid #a9b39d;
  background: #fffdf6;
  font-size: 12px;
  font-weight: 600;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1.5px solid var(--green);
  border-radius: 7px;
  padding: 9px 11px;
  transition: background 0.12s;
}

.option-btn:hover:not(:disabled) {
  background: #efeadd;
}

.option-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
}

.option-desc {
  font-size: 11px;
  color: #4b5950;
  margin: 4px 0;
  line-height: 1.5;
}

.option-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  padding-top: 4px;
  border-top: 1px dashed #dcd7c2;
}

.option-meta .warn {
  color: var(--red);
}

/* Settlement & Story Cards */
.settlement-box {
  background: var(--card);
  border: 1px solid #d4ceb8;
  border-radius: 7px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}

.red-stamp {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 2px solid #b83a2a;
  color: #b83a2a;
  background: rgba(255, 245, 240, 0.88);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 4px;
  transform: rotate(-7deg);
  box-shadow: inset 0 0 0 1px rgba(184, 58, 42, 0.28);
  pointer-events: none;
}

.kpi-formula {
  background: #283f37;
  color: #f7df9c;
  border-radius: 5px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

.settlement-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--green);
  color: #fff8e4;
  margin-bottom: 6px;
}

.settlement-box h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-family: 'Songti SC', serif;
  padding-right: 92px;
}

.settlement-human {
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 9px;
}

.settlement-office {
  background: #f0e7d3;
  border-left: 3px solid var(--red);
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.55;
  color: #6b533b;
  margin-bottom: 8px;
}

.settlement-voice {
  border-left: 2px solid var(--gold);
  padding-left: 9px;
  font-family: 'Songti SC', serif;
  font-size: 12.5px;
  color: #6e5938;
  margin: 6px 0 0;
}

/* Staff & Facility Rows */
.list-card {
  background: var(--card);
  border: 1px solid #d2cdb8;
  border-radius: 7px;
  padding: 9px 11px;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.list-card-main {
  flex: 1;
  min-width: 0;
}

.list-card-main strong {
  display: block;
  font-size: 13px;
}

.list-card-main small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.45;
}

.action-btn {
  background: var(--green);
  color: #fff8e4;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.toast-pop {
  position: absolute;
  bottom: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(25, 48, 41, 0.95);
  color: #fff8e4;
  border: 1px solid var(--gold);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  z-index: 30;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-pop.show {
  opacity: 1;
}

@media (max-width: 600px) {
  .hud-bar { padding: 5px 8px; min-height: 46px; }
  .hud-pill { padding: 3px 6px; min-width: 60px; }
  .hud-pill strong { font-size: 12px; }
  .cmd-btn { font-size: 12px; min-height: 40px; padding: 5px 2px; }
  .modal-backdrop { padding: 8px; }
  .modal-window { max-height: 88dvh; }
}
