/* =========================================================================
   NEO ARCADE — styles globaux
   Design : néo-rétro / synthwave, mobile-first.
   Sur desktop : coque téléphone centrée + décor animé autour.
   ========================================================================= */

:root {
  --bg: #0c0618;
  --screen-bg: #150b2e;
  --ink: #f3eaff;
  --muted: #b39ddb;

  --neon-cyan: #00f0ff;
  --neon-magenta: #ff2e97;
  --neon-yellow: #ffd23f;
  --neon-green: #06ffa5;
  --neon-purple: #a06bff;

  --radius-screen: 38px;
  --phone-w: 390px;
  --phone-h: 844px;

  --font-pixel: "Press Start 2P", monospace;
  --font-ui: "Outfit", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh; /* vrai plein écran mobile, ignore la barre d'adresse */
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

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

/* =========================================================================
   DÉCOR DESKTOP (synthwave)
   ========================================================================= */
.scene { position: fixed; inset: 0; overflow: hidden; z-index: 0; }

.scene__glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(255,46,151,0.35), transparent 60%),
    radial-gradient(70% 60% at 50% 70%, rgba(0,240,255,0.18), transparent 60%),
    linear-gradient(180deg, #1a0f33 0%, #0c0618 70%);
}

.scene__grid {
  position: absolute;
  left: 50%; bottom: 0;
  width: 200%; height: 55%;
  transform: translateX(-50%) perspective(380px) rotateX(70deg);
  transform-origin: bottom center;
  background-image:
    linear-gradient(to right, rgba(0,240,255,0.5) 1px, transparent 1px),
    linear-gradient(to top, rgba(255,46,151,0.5) 1px, transparent 1px);
  background-size: 56px 56px;
  animation: gridmove 1.2s linear infinite;
  opacity: 0.5;
}

@keyframes gridmove {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 56px, 0 56px; }
}

/* =========================================================================
   CADRE NÉON (desktop) — simple encadrement, pas une coque de téléphone
   ========================================================================= */
.device {
  position: relative;
  z-index: 1;
  width: var(--phone-w);
  height: var(--phone-h);
  max-height: 92vh;
  border-radius: 28px;
  padding: 7px;
  background: rgba(7, 4, 18, 0.55);
  border: 1.5px solid rgba(160, 107, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(0, 240, 255, 0.18),
    0 0 22px rgba(160, 107, 255, 0.45),
    0 0 70px rgba(255, 46, 151, 0.18),
    0 28px 70px rgba(0, 0, 0, 0.55);
}

.screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 22px;
  background: var(--screen-bg);
  overflow: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* =========================================================================
   VUES
   ========================================================================= */
.view { min-height: 100%; display: flex; flex-direction: column; }

/* ---- Dashboard ---- */
.view--home { padding: 34px 20px 24px; gap: 22px; }

.home-head { text-align: center; padding-top: 14px; }

.home-logo {
  font-family: var(--font-pixel);
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: 1px;
}
.home-logo__neo { color: var(--neon-cyan); text-shadow: 0 0 10px var(--neon-cyan); }
.home-logo__arcade { color: var(--neon-magenta); text-shadow: 0 0 10px var(--neon-magenta); }

.home-sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.5px;
}

/* ---- Dashboard : mosaïque (captures de jeux en fond) ---- */
.tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  flex: 1;
  align-content: start;
}

.tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent, #ffffff) 45%, transparent);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-ui);
  text-align: left;
  background: #0c0618;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent, #ffffff) 16%, transparent),
    0 10px 26px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.tile--feature { grid-column: span 6; aspect-ratio: 16 / 10; }
.tile--half    { grid-column: span 3; aspect-ratio: 4 / 5; }
.tile--third   { grid-column: span 2; aspect-ratio: 3 / 4; }

.tile:active { transform: scale(0.985); }
@media (hover: hover) {
  .tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 0 1px var(--accent), 0 14px 34px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  .tile:hover .tile__shot { transform: scale(1.06); }
}

.tile__shot {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}
.tile__shot--empty {
  display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 20%, rgba(160,107,255,0.25), #0c0618 70%);
}
.tile__glyph { font-size: 40px; filter: grayscale(0.5); opacity: 0.65; }

