:root {
  --bg: #14110d;
  --panel: #231d16;
  --panel-2: #2d251c;
  --text: #f1e8d8;
  --muted: #a89a82;
  --accent: #e0b23a;
  --accent-ink: #1b1405;
  --line: #3a3126;
  --good: #6fcf7f;
  --bad: #ff7a6b;
  --wall: #5b4531;
  --wainscot: #46341f;
  --floor: #2a2018;
  --rug: #5a2a24;
  --desk: #7a5230;
  --desk-front: #5f3f24;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }
h1, h2, h3 { line-height: 1.2; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.strong { font-weight: 700; }

.dot {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  vertical-align: baseline;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.dot.big { width: 56px; height: 56px; }

/* ---- Buttons --------------------------------------------------------- */

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 3px 8px; font-size: 0.85rem; }
.btn.big { padding: 12px 28px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

/* ---- Game layout ------------------------------------------------------ */

.game {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
}
.hud-firm { display: flex; align-items: center; gap: 8px; margin-right: auto; font-size: 1.1rem; }
.hud-item { display: flex; flex-direction: column; line-height: 1.2; }
.hud-item .label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.hud-item .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.value.negative { color: var(--bad); }

.office-wrap { background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.office { display: block; width: 100%; height: auto; }

.message {
  margin: 0;
  padding: 8px 12px;
  background: var(--panel);
  border-left: 4px solid var(--line);
  border-radius: 4px;
  min-height: 2.6em;
}
.message.ok { border-left-color: var(--good); }
.message.error { border-left-color: var(--bad); }

/* ---- Office scene ------------------------------------------------------ */

.office .wall { fill: var(--wall); }
.office .wainscot { fill: var(--wainscot); }
.office .floor { fill: var(--floor); }
.office .rug { fill: var(--rug); }
.office .frame { fill: #2a1b0e; }
.office .ocean { fill: #2c5d7c; }
.office .land { fill: #4f7d3f; }
.office .derrick { stroke: #2a1b0e; stroke-width: 3; fill: none; stroke-linejoin: round; }
.office .chart-bg { fill: #efe7d3; }
.office .paper { fill: #efe7d3; }
.office .ink { stroke: #4a4030; stroke-width: 2; fill: #4a4030; }
.office .cal-head { fill: #b8372c; }
.office .cal-month { fill: #fff; text-anchor: middle; font: 700 18px system-ui, sans-serif; }
.office .cal-day { fill: #2b2318; text-anchor: middle; font: 700 56px system-ui, sans-serif; }
.office .cal-year { fill: #5a4d38; text-anchor: middle; font: 600 16px system-ui, sans-serif; }
.office .safe { fill: #4a5058; stroke: #2b2f34; stroke-width: 3; }
.office .dial { fill: #8a929b; stroke: #2b2f34; stroke-width: 3; }
.office .dial-center { fill: #2b2f34; }
.office .desk-top { fill: var(--desk); }
.office .desk-front { fill: var(--desk-front); }
.office .monitor { fill: #cfc7b4; stroke: #6a6252; stroke-width: 2; }
.office .keyboard { fill: #bdb5a2; stroke: #6a6252; }
.office .term { fill: #7dff9f; font: 11px ui-monospace, Consolas, monospace; }
.office .blink { animation: blink 1.1s steps(2, start) infinite; }
.office .phone { fill: #232323; stroke: #000; stroke-width: 1.5; }
.office .cabinet { fill: #5d6770; stroke: #2e353b; stroke-width: 2; }
.office .drawer { fill: #7b8791; stroke: #2e353b; stroke-width: 1.5; }
.office .handle { fill: #d6d9dc; }
.office .plate { fill: var(--accent); stroke: #000; stroke-width: 1.5; }
.office .plate-text { text-anchor: middle; font: 700 15px system-ui, sans-serif; fill: #0b0b0b; paint-order: stroke; stroke: rgba(255, 255, 255, 0.55); stroke-width: 2px; }
.office .logo { fill: var(--accent); stroke: #000; stroke-width: 3; }
.office .logo-text { text-anchor: middle; font: 800 22px system-ui, sans-serif; fill: #1b1405; }

.office .spot { cursor: pointer; outline: none; }
.office .hit { fill: transparent; stroke: none; pointer-events: all; }
.office .spot:hover .hit, .office .spot:focus-visible .hit { stroke: var(--accent); stroke-width: 3; fill: rgba(224, 178, 58, 0.12); }
.office .spot-label {
  text-anchor: middle;
  font: 600 14px system-ui, sans-serif;
  fill: #f1e8d8;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.6);
  stroke-width: 3px;
  pointer-events: none;
}
.office .spot-label.on-desk { font-size: 13px; }
.office.days-out #cal-day { fill: #b8372c; }

@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .office .blink { animation: none; } }

/* ---- Modals ------------------------------------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 12px;
  overflow-y: auto;
  z-index: 10;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: min(560px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal.wide { width: min(960px, 100%); }
.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal h2 { margin: 0; font-size: 1.2rem; color: var(--accent); }
.modal-body { padding: 14px 16px; }
.feedback { margin: 0; padding: 0 16px 12px; min-height: 1.5em; font-size: 0.95rem; }
.feedback.ok { color: var(--good); }
.feedback.error { color: var(--bad); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---- Panels and tables ----------------------------------------------- */

.tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs-info { margin-left: auto; color: var(--muted); font-size: 0.9rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 6px 0 10px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
table.grid.compact th { width: 55%; font-size: 1rem; color: var(--text); font-weight: 400; }
table.grid tr.row-bad { background: rgba(255, 122, 107, 0.08); }
table.grid tr.winner { background: rgba(224, 178, 58, 0.15); font-weight: 700; }

.amount { width: 110px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }

select, input[type="text"] { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }

/* ---- Map, charts ------------------------------------------------------ */

.worldmap { width: 100%; height: auto; display: block; border-radius: 6px; }
.worldmap .ocean { fill: #26506b; }
.worldmap .land { fill: #4f7d3f; stroke: #2f4f26; stroke-width: 0.3; }
.worldmap .region { cursor: pointer; outline: none; }
.worldmap .region:hover .land, .worldmap .region:focus-visible .land { fill: #5f9350; stroke: var(--accent); stroke-width: 0.6; }
.worldmap .region-name { text-anchor: middle; font: 700 2.6px system-ui, sans-serif; fill: #fff; pointer-events: none; }
.worldmap .field-dot { stroke: #1a1a1a; stroke-width: 0.3; }
.worldmap .field-dot.drilled { stroke: #fff; stroke-width: 0.6; }
.worldmap .field-dot.burning { stroke: #ff3d2e; stroke-width: 0.9; }
.worldmap .field-dot.worthless { opacity: 0.55; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 10px 0 0; font-size: 0.9rem; }
.ring { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; border: 2px solid #fff; vertical-align: baseline; }
.ring.fire { border-color: #ff3d2e; }

.bars { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 16px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr minmax(100px, 150px); gap: 10px; align-items: center; }
.bar-track { position: relative; height: 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.bar-fill { height: 100%; border-radius: 9px; min-width: 2px; }
.bar-goal { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--accent); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

.price-chart { width: 100%; height: auto; max-height: 160px; background: #efe7d3; border-radius: 4px; }
.price-chart .axis { stroke: #b9ad92; stroke-width: 1; }
.price-chart .axis-label { font: 10px system-ui, sans-serif; fill: #5a4d38; }
.price-chart .line { stroke: #b8372c; stroke-width: 2.5; stroke-linejoin: round; }
.price-chart .line-dot { fill: #b8372c; }

.newspaper { background: #efe7d3; color: #2b2318; padding: 14px 16px; border-radius: 4px; }
.newspaper h3 { font-family: Georgia, "Times New Roman", serif; font-size: 1.5rem; margin: 4px 0 10px; }
.newspaper .paper-date { margin: 0; font-size: 0.85rem; color: #5a4d38; text-transform: uppercase; letter-spacing: 0.08em; }
.newspaper .muted { color: #5a4d38; }

.handover { text-align: center; padding: 8px 0; }
.help ul { padding-left: 1.2em; }

/* ---- Screens ----------------------------------------------------------- */

.screen { max-width: 640px; margin: 0 auto; padding: 48px 16px; }
.screen h1 { color: var(--accent); font-size: 2.4rem; letter-spacing: 0.04em; margin: 0 0 4px; }
.screen .sub { color: var(--muted); margin: 0 0 24px; }
.setup-rows { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.setup-row { display: flex; align-items: center; gap: 10px; }
.setup-row input { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-value { text-align: left; }
  table.grid .actions { justify-content: flex-start; }
  .modal-body { overflow-x: auto; }
}

/* ---- Minigames ----------------------------------------------------------- */

.minigame-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}
.minigame-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Phone, newspaper, security ------------------------------------------ */

.office .badge circle { fill: #d62d20; stroke: #fff; stroke-width: 2; }
.office .badge text { fill: #fff; text-anchor: middle; font: 800 13px system-ui, sans-serif; pointer-events: none; }
.office .badge { pointer-events: none; }

.offer {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.offer p { margin: 4px 0; }
.offer .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.messages, .headlines { padding-left: 1.1em; margin: 6px 0; }
.messages li, .headlines li { margin-bottom: 4px; }
.headlines li.fresh { font-weight: 700; }
.newspaper .headlines { font-family: Georgia, "Times New Roman", serif; }

.security { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 10px; }
.security h3 { margin: 6px 0; font-size: 1.05rem; }

/* ---- Menu, slots, tutorial, accessibility -------------------------------- */

.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item { text-align: left; padding: 10px 14px; }
.shortcut-box { margin-top: 14px; color: var(--muted); }
.shortcut-box summary { cursor: pointer; }
.shortcuts { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
kbd {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 5px;
  background: var(--panel-2);
  font: 600 0.85em ui-monospace, Consolas, monospace;
  color: var(--text);
}

.slots { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.slot.empty { opacity: 0.7; }
.slot .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.tutorial h3 { margin-top: 0; color: var(--accent); }
.tutorial li { margin-bottom: 6px; }
.dialog-buttons .muted { margin-right: auto; align-self: center; }

.setup-extras { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.screen section { margin-top: 20px; background: none; border: none; padding: 0; }

/* Keyboard focus must always be visible, also on the SVG office objects. */
.office .spot:focus-visible .hit { stroke: var(--accent); stroke-width: 4; fill: rgba(224, 178, 58, 0.18); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- World map (real coastlines) ------------------------------------------ */

.worldmap { background: #1f4a66; }
.worldmap .ocean { fill: #1f4a66; }
.worldmap .graticule, .office .graticule { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 0.15; }
.worldmap .land, .office .land { fill: #6f8a52; stroke: #3d5230; stroke-width: 0.25; stroke-linejoin: round; }
.worldmap .inland-water, .office .inland-water { fill: #1f4a66; stroke: #3d5230; stroke-width: 0.2; }
.worldmap .halo { fill: rgba(224, 178, 58, 0.12); stroke: rgba(224, 178, 58, 0.7); stroke-width: 0.3; stroke-dasharray: 1 0.8; }
.worldmap .region { cursor: pointer; outline: none; }
.worldmap .region:hover .halo, .worldmap .region:focus-visible .halo { fill: rgba(224, 178, 58, 0.3); stroke-width: 0.6; stroke-dasharray: none; }
.worldmap .region-name {
  text-anchor: middle;
  font: 700 2.5px system-ui, sans-serif;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.75);
  stroke-width: 0.6px;
  pointer-events: none;
}
.office .wall-marker { fill: #ff7a6b; stroke: #fff; stroke-width: 0.4; }

.why { margin-top: 2px; max-width: 34em; line-height: 1.3; }

.last-month { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; margin: 6px 0 10px; }

/* A link that looks like the other menu buttons. */
a.menu-link { display: block; text-decoration: none; color: var(--text); }
a.menu-link:hover { border-color: var(--accent); }

/* The home link sits among the setup buttons and must look like them. */
a.setup-home { display: inline-block; text-decoration: none; color: var(--text); }
a.setup-home:hover { border-color: var(--accent); }

/* Small label chips, e.g. "Pipeline" in the field list. */
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: 1px;
}
