
/* Hotfix v0.3.4.1: ensure elements marked with the HTML hidden attribute are really not displayed.
   Without this, .dialog-modal { display:grid } can override the browser default and leave
   a transparent/dim overlay on top of the game, blocking mouse controls. */
[hidden] {
  display: none !important;
}

:root {
  --bg: #17191f;
  --panel: #242833;
  --panel-2: #2f3543;
  --panel-3: #1c2029;
  --text: #f3f5f7;
  --muted: #aeb6c2;
  --accent: #ffd166;
  --accent-2: #74c0fc;
  --danger: #ff6b6b;
  --ok: #8ce99a;
  --border: rgba(255,255,255,0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #262b37, var(--bg));
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-card {
  width: min(1440px, 100%);
  background: rgba(36,40,51,0.94);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.32);
  overflow: hidden;
}

.topbar {
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(255,209,102,0.14), rgba(116,192,252,0.08));
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 22px; }
h2 { font-size: 18px; margin-bottom: 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
p { color: var(--muted); }
code { color: var(--accent); }

.status-pill {
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.loading-box {
  margin: 18px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.16);
  border-radius: 16px;
  padding: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.loading-box strong { color: var(--text); }
.loading-box.error { border-color: rgba(255,107,107,0.5); }
.loading-box.error strong { color: var(--danger); }

.game-layout {
  display: grid;
  grid-template-columns: minmax(640px, 960px) 430px;
  gap: 18px;
  padding: 18px;
}

.canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  background: #11141a;
  border-radius: 16px;
  overflow: hidden;
  align-self: start;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  cursor: pointer;
}

.side-panel {
  background: rgba(0,0,0,0.16);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  max-height: 82vh;
  overflow: auto;
}

.hint { font-size: 13px; line-height: 1.45; }
section { margin-top: 18px; }
.kv, .result-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.5;
  min-height: 48px;
}
.result-box { background: rgba(116,192,252,0.08); }

.legend-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
}
.legend-grid b {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  color: var(--text);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
}
.check-row input { accent-color: #ffd166; }

.log-box, .journal-box {
  background: #11141a;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 180px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #d7e0ea;
}
.log-row { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px dashed rgba(255,255,255,0.12); }

.journal-box {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  display: grid;
  gap: 8px;
}
.journal-empty { color: var(--muted); line-height: 1.4; }
.journal-entry {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  padding: 8px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
.journal-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
}
.journal-time { color: var(--accent); font-size: 11px; margin-bottom: 2px; }
.journal-entry strong { color: var(--text); }
.journal-entry p { margin: 4px 0 0; font-size: 12px; line-height: 1.35; color: var(--muted); }

.button-row { display: flex; gap: 8px; margin-top: 10px; }
.button-row.compact button { width: 100%; }
button {
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--accent);
  color: #222;
  font-weight: 700;
  cursor: pointer;
}
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button:hover { filter: brightness(1.06); }
button:disabled { cursor: not-allowed; opacity: 0.62; filter: none; }

.toast {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: 560px;
  background: rgba(17,20,26,0.92);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.34);
  font-size: 14px;
}

