/* ============================================================
   SAUROPIA — chunky retro UI
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

:root {
  --panel: #2c2440;
  --panel2: #3a3054;
  --ink: #f4eee2;
  --accent: #ffd75e;
  --pink: #f6538e;
  --teal: #3fc1c9;
  --green: #74c97f;
  --red: #e8607a;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: #1d1830; }
body { font-family: "Courier New", ui-monospace, monospace; color: var(--ink); }

canvas#game { position: fixed; inset: 0; image-rendering: pixelated; cursor: crosshair; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; gap: 6px; padding: 8px; flex-wrap: wrap;
  pointer-events: none;
}
.chip {
  pointer-events: auto;
  background: var(--panel); border: 3px solid #171226;
  box-shadow: 0 3px 0 #171226;
  border-radius: 8px; padding: 5px 10px;
  font-weight: bold; font-size: 14px; white-space: nowrap;
}
.chip.cash { color: var(--accent); }
.chip.cash.neg { color: var(--red); }
.chip.btn { cursor: pointer; }
.chip.btn:hover { background: var(--panel2); }
.chip.openbtn { color: var(--green); }
.chip.speeds .spd { cursor: pointer; opacity: 0.45; padding: 0 3px; }
.chip.speeds .spd.on { opacity: 1; color: var(--accent); }

/* ---------- to-do ---------- */
#todo {
  position: fixed; left: 10px; top: 112px; z-index: 15;
  background: rgba(44,36,64,0.94); border: 3px solid #171226; border-radius: 10px;
  padding: 10px 14px; font-size: 13px; line-height: 1.7; max-width: 280px;
  box-shadow: 0 4px 0 #171226;
}
#todo b { color: var(--accent); }
#todo .done { opacity: 0.6; text-decoration: line-through; }
#todo .hint { color: var(--teal); margin-top: 4px; }

