/*
 * Whittle & Wares — the shell.
 *
 * The forage phase is canvas; every management phase is real DOM, which is why
 * this file has more in it than the other games' do. That is deliberate: a
 * ledger of prices with steppers is a form, and a form built out of canvas text
 * is worse for everyone and unusable with a screen reader.
 *
 * NO INLINE STYLES ANYWHERE. The site ships `style-src 'self'` with no
 * `unsafe-inline`, so a style attribute is refused outright and logs a violation
 * on every load. Anything dynamic is a class or a CSS custom property set from
 * JS via setProperty, which is not an inline style attribute.
 */

:root {
  --bg: #141c16;
  --bg-2: #1b2820;
  --panel: #21301f;
  --panel-2: #1a251a;
  --ink: #eef3e4;
  --dim: #a5b79b;
  --gold: #ffc24a;
  --leaf: #79c46a;
  --rust: #e2794a;
  --red: #ff6b5b;
  --line: rgba(238, 243, 228, 0.14);
  --radius: 14px;
  --font: ui-rounded, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
}

#app {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.is-hidden {
  display: none !important;
}

/* ------------------------------------------------------------------- HUD -- */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(10, 16, 12, 0.85), rgba(10, 16, 12, 0));
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-day {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
}

.hud-gold {
  margin-left: auto;
  font-size: 14px;
  color: var(--dim);
}

.hud-gold b {
  color: var(--gold);
  font-size: 16px;
}

.hud-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(20, 28, 22, 0.7);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.hud-row-2 {
  gap: 10px;
}

.bar {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid var(--line);
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #6fbf5a, #b6e05a);
  transform-origin: left center;
  transform: scaleX(var(--v, 1));
  transition: transform 0.12s linear;
}

