:root {
  --green-dark: #0a2d2b;
  --green: #1a4b45;
  --green-light: #2f6f62;
  --amber: #f2c94c;
  --cream: #fef5cf;
  --blue: #7ad1ff;
  --accent: #ff6f61;
  --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;
  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;
}

#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;
}

.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;
}

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;
}

#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) {
  #hud {
    grid-template-columns: 1fr;
  }
  #leaderboardPanel {
    grid-column: auto;
  }
}