/* ---------- toolbar ---------- */
#toolbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; gap: 6px; padding: 8px; justify-content: center; flex-wrap: wrap;
  background: linear-gradient(transparent, rgba(23,18,38,0.9) 40%);
}
.tb {
  font-family: inherit; font-weight: bold; font-size: 18px;
  background: var(--panel); color: var(--ink);
  border: 3px solid #171226; border-radius: 10px;
  box-shadow: 0 4px 0 #171226;
  padding: 6px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.tb span { font-size: 10px; margin-top: 2px; }
.tb:hover { background: var(--panel2); transform: translateY(-2px); }
.tb:active { transform: translateY(2px); box-shadow: 0 1px 0 #171226; }
.tbgap { width: 24px; }

/* ---------- submenu ---------- */
#submenu {
  position: fixed; bottom: 74px; left: 50%; transform: translateX(-50%); z-index: 19;
  display: none; flex-wrap: wrap; gap: 6px; justify-content: center;
  max-width: 900px; max-height: 46vh; overflow-y: auto;
  background: rgba(44,36,64,0.97); border: 3px solid #171226; border-radius: 12px;
  padding: 10px; box-shadow: 0 6px 0 #171226;
}
.item {
  display: flex; gap: 8px; align-items: center;
  width: 280px; background: var(--panel2); border: 2px solid #171226;
  border-radius: 8px; padding: 6px; cursor: pointer; font-size: 12px;
}
.item:hover { outline: 3px solid var(--accent); }
.item.locked { opacity: 0.55; cursor: default; }
.item.locked:hover { outline: none; }
.item .thumb { background: #221c38; border-radius: 6px; flex: none; image-rendering: pixelated; }
.item .cost { color: var(--accent); }
.item small { color: #cfc6e8; line-height: 1.35; display: inline-block; }
.subclose { width: 100%; text-align: center; cursor: pointer; color: var(--red); font-weight: bold; padding-top: 4px; }

/* ---------- tool hint ---------- */
#toolhint {
  position: fixed; bottom: 84px; left: 12px; z-index: 18; display: none;
  background: rgba(23,18,38,0.92); border: 2px solid var(--accent); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; max-width: 300px;
}

/* ---------- side panel ---------- */
#panel {
  position: fixed; right: 10px; top: 56px; z-index: 18; display: none;
  width: 360px; max-height: calc(100vh - 160px); overflow-y: auto;
  background: rgba(44,36,64,0.97); border: 3px solid #171226; border-radius: 12px;
  padding: 14px; font-size: 13px; box-shadow: 0 6px 0 #171226;
}
#panel h3 { color: var(--accent); margin-bottom: 8px; }
#panel h4 { color: var(--teal); margin: 10px 0 4px; }
#panel hr { border: none; border-top: 2px solid #171226; margin: 8px 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; }
.row.done { color: var(--green); }
/* keep +/− steppers on one line; let the label shrink/truncate instead of wrapping the controls */
.stepper { flex: 0 0 auto; white-space: nowrap; display: flex; align-items: center; }
.rowlabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.staffrow { border-bottom: 1px dashed #171226; padding: 6px 0; }
.hirebox { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; white-space: nowrap; }
.mini {
  font-family: inherit; font-weight: bold; font-size: 12px;
  background: var(--panel); color: var(--ink);
  border: 2px solid #171226; border-radius: 6px; box-shadow: 0 2px 0 #171226;
  padding: 3px 8px; cursor: pointer; margin: 2px 1px;
}
.mini:hover { background: #4a3f6a; }
.mini.off { opacity: 0.5; }
.mini.danger { color: var(--red); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.warn { background: #4a3f2a; border: 2px solid var(--accent); border-radius: 6px; padding: 6px; margin: 6px 0; }
.dinorow { border-bottom: 1px dashed #171226; padding: 5px 0; }
.pbar {
  display: inline-block; width: 70px; height: 10px; background: #171226;
  border-radius: 4px; overflow: hidden; vertical-align: middle;
}
.pbar.wide { width: 110px; }
.pbar span { display: block; height: 100%; }
.fintable { width: 100%; border-collapse: collapse; font-size: 12px; }
.fintable th, .fintable td { text-align: right; padding: 2px 6px; border-bottom: 1px dashed #171226; }
.fintable th:first-child, .fintable td:first-child { text-align: left; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 10px; bottom: 90px; z-index: 25; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.toast {
  background: rgba(44,36,64,0.96); border: 3px solid var(--accent); border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: bold; max-width: 340px;
  opacity: 0; transform: translateX(30px); transition: all 0.3s;
  box-shadow: 0 4px 0 #171226;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- modal ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: rgba(20,15,35,0.72);
}
.mbox {
  position: relative; overflow: hidden;
  background: var(--panel); border: 4px solid #171226; border-radius: 16px;
  box-shadow: 0 8px 0 #171226, 0 0 60px rgba(255,215,94,0.15);
  padding: 26px 30px; max-width: 720px; max-height: 86vh; overflow-y: auto;
  font-size: 14px;
}
.mbox h1 { color: var(--accent); text-align: center; margin-bottom: 12px; font-size: 26px; }
.mbox h2 { color: var(--accent); margin-bottom: 10px; }
.mbox h4 { color: var(--teal); margin: 10px 0 4px; }
.story { margin: 8px 0; line-height: 1.5; }
.help p { margin: 7px 0; line-height: 1.45; }
.big {
  display: block; width: 100%; margin-top: 12px;
  font-family: inherit; font-weight: bold; font-size: 16px;
  background: var(--pink); color: #fff;
  border: 3px solid #171226; border-radius: 10px; box-shadow: 0 4px 0 #171226;
  padding: 10px; cursor: pointer;
}
.big:hover { filter: brightness(1.15); }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 #171226; }
.repgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.repgrid .row { font-size: 13px; border-bottom: 1px dashed #171226; }
.row.total { border-top: 2px solid var(--accent); margin-top: 4px; }
.frow { display: flex; justify-content: space-between; align-items: center; padding: 2px 0; font-size: 13px; }
.quotes { font-size: 13px; line-height: 1.6; background: var(--panel2); border-radius: 8px; padding: 8px 12px; margin: 4px 0; }
.overnight { margin-top: 10px; color: #b8aee0; font-size: 13px; }

.confetti {
  position: absolute; top: -12px; width: 10px; height: 10px; z-index: 1;
  animation: fall 3s linear infinite;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(90vh) rotate(720deg); opacity: 0.3; }
}

@media (max-width: 760px) {
  .repgrid { grid-template-columns: 1fr; }
  /* on narrow screens the top bar wraps to several rows and the toolbar grows,
     so start the panel lower and cap its height to the space between them */
  #panel { width: calc(100vw - 20px); top: 180px; max-height: calc(100vh - 370px); }
  #todo { top: 250px; font-size: 12px; max-width: 230px; }
}
