:root {
  --green-dark: #0a2d2b;
  --green: #1a4b45;
  --green-light: #2f6f62;
  --amber: #f2c94c;
  --cream: #fef5cf;
  --blue: #7ad1ff;
  --accent: #ff6f61;
  --profit: #8ee66b;
  --loss: #ff7b7b;
  --panel-bg: rgba(10, 45, 43, 0.85);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
  background: radial-gradient(circle at top, #1c2b3a, #04080f);
  color: var(--cream);
  min-height: 100vh;
}

#app {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

#pixi-container {
  width: 100%;
  height: 420px;
  border: 4px solid var(--green);
  border-radius: 8px;
  background: #0b1820;
  background-image: linear-gradient(rgba(4, 12, 18, 0.06), rgba(4, 12, 18, 0.1)), url('../assets/lemonade-scene.png');
  background-size: 100% 100%;
  background-position: top center;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

#pixi-container canvas {
  width: 100% !important;
  height: 100% !important;
}

#hud {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 1rem;
}

.hud-header {
  grid-column: span 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 3px solid var(--green);
  padding: 0.8rem;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px #06201e;
}

.title-block h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 2px;
}

.title-block p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--blue);
}

.scoreboard {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
}

.scoreboard div {
  background: #02110f;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 2px solid var(--green-light);
}

.scoreboard span {
  display: block;
  color: #8ed1c4;
  font-size: 0.7rem;
}

.toggles label {
  display: block;
  font-size: 0.8rem;
}

select {
  background: #041610;
  border: 2px solid var(--green-light);
  border-radius: 6px;
  color: var(--cream);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.25rem;
}

#warningBanner {
  grid-column: span 2;
  padding: 0.5rem;
  border: 2px dashed var(--accent);
  color: var(--accent);
  text-align: center;
}

.hidden {
  display: none !important;
}

#panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.panel {
  background: var(--panel-bg);
  border: 3px solid var(--green);
  border-radius: 12px;
  padding: 0.8rem;
  box-shadow: inset 0 0 0 2px #031c18, 0 6px 18px rgba(0, 0, 0, 0.5);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-head p {
  margin: 0;
  font-size: 0.7rem;
  color: var(--blue);
}

.ghost {
  background: transparent;
  border: 2px solid var(--blue);
  color: var(--blue);
  border-radius: 6px;
}

.forecast-details {
  margin-top: 0.8rem;
}

.forecast-condition {
  font-size: 1.2rem;
  margin: 0;
}

.forecast-tip {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  color: #99f1ff;
}

.event-chip {
  display: inline-block;
  margin: 0.6rem 0 0;
  padding: 0.35rem 0.5rem;
  border: 2px solid var(--amber);
  border-radius: 6px;
  color: var(--amber);
  background: rgba(0, 0, 0, 0.22);
  font-size: 0.72rem;
}

.event-description,
.reflection-prompt {
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  line-height: 1.55;
  color: #d8fff8;
}

.estimate-box {
  margin: 0.65rem 0;
  padding: 0.65rem;
  background: rgba(2, 17, 15, 0.72);
  border: 2px solid var(--blue);
  border-radius: 8px;
}

.estimate-box strong {
  display: block;
  color: var(--blue);
  font-size: 0.8rem;
}

.estimate-box p {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
}

#profitProjection {
  color: var(--amber);
}

.store-grid,
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

label {
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

input[type='number'],
input[type='text'] {
  background: #041610;
  border: 2px solid var(--green-light);
  border-radius: 6px;
  padding: 0.4rem;
  color: var(--cream);
  font-family: inherit;
}

.store-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.55rem;
}

button {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 3px solid #06211c;
  background: var(--green-light);
  color: var(--cream);
  cursor: pointer;
  text-transform: uppercase;
}

button.primary {
  background: var(--amber);
  color: #032217;
}

button.secondary {
  background: #133834;
}

button.accent {
  background: var(--accent);
  color: #05110e;
}

.run-body {
  text-align: center;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.results-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0;
}

.spark-chart {
  margin-top: 0.6rem;
  height: 70px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.spark-chart span {
  display: block;
  width: 12px;
  background: var(--amber);
  border-radius: 2px 2px 0 0;
}

.spark-chart span.profit {
  background: var(--profit);
}

.spark-chart span.loss {
  background: var(--loss);
}

.breakdown-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.breakdown-list div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.68rem;
  line-height: 1.35;
}

.breakdown-list strong.good {
  color: var(--profit);
}

.breakdown-list strong.bad {
  color: var(--loss);
}

.upgrade-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.upgrade-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem;
  border: 2px solid rgba(122, 209, 255, 0.35);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.upgrade-list strong {
  display: block;
  color: var(--amber);
  font-size: 0.76rem;
}

.upgrade-list p {
  margin: 0.25rem 0 0;
  color: #d8fff8;
  font-size: 0.68rem;
  line-height: 1.45;
}

.upgrade-list button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

#leaderboardPanel {
  grid-column: span 2;
}

#leaderboardList {
  list-style: decimal;
  padding-left: 1.2rem;
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
}

#leaderboardList li {
  padding: 0.2rem 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}

.overlay-card {
  background: #04201c;
  border: 4px solid var(--amber);
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
}

.overlay-card h1,
.overlay-card h2 {
  margin-top: 0;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.crt-on #pixi-container,
.crt-on #hud {
  position: relative;
}

.crt-on::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: screen;
  opacity: 0.2;
  z-index: 50;
}

#finalScreen form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}

@media (max-width: 900px) {
  #app {
    padding: 0.5rem;
  }
  #pixi-container {
    height: 320px;
  }
  .hud-header,
  .scoreboard {
    align-items: stretch;
    flex-direction: column;
  }
  .toggles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }
  #hud {
    grid-template-columns: 1fr;
  }
  .hud-header,
  #warningBanner {
    grid-column: auto;
  }
  #leaderboardPanel {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  body {
    font-family: 'Courier New', Courier, monospace;
  }
  .title-block h1 {
    font-size: 1.25rem;
  }
  .scoreboard,
  .store-grid,
  .recipe-grid,
  .quick-actions,
  .store-actions,
  .overlay-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  button {
    width: 100%;
  }
}
