:root {
  --bg: #0b0b0e;
  --fg: #e6e6e6;
  --dim: #8a8a93;
  --accent: #ffd54a;
  --good: #6ee7b7;
  --bad: #ef6b6b;
  --cool: #7cc7ff;
  --magenta: #d18cff;
  --panel: #15151b;
  --panel-hi: #1f1f28;
  --border: #2a2a35;
}

* { box-sizing: border-box; }

html {
  font-size: 20px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
  overscroll-behavior: none;
}

@media (min-width: 700px) {
  html { font-size: 22px; }
}

body {
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 640px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-height: 60vh;
}

h1, h2 {
  margin: 0 0 12px 0;
  font-weight: 700;
  line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }

.prompt {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.result {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent);
}

.ai-hint {
  display: inline-block;
  background: var(--panel-hi);
  border: 1px dashed var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0 12px 0;
  font-style: italic;
}

.dim { color: var(--dim); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.accent { color: var(--accent); }
.cool { color: var(--cool); }

pre.art {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.05;
  background: #08080b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin: 8px 0;
  overflow-x: auto;
  color: var(--fg);
  white-space: pre;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

button.option,
button.primary {
  background: var(--panel-hi);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease;
}

button.option:hover,
button.primary:hover {
  background: #262633;
  border-color: #3a3a48;
}

button.option:active,
button.primary:active {
  transform: scale(0.99);
}

button.option .cost {
  display: block;
  font-size: 0.85rem;
  color: var(--dim);
  margin-top: 4px;
}

button.option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.option.disabled .cost { color: var(--bad); }

button.primary {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  border-color: var(--accent);
  text-align: center;
}

button.primary:hover { background: #ffdf6e; }

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
}

.res-chip {
  background: var(--panel-hi);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
}

.res-chip .gen {
  color: var(--good);
  margin-left: 4px;
  font-size: 0.8rem;
}

.win-banner {
  background: linear-gradient(135deg, #1f1f28, #2a2a35);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  margin: 12px 0;
}

.win-banner .big {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}

.confetti {
  font-family: ui-monospace, monospace;
  letter-spacing: 4px;
  color: var(--accent);
  text-align: center;
  font-size: 1.2rem;
}

/* Minigame */
#minigame-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.minigame-stats {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 700;
}

#minigame-canvas {
  display: block;
  width: 100%;
  background: #050507;
  border: 1px solid var(--border);
  border-radius: 8px;
  image-rendering: pixelated;
  touch-action: none;
}

.swipe-hint {
  text-align: center;
  color: var(--dim);
  font-size: 0.85rem;
}

.minigame-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.minigame-buttons button {
  background: var(--panel-hi);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.minigame-buttons button:active {
  background: var(--accent);
  color: #1a1a1a;
}

.footer-note {
  text-align: center;
  color: var(--dim);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Smaller phones: shrink ASCII art more aggressively */
@media (max-width: 380px) {
  pre.art { font-size: 0.72rem; }
}

@media (max-width: 320px) {
  pre.art { font-size: 0.62rem; }
}
