/* Factory Clicker 2008 — design rétro arcade.
   Fond sombre, accents néon, polices système/monospace. Aucun asset externe. */

:root {
  --bg: #05060a;
  --bg-2: #0b0e1a;
  --panel: #0d1120;
  --panel-edge: #1e293b;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.55);
  --cyan: #22d3ee;
  --magenta: #e879f9;
  --green: #4ade80;
  --red: #f87171;
  --text: #e5e7eb;
  --text-dim: #94a3b8;
  --font-mono: "Lucida Console", "Courier New", ui-monospace, Menlo, monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Voile CRT discret (scanlines) par-dessus tout, sans intercepter les clics. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.03) 0 1px,
    transparent 1px 3px
  );
}

/* --- Toile de fond --- */
#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Écrans (menu / jeu / game over) --- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.screen--active {
  display: flex;
}

.screen__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.brand {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
}

.title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(2.6rem, 13vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--amber);
  text-shadow:
    0 0 8px rgba(245, 158, 11, 0.7),
    0 0 28px rgba(245, 158, 11, 0.35);
}

.title--over {
  color: var(--green);
  text-shadow:
    0 0 8px rgba(74, 222, 128, 0.7),
    0 0 28px rgba(74, 222, 128, 0.35);
}

.year {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--magenta);
  text-shadow: 0 0 10px rgba(232, 121, 249, 0.6);
}

/* --- Boutons --- */
.btn {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 42px;
  border: 2px solid var(--amber);
  background: transparent;
  color: var(--amber);
  cursor: pointer;
  box-shadow:
    0 0 14px rgba(245, 158, 11, 0.3),
    inset 0 0 12px rgba(245, 158, 11, 0.12);
  transition: transform 0.06s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: rgba(245, 158, 11, 0.1);
}

.btn:active {
  transform: scale(0.96);
}

.btn--primary {
  background: var(--amber);
  color: #05060a;
}

.btn--primary:hover {
  background: #fbbf24;
}

.btn--ghost {
  font-size: 0.8rem;
  padding: 8px 18px;
  border-color: var(--panel-edge);
  color: var(--text-dim);
  box-shadow: none;
}

.btn--ghost:hover {
  color: var(--red);
  border-color: var(--red);
}

/* --- HUD (compteur) --- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(5, 6, 10, 0.92), rgba(5, 6, 10, 0));
  pointer-events: none;
}

.hud__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.points {
  font-family: var(--font-mono);
  font-size: clamp(1.7rem, 9vw, 2.8rem);
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.55);
}

.rate {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 5vw, 1.4rem);
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

.clickpower {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 5vw, 1.4rem);
  font-weight: 700;
  color: var(--magenta);
  text-shadow: 0 0 8px rgba(232, 121, 249, 0.5);
}

.unit {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* --- Chiffres flottants --- */
.floaters {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  overflow: hidden;
}

.floater {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
  animation: float-up 0.9s ease-out forwards;
}

@keyframes float-up {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1.25);
  }
}

/* --- Boutique --- */
.shop {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: rgba(11, 14, 26, 0.94);
  border-top: 2px solid var(--cyan);
  box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.6);
}

.shop__title {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  color: var(--cyan);
  text-transform: uppercase;
}

.shop__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop__footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.05s ease;
}

.shop-item:not(:disabled):hover {
  border-color: var(--amber);
}

.shop-item:not(:disabled):active {
  transform: scale(0.985);
}

.shop-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-item--locked {
  opacity: 0.35;
}

.shop-item__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.shop-item__name {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
}

.shop-item__desc {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.shop-item__right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.shop-item__cost {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--amber);
}

.shop-item__owned {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--green);
}

.shop-item__owned--empty {
  color: var(--text-dim);
}

.shop-item__done {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--green);
}

/* --- Textes d'aide --- */
.hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.hint--small {
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.8;
}

.stats {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-line;
}

/* --- Bureau : la boutique devient une colonne latérale --- */
@media (min-width: 768px) {
  .shop {
    left: auto;
    top: 0;
    bottom: 0;
    width: 360px;
    max-height: none;
    border-top: none;
    border-left: 2px solid var(--cyan);
    padding-top: max(16px, env(safe-area-inset-top));
  }
}

/* --- Accessibilité : mouvement réduit --- */
@media (prefers-reduced-motion: reduce) {
  .floater {
    animation-duration: 0.01s;
  }
}
