/* Hot Dog Stand, student-edition look: cream paper, ketchup and mustard, navy ink.
   Colours are tokens. Light is the default; dark is a player choice (the Dark mode button). */
:root {
  --paper: #fbf3e0;
  --paper-2: #fffdf6;
  --ink: #1f2a44;
  --muted: #6b6456;
  --rule: #d9c79c;
  --red: #d7263d;
  --red-dark: #a51d2e;
  --mustard: #f2b705;
  --bun: #e3a857;
  --green: #2a7d4f;
  --blue: #1f4e89;
  --shadow: rgba(31, 42, 68, 0.2);
  --cream-hi: #fff7e6;
  --display: 'Bungee', 'Trebuchet MS', Impact, sans-serif;
  --body: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
}
:root[data-theme="dark"] {
  --paper: #161d2e;
  --paper-2: #1f2840;
  --ink: #f7efd9;
  --muted: #aab3c7;
  --rule: #39445f;
  --red: #ff6b7a;
  --red-dark: #ff8d99;
  --mustard: #ffd34d;
  --bun: #e8b86d;
  --green: #7dd3a0;
  --blue: #9cc3ff;
  --shadow: rgba(0, 0, 0, 0.45);
  --cream-hi: #26304a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(circle at 10% 0%, rgba(242, 183, 5, 0.18), transparent 40%),
    radial-gradient(circle at 90% 100%, rgba(215, 38, 61, 0.12), transparent 40%),
    var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}
#app { max-width: 1000px; margin: 0 auto; padding: 16px 16px 40px; }
h1, h2, h3 { font-family: var(--display); margin: 0 0 8px; line-height: 1.15; font-weight: normal; }
h1 { font-size: 26px; color: var(--red); letter-spacing: 0.01em; }
h2 { font-size: 20px; color: var(--blue); }
h3 { font-size: 15px; color: var(--ink); }
p { margin: 0 0 10px; }
ul { margin: 0 0 12px; padding-left: 20px; }
li { margin-bottom: 4px; }
.muted { color: var(--muted); }
.num { font-family: var(--mono); font-weight: 700; }
.good { color: var(--green); }
.bad { color: var(--red); }

/* Masthead and logo */
.masthead {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 0 12px; margin-bottom: 14px; border-bottom: 3px double var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand svg { width: 52px; height: 52px; flex: none; }
.brand .word { display: flex; flex-direction: column; }
.brand small {
  font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px;
}
.masthead .spacer { flex: 1; }
.iconbtn {
  font-family: var(--mono); font-size: 12px; padding: 6px 10px; border: 2px solid var(--ink);
  background: var(--paper-2); color: var(--ink); border-radius: 999px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink);
}

/* HUD tiles */
.hud {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px;
}
.tile {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.tile svg { width: 26px; height: 26px; flex: none; color: var(--red); }
.tile .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tile b { display: block; font-family: var(--mono); font-size: 18px; line-height: 1.2; }
.tile small { font-size: 12px; color: var(--muted); font-family: var(--body); }

.card {
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px;
  padding: 14px; box-shadow: 4px 4px 0 var(--shadow); margin-bottom: 14px;
}

/* Title / chapter opener */
.hero { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: center; }
@media (min-width: 720px) { .hero { grid-template-columns: 1.05fr 0.95fr; } }
.chapter {
  display: inline-block; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--navy-chip, var(--ink)); color: var(--paper-2); padding: 3px 10px; border-radius: 4px; margin-bottom: 10px;
}
.objectives { list-style: none; padding: 0; counter-reset: obj; }
.objectives li { counter-increment: obj; padding: 8px 10px 8px 42px; position: relative; border-bottom: 1px dotted var(--rule); }
.objectives li::before {
  content: counter(obj); position: absolute; left: 8px; top: 7px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--mustard); color: var(--ink); font-family: var(--display); font-size: 13px; text-align: center; line-height: 24px;
}
.hero-art { position: relative; }
.hero-art .bob { transform-origin: 50% 90%; }
.hero-art .scene { width: 100%; height: auto; display: block; }

/* Buttons */
button {
  font: inherit; font-family: var(--display); font-size: 13px; letter-spacing: 0.01em;
  color: var(--ink); background: var(--paper-2); border: 2px solid var(--ink); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); transition: transform 0.05s;
}
button:hover:not(:disabled) { background: var(--cream-hi); }
button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--red); color: #fff; border-color: var(--ink); font-size: 16px; padding: 12px 20px;
}
button.primary:hover:not(:disabled) { background: var(--red-dark); }
button.mustard { background: var(--mustard); }
button.small { padding: 4px 9px; font-size: 12px; box-shadow: 1px 1px 0 var(--ink); }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; }

/* Plan screen */
.plan-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 840px) { .plan-grid { grid-template-columns: 1.1fr 0.9fr; } }