.tile__veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg,
    rgba(8,4,18,0) 28%, rgba(8,4,18,0.5) 60%, rgba(8,4,18,0.92) 100%);
}

.tile__stats {
  position: absolute; top: 10px; left: 10px;
  display: flex; gap: 8px;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tile__stats span {
  background: rgba(0,0,0,0.45);
  padding: 4px 8px; border-radius: 9px;
  backdrop-filter: blur(4px);
}

.tile__body {
  position: absolute; left: 14px; bottom: 12px;
  right: 14px; pointer-events: none;
}
.tile__title {
  margin: 0; font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,0.75);
}
.tile--feature .tile__title { font-size: 22px; }
.tile--half .tile__title, .tile--third .tile__title {
  font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: calc(100% - 56px); /* laisse la place à la pastille JOUER */
}
.tile__tag {
  margin: 4px 0 0; font-size: 13px;
  color: rgba(243,234,255,0.85);
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
}

.tile__play {
  position: absolute; bottom: 12px; right: 12px;
  font-family: var(--font-pixel);
  font-size: 9px; padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent); color: #1a0f33;
}
.tile--half .tile__play, .tile--third .tile__play { font-size: 7px; padding: 6px 8px; }

/* icône "i" discrète, en haut à droite de la tuile */
.tile__info {
  position: absolute; top: 9px; right: 9px; z-index: 3;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 11px; font-weight: 800; font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(4px);
  opacity: 0.45;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
}
.tile__info:hover { opacity: 1; }
.tile__info:active { transform: scale(0.9); }

/* fiche de règles (overlay léger) */
.rules {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(8,4,18,0.72);
  backdrop-filter: blur(5px);
  border-radius: inherit;
  overflow: hidden;
  animation: pop 0.18s ease;
}
.rules__card {
  text-align: center;
  max-width: 300px;
  padding: 26px 22px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 28%, transparent);
}
.rules__glyph { font-size: 40px; margin-bottom: 8px; }
.rules__title {
  margin: 0 0 10px; font-size: 18px; font-weight: 800;
  color: var(--accent);
}
.rules__text { margin: 0 0 20px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.rules__close {
  font-family: var(--font-pixel); font-size: 10px;
  padding: 12px 22px; border: none; border-radius: 12px;
  background: var(--accent); color: #1a0f33; cursor: pointer;
}
.rules__close:active { transform: scale(0.95); }

.tile--soon { cursor: default; opacity: 0.8; }
.tile__badge {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--font-pixel);
  font-size: 7px; padding: 6px 8px; border-radius: 9px;
  background: rgba(255,255,255,0.12); color: var(--muted);
}

.home-foot {
  text-align: center;
  font-size: 11px;
  color: rgba(179,157,219,0.5);
  letter-spacing: 0.5px;
}

/* ---- Écran de jeu ---- */
.view--game { position: relative; height: 100%; }

.game-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 44px 18px 10px;
  pointer-events: none;
}
.game-hud > * { pointer-events: auto; }

.hud-back {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.35);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.hud-back:active { transform: scale(0.94); }

.hud-score {
  font-family: var(--font-pixel);
  font-size: 30px;
  color: #fff;
  text-shadow: 0 0 12px var(--neon-cyan), 0 2px 0 rgba(0,0,0,0.4);
  font-variant-numeric: tabular-nums;
}

.hud-best {
  font-size: 13px;
  font-weight: 600;
  color: var(--neon-yellow);
  background: rgba(0,0,0,0.35);
  padding: 7px 11px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.game-stage { position: absolute; inset: 0; }

/* =========================================================================
   JEU : FLAPPY
   ========================================================================= */
.flappy { position: absolute; inset: 0; touch-action: none; }
.flappy__canvas { display: block; width: 100%; height: 100%; }

.flappy__overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  z-index: 8;
  transition: opacity 0.2s ease;
}
.flappy__overlay[data-state="playing"] { opacity: 0; pointer-events: none; }