.context-menu {
  position: fixed;
  width: min(360px, calc(100vw - 16px));
  background: #202530;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.42);
  z-index: 10;
}
.context-menu h4 { margin: 0 0 5px; font-size: 15px; color: var(--accent); }
.context-desc { margin: 0 0 6px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.context-meta { margin: 0 0 8px; color: rgba(255,255,255,0.42); font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.debug-note { display: inline-block; margin-bottom: 8px; color: var(--accent-2); font-size: 11px; }
.context-actions { display: grid; gap: 6px; }
.context-action {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  width: 100%;
  margin: 0;
  text-align: left;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  font-weight: 500;
}
.context-action:hover { background: rgba(255,255,255,0.12); }
.context-action-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  font-weight: 800;
}
.context-action-copy { display: grid; gap: 2px; }
.context-action-copy strong { font-size: 13px; }
.context-action-meta, .context-action-desc { font-size: 11px; color: var(--muted); line-height: 1.25; }
.action-urgent .context-action-icon { background: rgba(255,107,107,0.22); }
.action-type-purchase .context-action-icon { background: rgba(255,209,102,0.22); }
.action-type-hire .context-action-icon { background: rgba(248,194,145,0.20); }
.action-type-diagnostic .context-action-icon,
.action-type-status_check .context-action-icon { background: rgba(116,192,252,0.22); }
.action-completed { opacity: 0.65; }
.action-locked .context-action-icon { background: rgba(174,182,194,0.20); }
.is-disabled { color: var(--muted); }

@media (max-width: 1120px) {
  .app-shell { padding: 12px; align-items: flex-start; }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { order: 2; max-height: none; }
}

.quest-box, .materials-box, .validation-box {
  background: #11141a;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 76px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  font-size: 12px;
}
.quest-empty, .materials-empty, .validation-empty { color: var(--muted); line-height: 1.4; }
.quest-entry, .material-entry, .validation-entry {
  padding: 8px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
.quest-entry strong, .material-entry strong { color: var(--text); }
.quest-entry p, .material-entry p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.quest-status {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(116,192,252,0.14);
  color: var(--accent-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.quest-steps { margin: 6px 0 0 0; padding-left: 0; list-style: none; display: grid; gap: 4px; }
.quest-steps li { color: var(--muted); }
.quest-steps li.done { color: var(--ok); }
.material-meta { margin-top: 4px; font-size: 11px; color: rgba(255,255,255,0.48); }
.validation-entry { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.validation-error { border-color: rgba(255,107,107,0.46); background: rgba(255,107,107,0.08); }
.validation-warning { border-color: rgba(255,209,102,0.40); background: rgba(255,209,102,0.08); }
.validation-info { border-color: rgba(116,192,252,0.36); background: rgba(116,192,252,0.07); }
.validation-ok { border-color: rgba(140,233,154,0.36); background: rgba(140,233,154,0.07); }
.button-row.split { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.dialog-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.42);
  z-index: 20;
  padding: 18px;
}
.dialog-card {
  width: min(620px, 100%);
  background: #202530;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.42);
}
.dialog-card h4 { margin: 0 0 6px; color: var(--accent); }
.dialog-speaker { color: var(--accent-2); font-size: 12px; margin-bottom: 8px; }
.dialog-text { color: var(--text); line-height: 1.55; white-space: pre-line; }
.dialog-options { display: grid; gap: 8px; margin-top: 14px; }
.dialog-option { text-align: left; color: #222; }
.dialog-option.secondary { color: var(--text); }
.state-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  color: var(--muted);
  font-size: 10px;
  margin-left: 4px;
}

.indicators-box, .economy-box, .assets-box {
  background: #11141a;
  border: 1px solid var(--border);
  border-radius: 12px;
  min-height: 76px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  font-size: 12px;
}
.indicator-entry, .asset-entry {
  padding: 8px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}
.indicator-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.indicator-head strong, .asset-entry strong { color: var(--text); }
.indicator-head span { color: var(--accent); font-weight: 800; }
.indicator-entry p, .asset-entry p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.indicator-bar {
  margin-top: 6px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
}
.indicator-bar span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.indicator-warning .indicator-bar span { background: var(--accent); }
.indicator-critical .indicator-bar span { background: var(--danger); }
.is-hidden-indicator { border-style: dashed; opacity: 0.86; }
.economy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.economy-grid div {
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
}
.economy-grid span { display: block; color: var(--muted); font-size: 11px; }
.economy-grid strong { display: block; margin-top: 3px; color: var(--text); font-size: 15px; }
.economy-grid strong.good { color: var(--ok); }
.economy-grid strong.bad { color: var(--danger); }
.asset-entry.owned { border-color: rgba(140,233,154,0.36); background: rgba(140,233,154,0.07); }
.asset-meta { margin-top: 5px; color: rgba(255,255,255,0.48); font-size: 11px; }
.effect-summary {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.effect-summary ul { margin: 5px 0 0 0; padding-left: 18px; color: var(--muted); }
.effect-summary li { margin: 2px 0; }

/* v0.3.6-assets-guide */
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--accent);
  color: #222;
  font-weight: 700;
  text-decoration: none;
}
.button-link:hover { filter: brightness(1.06); }

/* v0.3.8-economy-assets */
.recurring-entry { border-color: rgba(116,192,252,0.30); background: rgba(116,192,252,0.055); }
.recurring-box .materials-empty { font-size: 12px; line-height: 1.4; color: var(--muted); }

/* v0.4.0 — scenario events */
.event-status-box,
.manual-events-box,
.event-history-box {
  display: grid;
  gap: 8px;
}

.event-chip,
.event-history-row {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(255,255,255,0.045);
  line-height: 1.35;
}

.event-history-row span,
.muted {
  color: rgba(255,255,255,0.62);
  font-size: 12px;
}

.event-chip.event-warning,
.event-warning {
  border-color: rgba(255,209,102,0.55);
  background: rgba(255,209,102,0.10);
}

.event-chip.event-urgent,
.event-urgent {
  border-color: rgba(255,107,107,0.60);
  background: rgba(255,107,107,0.12);
}

.event-ending_bad {
  border-color: rgba(255,107,107,0.85);
  background: rgba(255,107,107,0.18);
}

.event-ending_good {
  border-color: rgba(116, 192, 252, 0.75);
  background: rgba(116, 192, 252, 0.14);
}

.manual-events-box button {
  width: 100%;
  text-align: left;
}

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 16, 0.68);
  backdrop-filter: blur(2px);
}

.event-modal-card {
  width: min(760px, 94vw);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 18px;
  padding: 20px;
  background: linear-gradient(180deg, rgba(30,36,52,0.98), rgba(17,22,34,0.98));
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
}

.event-modal-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.event-modal-header span {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.68);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 4px 8px;
}

