/* =========================================================================
   NEO ARCADE MINIMAL
   Feuille claire ou noire, filets fins, une touche fluo.
   Les toiles de jeu restent celles de l'édition d'origine.
   ========================================================================= */

:root {
  --field: #eceae4;
  --sheet: #fffcf8;
  --ink: #161616;
  --muted: #6f6b64;
  --line: rgba(22, 22, 22, 0.14);
  --line-strong: rgba(22, 22, 22, 0.42);
  --fluo: #d6ff3e;
  --blush: #f0c9d4;
  --play: #0c0618;
  --sheet-w: 430px;
  --font-serif: "Instrument Serif", "Iowan Old Style", Palatino, Georgia, serif;
  --font-sans: "Instrument Sans", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

html.theme-dark {
  --field: #0a0a0a;
  --sheet: #141414;
  --ink: #f4f2ec;
  --muted: #9c978e;
  --line: rgba(244, 242, 236, 0.14);
  --line-strong: rgba(244, 242, 236, 0.42);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

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

::selection { background: var(--fluo); color: #161616; }

.mark {
  width: 8px;
  height: 8px;
  background: var(--fluo);
  display: inline-block;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

/* =========================================================================
   CHAMP (desktop)
   ========================================================================= */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.scene__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 96px 96px;
  background-position: center;
}

.scene__aside {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: none;
}

.scene__aside--left { left: 5vw; }
.scene__aside--right { right: 5vw; text-align: right; }

.scene__word {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(72px, 8vw, 128px);
  line-height: 0.85;
  letter-spacing: -0.04em;
}

.scene__sign {
  margin: 14px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 28px;
}

@media (min-width: 1180px) {
  .scene__aside { display: block; }
}

/* =========================================================================
   FEUILLE
   ========================================================================= */
.device {
  position: relative;
  z-index: 1;
  width: var(--sheet-w);
  height: min(920px, 94vh);
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.06);
}

html.theme-dark .device {
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

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

.view { min-height: 100%; display: flex; flex-direction: column; }

/* =========================================================================
   CATALOGUE
   ========================================================================= */
.view--home {
  padding: 22px 18px 28px;
  gap: 26px;
}

.mast { position: relative; padding-top: 4px; }

.theme {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.theme:hover { background: var(--ink); color: var(--sheet); }

.mast__title {
  margin: 8px 0 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 68px;
  line-height: 0.84;
  letter-spacing: -0.045em;
}

.mast__sign {
  margin: 14px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 26px;
}

.mast__lede {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 18px 12px;
  align-content: start;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.tile--feature { grid-column: span 6; }
.tile--half { grid-column: span 3; }
.tile--third { grid-column: span 2; }

.tile:hover { border-color: var(--ink); }
.tile:active { transform: scale(0.992); }

.tile__frame {
  position: relative;
  overflow: hidden;
  background: var(--play);
}

.tile--feature .tile__frame { aspect-ratio: 16 / 10; }
.tile--half .tile__frame,
.tile--third .tile__frame { aspect-ratio: 1 / 1; }

.tile__frame::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent, var(--fluo));
  z-index: 2;
}

.tile__shot {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.6s ease;
}

.tile:hover .tile__shot { transform: scale(1.045); }

.tile__shot--empty {
  background:
    linear-gradient(180deg, transparent, transparent),
    var(--play);
}

.tile__num {
  position: absolute;
  left: 10px;
  bottom: 6px;
  z-index: 2;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}

.tile__info {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  cursor: pointer;
}

.tile__info:hover { background: rgba(0, 0, 0, 0.55); }

.tile__caption {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 11px;
  border-top: 1px solid var(--line);
}

.tile__names { min-width: 0; }

.tile__title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile--half .tile__title,
.tile--third .tile__title { font-size: 16px; }

.tile__tag {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tile__stats {
  margin: 0;
  text-align: right;
  flex: none;
}

.tile__stats b {
  display: block;
  font-weight: 500;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.tile__stats small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.tile--soon { cursor: default; opacity: 0.72; }
.tile--soon:hover { border-color: var(--line); }
.tile__wait { color: var(--muted); font-size: 12px; }

.colophon {
  margin-top: auto;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* fiche */
.rules {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: color-mix(in srgb, var(--field) 62%, transparent);
  backdrop-filter: blur(10px);
}

.rules__card {
  width: min(360px, 100%);
  margin-bottom: 8px;
  padding: 26px 22px 20px;
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  text-align: left;
}

.rules__title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.rules__text {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

.rules__close,
.ovl__btn,
.flappy__cta {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--sheet);
  cursor: pointer;
}

.rules__close:hover,
.ovl__btn:hover,
.flappy__cta:hover {
  background: var(--fluo);
  border-color: var(--fluo);
  color: #161616;
}

.rules__close:active,
.ovl__btn:active,
.flappy__cta:active { transform: scale(0.98); }

/* =========================================================================
   JEU
   ========================================================================= */
.view--game {
  position: relative;
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.game-hud {
  position: relative;
  z-index: 10;
  flex: none;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

.hud-back {
  justify-self: start;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hud-title {
  margin: 0;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-figures { text-align: right; }

.hud-score {
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}

.hud-best {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.game-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--sheet);
}

.flappy, .gwrap { position: absolute; inset: 0; touch-action: none; }
.flappy__canvas, .gwrap__canvas { display: block; width: 100%; height: 100%; }

.flappy__overlay, .ovl {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 8;
  transition: opacity 0.2s ease;
}

.flappy__overlay[data-state="playing"],
.ovl[data-state="playing"] {
  opacity: 0;
  pointer-events: none;
}

.flappy__panel, .ovl__panel {
  text-align: left;
  width: min(300px, 100%);
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  padding: 22px 20px 18px;
  color: var(--ink);
}

.flappy__hint, .ovl__hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.flappy__big, .ovl__title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-shadow: none;
}

.flappy__sub, .ovl__sub {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
}

.flappy__final, .ovl__final { margin: 4px 0 16px; }

.flappy__score-line, .ovl__line {
  margin: 3px 0;
  font-size: 13px;
  color: var(--muted);
}

.flappy__score-line b, .ovl__line b {
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

.flappy__record, .ovl__record {
  margin: 10px 0 0;
  font-family: var(--font-serif);
  font-size: 14px;
  font-style: italic;
  color: #161616;
  background: var(--fluo);
  display: inline-block;
  padding: 2px 7px;
  text-shadow: none;
  animation: none;
}

.glives {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 9;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--sheet);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 5px 8px;
  pointer-events: none;
}

/* =========================================================================
   MOBILE : la feuille devient l'écran
   ========================================================================= */
@media (max-width: 760px), (max-height: 740px) {
  .scene { display: none; }
  .device {
    width: 100%;
    height: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
  }
  .view--home {
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
  }
  .game-hud {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .glives { bottom: max(14px, env(safe-area-inset-bottom)); }
  .mast__title { font-size: 64px; }
}