.flappy__panel {
  text-align: center;
  background: rgba(10,4,24,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 26px 24px;
  backdrop-filter: blur(8px);
  max-width: 280px;
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.flappy__hint {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--neon-cyan);
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.flappy__big {
  font-family: var(--font-pixel);
  font-size: 22px;
  color: var(--neon-yellow);
  text-shadow: 0 0 14px rgba(255,210,63,0.6);
  margin-bottom: 10px;
}
.flappy__sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.flappy__final { margin: 6px 0 18px; }
.flappy__score-line {
  font-size: 13px; color: var(--muted);
  letter-spacing: 1px; margin: 4px 0;
}
.flappy__score-line b {
  color: #fff; font-size: 20px; margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.flappy__record {
  margin-top: 10px;
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--neon-green);
  text-shadow: 0 0 10px var(--neon-green);
  animation: blink 0.8s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

.flappy__cta {
  font-family: var(--font-pixel);
  font-size: 12px;
  padding: 14px 26px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,46,151,0.4);
  transition: transform 0.12s ease;
}
.flappy__cta:active { transform: scale(0.95); }

/* =========================================================================
   UI DE JEU PARTAGÉE (overlay start / game over) — Snake, Bricks…
   ========================================================================= */
.gwrap { position: absolute; inset: 0; touch-action: none; }
.gwrap__canvas { display: block; width: 100%; height: 100%; }

.ovl {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px; z-index: 8;
  transition: opacity 0.2s ease;
}
.ovl[data-state="playing"] { opacity: 0; pointer-events: none; }

.ovl__panel {
  text-align: center;
  background: rgba(10,4,24,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 26px 24px;
  backdrop-filter: blur(8px);
  max-width: 280px;
  animation: pop 0.25s ease;
}
.ovl__hint {
  font-family: var(--font-pixel);
  font-size: 8px; letter-spacing: 1px;
  color: var(--neon-cyan); margin-bottom: 14px;
}
.ovl__title {
  font-family: var(--font-pixel);
  font-size: 20px; margin-bottom: 10px;
  color: var(--accent, var(--neon-yellow));
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent, var(--neon-yellow)) 60%, transparent);
}
.ovl__sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.ovl__final { margin: 6px 0 18px; }
.ovl__line { font-size: 13px; color: var(--muted); letter-spacing: 1px; margin: 4px 0; }
.ovl__line b {
  color: #fff; font-size: 20px; margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.ovl__record {
  margin-top: 10px;
  font-family: var(--font-pixel);
  font-size: 9px; color: var(--neon-green);
  text-shadow: 0 0 10px var(--neon-green);
  animation: blink 0.8s steps(2) infinite;
}
.ovl__btn {
  font-family: var(--font-pixel);
  font-size: 12px; padding: 14px 26px;
  border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--neon-magenta), var(--neon-purple));
  color: #fff; cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,46,151,0.4);
  transition: transform 0.12s ease;
}
.ovl__btn:active { transform: scale(0.95); }

/* vies (Bricks) posées dans le coin inférieur gauche, zone libre sous les
   briques, pour ne chevaucher ni le HUD ni l'aire de jeu */
.glives {
  position: absolute; bottom: 16px; left: 16px; z-index: 9;
  font-size: 14px; letter-spacing: 2px; color: var(--neon-magenta);
  background: rgba(0,0,0,0.35); padding: 6px 10px; border-radius: 12px;
  backdrop-filter: blur(6px); pointer-events: none;
}

/* =========================================================================
   RESPONSIVE — plein écran sur mobile / petits écrans
   ========================================================================= */
@media (max-width: 480px), (max-height: 740px) {
  .scene { display: none; }
  .device {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    padding: 0;
    border: none;
    background: var(--screen-bg);
    box-shadow: none;
  }
  .screen { border-radius: 0; }
  .game-hud { padding-top: max(44px, env(safe-area-inset-top)); }
  .view--home { padding-top: max(34px, env(safe-area-inset-top)); }
  /* on respecte les zones sûres (encoche / barre système) en bas */
  .view--home { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .glives { bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* écrans très hauts : on agrandit un peu le cadre */
@media (min-width: 481px) and (min-height: 920px) {
  :root { --phone-h: 880px; }
}
