*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  background: #050214;
  color: #e0e0e0;
  padding: 12px;
  overflow: hidden;
}

#app {
  position: relative;
  max-width: 920px;
  margin: 0 auto;
  background: rgba(15, 8, 35, 0.6);
  border: 1px solid rgba(217, 70, 239, 0.25);
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-shadow: 0 8px 32px rgba(217, 70, 239, 0.15);
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.back-link {
  font-size: 0.85rem;
  color: #22d3ee;
  text-decoration: none;
  font-weight: 700;
}
.back-link:hover { color: #67e8f9; }
h1 {
  flex: 1;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 0.95rem;
  letter-spacing: 1px;
  text-align: center;
  background: linear-gradient(90deg, #22d3ee, #d946ef, #fde047);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
}
.niv-badge {
  font-size: 0.78rem;
  color: #fde047;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(253, 224, 71, 0.1);
  border: 1px solid rgba(253, 224, 71, 0.3);
  border-radius: 8px;
}

.info-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(10, 5, 25, 0.7);
  border: 1px solid rgba(217, 70, 239, 0.2);
  border-radius: 10px;
}
.info-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.5px;
}
.info-icon { font-size: 0.95rem; }
.info-temps { color: #22d3ee; }
.info-vitesse { color: #fde047; }
.info-distance { color: #d946ef; }
.info-effet { color: #f472b6; }

/* Canvas */
.canvas-wrap {
  position: relative;
  background: #050214;
  border: 2px solid rgba(217, 70, 239, 0.3);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  width: 100%;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Hint controls */
.hint {
  font-size: 0.74rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
  line-height: 1.4;
}
.hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(217, 70, 239, 0.15);
  border: 1px solid rgba(217, 70, 239, 0.4);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.72rem;
  color: #22d3ee;
  margin: 0 1px;
}

/* Mobile pad tactile */
.touchpad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}
.touchbtn {
  padding: 16px 0;
  background: rgba(217, 70, 239, 0.18);
  border: 1px solid rgba(217, 70, 239, 0.45);
  border-radius: 10px;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}
.touchbtn:active { background: rgba(217, 70, 239, 0.35); }
@media (hover: none) and (pointer: coarse) {
  .touchpad { display: grid; }
}

/* Effet flash REVERSE */
.canvas-wrap.reverse-active::after {
  content: 'CONTROLES INVERSES';
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  background: rgba(217, 70, 239, 0.85);
  color: #fff;
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 1px;
  border-radius: 4px;
  animation: reverseFlash 0.4s ease infinite alternate;
}
@keyframes reverseFlash {
  from { opacity: 0.7; }
  to { opacity: 1; transform: translateX(-50%) scale(1.04); }
}

/* Overlay (pas de backdrop-filter : trop coûteux en GPU sur conteneur plein écran) */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 2, 20, 0.92);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.overlay.visible { display: flex; }
.overlay-box {
  background: rgba(20, 10, 45, 0.97);
  border: 2px solid rgba(217, 70, 239, 0.4);
  border-radius: 14px;
  padding: 26px 24px 22px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(217, 70, 239, 0.3);
}
.overlay-box h2 {
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 1.05rem;
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.win-text { color: #4ade80; }
.lose-text { color: #f87171; }
.overlay-box p {
  color: #cbd5e1;
  font-size: 0.88rem;
  margin-bottom: 14px;
  line-height: 1.4;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px;
  background: rgba(217, 70, 239, 0.08);
  border-radius: 8px;
}
.stat-cell { text-align: center; }
.stat-label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; }
.stat-val { font-size: 1.2rem; font-weight: 800; color: #fde047; font-family: 'Courier New', monospace; }

.btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: #a21caf;
  box-shadow: none;
}
.btn-secondary {
  background: #0e7490;
  box-shadow: none;
}
.overlay-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.cta-score-msg {
  color: #fde047;
  font-size: 0.82rem;
  margin-bottom: 10px;
}
.cta-auth-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

footer { font-size: 0.74rem; color: #64748b; margin-top: 8px; text-align: center; }
footer a { color: #22d3ee; text-decoration: none; }
footer a:hover { color: #67e8f9; }

@media (max-width: 480px) {
  #app { padding: 10px 8px 8px; border-radius: 14px; }
  h1 { font-size: 0.78rem; }
  .info-bar { padding: 6px 8px; }
  .info-item { font-size: 0.72rem; }
}