.event-modal-card p {
  margin: 0 0 16px;
  line-height: 1.55;
  color: rgba(255,255,255,0.86);
}

.event-choice-list {
  display: grid;
  gap: 10px;
}

.event-choice-list button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
}

/* v0.5.0 session UI */
.topbar-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.compact-link { padding:7px 10px; font-size:12px; }
.session-info-bar { margin: 0 16px 14px; padding: 10px 12px; border:1px solid rgba(255,255,255,.14); border-radius:12px; background: rgba(15,23,42,.7); color:#dbeafe; display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; }
.session-info-bar strong { color:#fff; }
.session-info-bar .muted { color:#94a3b8; }
.session-page { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; background: radial-gradient(circle at top, #22314a 0, #101520 42%, #090d14 100%); color:#e5e7eb; font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
.session-card { width:min(760px, 100%); background:rgba(15,23,42,.92); border:1px solid rgba(255,255,255,.12); box-shadow: 0 24px 90px rgba(0,0,0,.35); border-radius:22px; padding:26px; }
.session-card h1 { margin:0 0 8px; font-size:30px; }
.session-card p { color:#aab6c5; line-height:1.5; }
.form-grid { display:grid; grid-template-columns: 1fr 1fr; gap:14px; margin:22px 0; }
.form-grid label { display:flex; flex-direction:column; gap:6px; color:#cbd5e1; font-size:14px; }
.form-grid input, .form-grid select, .admin-input { border:1px solid rgba(255,255,255,.16); border-radius:10px; background:#111827; color:#fff; padding:10px 12px; font-size:15px; }
.form-grid .full { grid-column: 1 / -1; }
.session-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.session-actions button, .session-button { border:0; border-radius:10px; padding:10px 14px; background:#ffd166; color:#151922; font-weight:700; cursor:pointer; text-decoration:none; display:inline-block; }
.session-actions .secondary, .session-button.secondary { background:#263244; color:#e5e7eb; border:1px solid rgba(255,255,255,.12); }
.session-message { margin-top:14px; padding:12px; border-radius:12px; background:#111827; color:#cbd5e1; white-space:pre-wrap; }
.session-message.error { background:#3b1f24; color:#fecaca; }
.session-message.ok { background:#173524; color:#bbf7d0; }
.admin-shell { min-height:100vh; padding:24px; background:#0b1020; color:#e5e7eb; font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
.admin-card { max-width:1180px; margin:0 auto 18px; background:rgba(15,23,42,.88); border:1px solid rgba(255,255,255,.12); border-radius:18px; padding:20px; }
.admin-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap:14px; }
.admin-table { width:100%; border-collapse:collapse; margin-top:12px; font-size:14px; }
.admin-table th, .admin-table td { border-bottom:1px solid rgba(255,255,255,.1); padding:9px; text-align:left; vertical-align:top; }
.admin-table th { color:#93c5fd; font-weight:700; }
.public-kpi-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap:12px; }
.public-kpi { background:#101827; border:1px solid rgba(255,255,255,.12); border-radius:14px; padding:14px; }
.public-kpi b { font-size:24px; display:block; margin-top:4px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .session-card { padding:18px; } }
