/* Keep the Lamp — indigo night, dim cream paper, amber, window gold. */

:root {
  --sky: #12142a;
  --sky-deep: #0c0e1c;
  --indigo: #1c2140;
  --ink: #1a1f38;
  --ink-soft: #3d4563;
  --paper: #e6dcc8;
  --paper-dim: #d4c9b0;
  --line: #b9ad93;
  --amber: #c48a22;
  --amber-ink: #8a5e12;
  --gold: #e6c56b;
  --danger: #7a2e2e;
  --held: #f3ead6;
  --focus: #c48a22;
  --shadow: #080a18;
  --topbar-h: 48px;
  --font-serif: Georgia, "Times New Roman", Times, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--sky-deep);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  padding: 6px 10px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}

.skip:focus {
  top: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 5px 10px;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: var(--held);
}

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

button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

button.primary:hover {
  background: var(--indigo);
  color: var(--gold);
}

button.danger {
  color: var(--danger);
  border-color: #c9a3a3;
}

button.text-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--amber-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--gold);
  border-color: var(--ink);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.logo {
  display: block;
  color: var(--amber-ink);
  flex: none;
}

.logo .flame {
  stroke: var(--amber);
}

.clock {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resources {
  display: flex;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
}

.resources li {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
}

.resources svg {
  color: var(--amber-ink);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed {
  display: flex;
  gap: 2px;
}

.panel {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 4px 6px 0 var(--shadow);
  padding: 12px 14px;
}

.panel h2 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 400;
}

.panel-kicker,
.eyebrow,
.fineprint,
.muted,
.help {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.eyebrow {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.plain-list,
.journal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li,
.plan-row,
.worker-row,
.contract-row,
.history-row {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.plain-list li:first-child,
.plan-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.plan-row,
.worker-row {
  display: grid;
  gap: 4px;
}

.plan-top,
.row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.name {
  font-weight: 600;
}

.kicker {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.progress {
  display: block;
  width: 100%;
  height: 6px;
  background: var(--paper-dim);
  border: 1px solid var(--line);
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--amber);
}

.left-stack {
  position: absolute;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 250px;
  max-height: calc(100% - var(--topbar-h) - 28px);
}

.hill-plans {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.workers {
  overflow: auto;
  flex: 0 1 auto;
  min-height: 7.5rem;
  max-height: 38%;
}

.context {
  position: absolute;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  z-index: 12;
  width: 292px;
  max-height: calc(100% - var(--topbar-h) - 108px);
  overflow: auto;
}

.notice {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 580px));
  min-width: 240px;
}

.notice h2 {
  font-size: 1rem;
}

.welcome {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 32px));
  text-align: left;
}

.welcome h2 {
  font-size: 1.35rem;
  line-height: 1.25;
}

.welcome .primary {
  margin-top: 8px;
}

.toasts {
  position: absolute;
  z-index: 18;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100% - 24px));
  pointer-events: none;
}

.held-slip,
.banner {
  margin: 0;
  padding: 6px 12px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  pointer-events: auto;
}

.held-slip {
  font-family: var(--font-serif);
  background: var(--held);
}

.leave-hint {
  background: #e8d4b0;
  border-color: #c4a878;
}

#btn-leave.leave-call {
  border-color: #c4a878;
  color: #3a2c18;
}

.morning {
  max-width: 28rem;
  padding: 12px 14px;
  text-align: left;
  background: #e8d4b0;
  border-color: #c4a878;
}

.morning h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 400;
}

.morning p {
  margin: 0 0 6px;
}

.morning button {
  margin-top: 4px;
}

.morning,
.install-slip {
  max-height: min(70vh, 28rem);
  overflow: auto;
}

.install-slip {
  max-width: 28rem;
  padding: 12px 14px;
  text-align: left;
  pointer-events: auto;
}

.install-slip h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 400;
}

.install-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.leave-phone {
  display: none;
}

.banner {
  color: var(--danger);
  border-color: #c9a3a3;
}

.banner.action {
  color: var(--ink);
  border-color: var(--line);
}

.world-tools {
  position: absolute;
  z-index: 12;
  right: 12px;
  bottom: 14px;
  display: flex;
  gap: 4px;
}

.world-tools button {
  min-width: 36px;
}

.dock {
  display: none;
}

.policy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.policy-row button {
  flex: 1 1 auto;
}

.objective {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.cost {
  font-size: 0.82rem;
  color: var(--amber-ink);
}

dialog {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0;
  box-shadow: 6px 8px 0 var(--shadow);
  max-width: calc(100% - 24px);
}

dialog::backdrop {
  background: rgb(12 14 28 / 0.62);
}

.dialog-paper {
  margin: 0;
  padding: 18px 18px 16px;
  width: min(420px, 100%);
}

.dialog-paper.wide {
  width: min(520px, 100%);
}

.dialog-paper h2 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-weight: 400;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.journal-list {
  max-height: min(50vh, 360px);
  overflow: auto;
}

.journal-list li {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.journal-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.journal-list h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-family: var(--font-serif);
  font-weight: 400;
}

.noscript {
  position: absolute;
  z-index: 40;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 12px;
  background: var(--paper);
  color: var(--ink);
}

@media (max-width: 860px) {
  .brand h1 {
    font-size: 0.95rem;
  }

  .clock {
    flex: 0 1 auto;
  }

  .top-actions button {
    padding: 5px 7px;
  }

  .left-stack,
  .context,
  .notice {
    display: none;
    top: auto;
    left: 10px;
    right: 10px;
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 38vh;
    transform: none;
    overflow: auto;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .left-stack.is-open,
  .context.is-open,
  .notice.is-open {
    display: flex;
  }

  .context.is-open,
  .notice.is-open {
    display: block;
  }

  .welcome {
    top: 42%;
    width: min(360px, calc(100% - 24px));
  }

  .world-tools {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    right: 10px;
  }

  .toasts {
    top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px);
  }

  .leave-phone:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 18;
    left: max(10px, env(safe-area-inset-left, 0px));
    bottom: calc(62px + env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    min-width: 7.2rem;
    padding: 12px 16px;
    font-size: 1rem;
  }

  .dock {
    position: absolute;
    z-index: 16;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0;
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    background: var(--paper);
    color: var(--ink);
    border-top: 1px solid var(--line);
  }

  .dock button {
    border: 0;
    border-radius: 0;
    background: transparent;
    min-height: 48px;
  }

  .dock button[aria-pressed="true"] {
    background: var(--ink);
    color: var(--gold);
  }

  #btn-leave {
    display: none;
  }
}

@media (max-width: 860px) and (orientation: landscape) {
  .morning,
  .install-slip {
    max-height: min(48vh, 16rem);
  }

  .leave-phone:not([hidden]) {
    z-index: 22;
  }

  .toasts {
    left: auto;
    right: max(12px, env(safe-area-inset-right, 0px));
    transform: none;
    width: min(28rem, calc(100% - 150px));
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 8px;
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  }

  .speed {
    display: none;
  }

  .logo,
  #btn-settings,
  #btn-pause {
    display: none;
  }

  .clock {
    flex: 1 1 8rem;
    min-width: 8rem;
    font-size: 0.78rem;
  }

  .brand h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .clock {
    font-size: 0.82rem;
  }

  .resources {
    gap: 8px;
  }

  .left-stack,
  .context,
  .notice {
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    max-height: 34vh;
  }
}

@media (display-mode: standalone) {
  #install-slip {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