.scene-wrap { position: relative; }
.scene { width: 100%; height: auto; display: block; border-radius: 10px; border: 2px solid var(--ink); }
.caption { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.caption b { color: var(--ink); }
.pill {
  display: inline-block; font-family: var(--mono); font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: var(--mustard); color: var(--ink); margin-right: 4px;
}
.pill.weekend { background: var(--blue); color: #fff; }

.locs { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
@media (min-width: 540px) { .locs { grid-template-columns: 1fr 1fr; } }
.loc {
  display: block; text-align: left; font-family: var(--body); font-weight: normal; padding: 9px 11px;
  box-shadow: 2px 2px 0 var(--ink); border-width: 2px; background: var(--paper-2);
}
.loc[aria-pressed="true"] { background: var(--cream-hi); border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.loc .name { font-family: var(--display); font-size: 13px; display: block; margin-bottom: 2px; }
.loc .meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.loc .meter { display: block; height: 8px; border-radius: 99px; background: var(--rule); margin: 6px 0 4px; overflow: hidden; }
.loc .meter i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width 0.3s; }
.loc .blurb { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; }

.control { margin: 12px 0; }
.control > label, .control > .lbl { display: block; font-family: var(--display); font-size: 13px; margin-bottom: 4px; }
.stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stepper output { font-family: var(--mono); font-size: 19px; font-weight: 700; min-width: 80px; text-align: center; }
input[type="range"] { width: 100%; accent-color: var(--red); }
.fairnote { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

.estimate {
  background: var(--cream-hi); border: 2px dashed var(--mustard); border-radius: 10px; padding: 8px 10px; margin: 8px 0;
  font-size: 14px;
}
.estimate b { font-family: var(--mono); font-size: 17px; }

.summary {
  font-family: var(--mono); font-size: 13px; border-top: 2px dashed var(--rule); padding-top: 8px; margin-top: 8px;
}
.summary div { display: flex; justify-content: space-between; padding: 1px 0; }

.finance { display: flex; gap: 8px; flex-wrap: wrap; }
.msg { min-height: 1.4em; color: var(--red); font-weight: bold; font-size: 14px; margin: 6px 0 0; }

details.glossary summary { cursor: pointer; font-family: var(--display); font-size: 14px; color: var(--blue); }
.terms { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 10px; }
@media (min-width: 640px) { .terms { grid-template-columns: 1fr 1fr; } }
.term { border-left: 4px solid var(--mustard); padding: 5px 9px; background: var(--paper); font-size: 14px; border-radius: 0 6px 6px 0; }
.term.locked { border-left-color: var(--rule); color: var(--muted); font-style: italic; }

/* Run and report */
.pnl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 14px; }
.pnl td { padding: 5px 6px; border-bottom: 1px dotted var(--rule); }
.pnl td:last-child { text-align: right; }
.pnl tr.total td { border-top: 2px solid var(--ink); border-bottom: none; font-weight: 700; font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; text-align: center; }
.stats div { background: var(--paper); border: 1.5px solid var(--rule); border-radius: 8px; padding: 6px; font-size: 12px; color: var(--muted); }
.stats b { display: block; font-family: var(--mono); font-size: 19px; color: var(--ink); }

.lesson {
  border-left: 6px solid var(--mustard); background: var(--paper); padding: 10px 12px; border-radius: 0 8px 8px 0; margin-bottom: 10px;
}
.lesson .tag {
  display: inline-block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--blue); color: #fff; padding: 2px 7px; border-radius: 4px; margin-bottom: 4px;
}
.lesson h3 { font-size: 14px; margin-bottom: 2px; }
.lesson p { margin: 0; font-size: 15px; }
.nolesson { font-size: 14px; color: var(--muted); }

.run-banner {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  background: var(--paper-2); border: 2px solid var(--ink); border-radius: 8px; padding: 3px 12px;
  font-family: var(--mono); font-weight: 700; box-shadow: 2px 2px 0 var(--shadow);
}
.counter { font-family: var(--display); font-size: 26px; color: var(--green); margin: 10px 0 2px; }

.bars { width: 100%; height: auto; display: block; }
.bars text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }

/* Stamp for the season rating */
.stamp {
  display: inline-block; font-family: var(--display); font-size: 15px; color: var(--red); border: 3px solid var(--red);
  border-radius: 8px; padding: 6px 12px; transform: rotate(-3deg); margin: 4px 0 10px; background: var(--paper-2);
}


/* Bank warning */
.warn {
  background: rgba(215, 38, 61, 0.12); border: 2px solid var(--red); border-radius: 10px;
  padding: 8px 10px; margin: 10px 0 4px; font-size: 14px; line-height: 1.4;
}
.warn b { font-family: var(--display); font-size: 13px; color: var(--red); display: block; margin-bottom: 2px; }

/* Phone layout */
@media (max-width: 560px) {
  #app { padding: 10px 10px 32px; }
  h1 { font-size: 20px; }
  .brand svg { width: 40px; height: 40px; }
  .masthead { gap: 8px; }
  .masthead .spacer { display: none; }
  .iconbtn { font-size: 11px; padding: 5px 8px; }
  .hud { grid-template-columns: 1fr 1fr; gap: 6px; }
  .tile { padding: 6px 8px; gap: 6px; }
  .tile svg { width: 20px; height: 20px; }
  .tile b { font-size: 15px; }
  .tile small { font-size: 11px; }
  .card { padding: 10px; }
  .hero { gap: 12px; }
  .stats { gap: 6px; }
  .stats b { font-size: 16px; }
  .finance button { flex: 1 1 45%; }
  button.primary { width: 100%; }
  .pnl { font-size: 13px; }
  .locs { grid-template-columns: 1fr; }
  .news { padding: 8px; }
}

.postmortem { list-style: none; padding: 0; }
.postmortem li { border-left: 5px solid var(--red); background: var(--paper); padding: 8px 10px; margin-bottom: 8px; border-radius: 0 8px 8px 0; font-size: 14px; }

/* News, goals, achievements, confetti */
.news {
  display: flex; gap: 12px; align-items: flex-start; background: var(--cream-hi); border: 2px solid var(--ink);
  border-radius: 12px; padding: 10px 12px; margin: 10px 0 4px; box-shadow: 3px 3px 0 var(--shadow);
}
.news-icon { font-size: 30px; line-height: 1; flex: none; }
.news-kicker { display: block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--red); }
.news b { font-family: var(--display); font-size: 14px; }
.news p { margin: 2px 0 0; font-size: 14px; }
.news.quiet { color: var(--muted); font-size: 14px; border-style: dashed; box-shadow: none; background: transparent; }
.goal {
  border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px; margin-top: 12px; font-size: 14px;
}
.goal.met { background: rgba(42, 125, 79, 0.18); }
.goal.missed { background: var(--paper); }
.unlock { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.unlock b { font-family: var(--display); font-size: 13px; margin-right: 4px; }
.badge {
  background: var(--mustard); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px;
  padding: 3px 12px; font-family: var(--display); font-size: 12px; box-shadow: 2px 2px 0 var(--ink);
}
.achieve-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-top: 8px; }
.ach { border: 2px dashed var(--rule); border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--muted); }
.ach b { display: block; font-family: var(--display); font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ach.on { border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink); box-shadow: 2px 2px 0 var(--mustard); }
.ach.on b { color: var(--red); }
.confetti-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti-layer i {
  position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; opacity: 0.95;
  animation-name: confettiFall; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes confettiFall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- Scene motion ---------- */
.sun-rays { transform-origin: 420px 56px; animation: spin 24s linear infinite; }
.glow { animation: pulse 3.2s ease-in-out infinite; }
.cloud { animation: drift linear infinite; transform-box: view-box; }
.bird { animation: flyBy 16s linear infinite; }
.rain-drop { stroke: #4fa3d9; stroke-width: 1.5; animation: fall linear infinite; }
.snow { fill: #fff; animation: snowfall linear infinite; }
.twinkle { animation: twinkle 2.4s ease-in-out infinite; }
.waves path { animation: wave 4s linear infinite; }
.walker { animation: walkIn 0.8s ease-out both, bob 0.7s ease-in-out infinite alternate; }
.steam path { stroke-dasharray: 40; animation: steam 2.2s ease-in-out infinite; }
.neon { animation: flicker 2.2s steps(1, end) infinite; }
.sold-sign { transform-box: fill-box; transform-origin: center; animation: flip 0.6s ease-out both; }
.coin {
  font-family: var(--mono); font-weight: 700; font-size: 15px; fill: var(--green);
  stroke: #fff; stroke-width: 3; paint-order: stroke; animation: coinPop 1.1s ease-out forwards;
}
.walker.leave { animation: walkOut 0.7s ease-in forwards; }
.sky { transition: fill 0.8s ease; }
.hero-art .bob { animation: bobHot 3.4s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.3; } }
@keyframes drift { from { transform: translateX(-90px); } to { transform: translateX(570px); } }
@keyframes flyBy { from { transform: translateX(-30px); } to { transform: translateX(520px); } }
@keyframes fall { from { transform: translateY(-20px); opacity: 0.9; } to { transform: translateY(280px); opacity: 0.2; } }
@keyframes snowfall { from { transform: translateY(-10px); } to { transform: translateY(280px); } }
@keyframes twinkle { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-120px); } }
@keyframes walkIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-2px); } }
@keyframes walkOut { to { transform: translateX(-120px); opacity: 0; } }
@keyframes steam { 0% { stroke-dashoffset: 40; opacity: 0; } 30% { opacity: 0.8; } 100% { stroke-dashoffset: -40; opacity: 0; } }
@keyframes flicker { 0%, 18%, 22%, 62%, 100% { opacity: 1; } 20%, 60% { opacity: 0.35; } }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@keyframes coinPop { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-46px); opacity: 0; } }
@keyframes bobHot { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .coin { display: none; }
}