.bar-fill.is-low {
  background: linear-gradient(90deg, #e2794a, #ff6b5b);
}

.hud-sack {
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
}

/* --------------------------------------------------------------- screens -- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 14, 10, 0.82);
  pointer-events: auto;
  overflow-y: auto;
}

.panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

.panel-title {
  text-align: center;
}

.title {
  margin: 4px 0 2px;
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: 0.01em;
}

.title .amp {
  color: var(--gold);
}

.tagline {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.45;
}

/* The day's shape, on the title screen. Four lines is cheaper than a tutorial
 * and it is the question the player actually had: what am I supposed to do? */
.loop {
  list-style: none;
  counter-reset: step;
  margin: 0 0 16px;
  padding: 0;
  text-align: left;
  font-size: 13px;
  color: var(--dim);
}

.loop li {
  counter-increment: step;
  display: flex;
  gap: 9px;
  padding: 5px 0;
  line-height: 1.4;
}

.loop li::before {
  content: counter(step);
  flex: none;
  width: 19px;
  height: 19px;
  border-radius: 99px;
  background: rgba(121, 196, 106, 0.2);
  color: var(--leaf);
  font-weight: 700;
  font-size: 11px;
  text-align: center;
  line-height: 19px;
}

.loop b {
  color: var(--ink);
}

.best {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.panel-h {
  margin: 0 0 4px;
  font-size: 20px;
}

.panel-h3 {
  margin: 18px 0 6px;
  font-size: 14px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-sub {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.5;
}

.panel-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
}

.panel-note.rent {
  color: var(--rust);
  font-weight: 700;
}

.panel-note.rent.is-due {
  color: var(--red);
}

/* --------------------------------------------------------------- buttons -- */

.btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

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

.btn-primary {
  background: linear-gradient(180deg, #5fae4e, #3d8036);
  border-color: rgba(0, 0, 0, 0.3);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
}

.btn-quiet {
  background: none;
  border-color: transparent;
  color: var(--dim);
  font-size: 13px;
}

.row {
  display: flex;
  gap: 10px;
}

.row .btn {
  flex: 1;
}

.row-haggle {
  margin-top: 12px;
}

/* ----------------------------------------------------------------- lists -- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
}

.list .ico {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
  flex: none;
}

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

.list .nm b {
  display: block;
  font-size: 14px;
}

.list .nm span {
  display: block;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.4;
}

.list .hot {
  color: var(--gold);
}

.list .cold {
  color: var(--rust);
}

/* The price outlook: three segments across the row showing what a price will do.
 * Widths come from a custom property set by JS — CSSOM, not a style attribute,
 * so the CSP has nothing to refuse. */
.outlook {
  display: flex;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
}

.outlook .seg {
  width: var(--w, 0%);
  transition: width 0.12s ease-out;
}

.seg-buy {
  background: var(--leaf);
}

.seg-haggle {
  background: var(--gold);
}

.seg-out {
  background: var(--red);
}

.verdict {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
}

.verdict[data-tone='cheap'] {
  color: #8fd0ff;
}

.verdict[data-tone='good'] {
  color: var(--leaf);
}

.verdict[data-tone='fair'] {
  color: var(--gold);
}

.verdict[data-tone='dear'] {
  color: var(--rust);
}

.verdict[data-tone='bad'] {
  color: var(--red);
}

.list-price li {
  align-items: flex-start;
}

.list-price .mini,
.list-price .price {
  margin-top: 2px;
}

.mini {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}

.mini:disabled {
  opacity: 0.35;
  cursor: default;
}

.price {
  min-width: 44px;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
}

.list-buy .cost {
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.list-buy li.is-owned {
  opacity: 0.45;
}

.tally {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
}

.tally li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.tally li span {
  color: var(--dim);
}

.tally li b {
  color: var(--gold);
}

/* --------------------------------------------------------------- counter -- */

.panel-counter {
  text-align: center;
}

.counter {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  text-align: left;
}

.face {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  flex: none;
}

.cust-name {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 16px;
}

.cust-line {
  margin: 0;
  font-size: 13px;
  color: var(--dim);
  line-height: 1.45;
}

.cust-verdict {
  margin: 14px 0 0;
  font-size: 15px;
  font-weight: 700;
  min-height: 22px;
}

.cust-verdict.is-good {
  color: var(--leaf);
}

.cust-verdict.is-bad {
  color: var(--red);
}

/* ------------------------------------------------------------------ name -- */

.name-form {
  margin-top: 14px;
}

.name-label {
  display: block;
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 6px;
}

.name-input {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.name-form .btn {
  margin-top: 0;
  width: auto;
  flex: none;
  padding: 12px 18px;
}

/* ------------------------------------------------------------------- how -- */

.how {
  margin-top: 16px;
  text-align: left;
  font-size: 13px;
  color: var(--dim);
}

.how summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  padding: 6px 0;
}

.how ul {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.how b {
  color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill {
    transition: none;
  }
  .btn:active {
    transform: none;
  }
}


/* ------------------------------------------------------- forage objective -- */

/* "I have no idea what to do, I only collect some stuff and nothing else" —
 * the morning had no stated goal anywhere on screen, so this says it, all the
 * time, and counts down the walk home. */
.objective {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(8, 14, 10, 0.82);
  border: 1px solid var(--line);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.35;
}

.objective b {
  color: var(--gold);
}

.objective .obj-text {
  flex: 1;
  min-width: 0;
}

.objective .obj-home {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 9px;
  background: rgba(255, 194, 74, 0.14);
  color: var(--gold);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

.objective.is-home .obj-home {
  background: rgba(121, 196, 106, 0.2);
  color: var(--leaf);
}

/* The first morning walks you through it, one line at a time. */
.coach {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 58px);
  padding: 11px 13px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(56, 84, 48, 0.96), rgba(30, 48, 28, 0.96));
  border: 1px solid rgba(238, 243, 228, 0.22);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.coach b {
  color: var(--gold);
}


/* ---------------------------------------------------------- commissions -- */

/* An order is the morning's actual instruction, so it gets a card rather than a
 * line in a list: a name, a number and a date, which is the shape of a plan. */
.orders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.orders .order {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 194, 74, 0.08);
  border: 1px solid rgba(255, 194, 74, 0.28);
}

.orders .ico {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
  flex: none;
}

.orders .nm {
  flex: 1;
  min-width: 0;
}

.orders .nm b {
  display: block;
  font-size: 14px;
}

.orders .nm span {
  display: block;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.4;
}

.orders .nm span.cold {
  color: var(--rust);
}

.orders .cost {
  flex: none;
  color: var(--leaf);
  font-weight: 700;
  font-size: 12px;
}

.order-news {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
  line-height: 1.45;
}

.order-news.is-good {
  color: var(--leaf);
  border-color: rgba(121, 196, 106, 0.35);
}

.order-news.is-bad {
  color: var(--red);
  border-color: rgba(255, 107, 91, 0.35);
}

.offer {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(121, 196, 106, 0.1);
  border: 1px solid rgba(121, 196, 106, 0.32);
}

.offer-line {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.5;
}
