/* Fraunces : police d'affichage variable auto-hébergée pour le wordmark. */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}

:root {
  color-scheme: light dark;

  --green: #1f8f5f;
  --gold: #e4a72e;
  --blue: #2674b8;
  --red: #c84b45;

  /* Thème clair (par défaut) */
  --ink: #101512;
  --muted: #5f6863;
  --bg: #f7f4ec;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #fffdf8;
  --line: rgba(19, 28, 22, 0.14);
  --deep: #14201a;
  --on-deep: #fffaf0;
  --glow-a: rgba(31, 143, 95, 0.18);
  --glow-b: rgba(38, 116, 184, 0.16);

  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ecefe9;
    --muted: #9aa39c;
    --bg: #0f1411;
    --panel: rgba(30, 38, 33, 0.62);
    --panel-solid: #1a221d;
    --line: rgba(220, 235, 225, 0.12);
    --deep: #f1ede2;
    --on-deep: #11160f;
    --glow-a: rgba(31, 143, 95, 0.22);
    --glow-b: rgba(38, 116, 184, 0.2);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 12% -10%, var(--glow-a), transparent 42%),
    radial-gradient(110% 80% at 100% 0%, var(--glow-b), transparent 46%),
    var(--bg);
}

button {
  font: inherit;
  color: inherit;
}

.app {
  width: min(100%, 30rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(0.75rem, 3vw, 1.2rem) clamp(0.85rem, 4vw, 1.25rem) 1.4rem;
  display: flex;
  flex-direction: column;
  gap: clamp(0.7rem, 2.5vw, 1rem);
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.mark {
  width: 2.85rem;
  height: 2.85rem;
  flex: 0 0 auto;
}
.mark rect {
  fill: var(--deep);
}
.mark path {
  fill: none;
  stroke: var(--on-deep);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}
.mark circle {
  fill: var(--gold);
}

.eyebrow,
h1 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: clamp(2.1rem, 9vw, 3rem);
  line-height: 0.9;
  letter-spacing: -0.015em;
}

/* Bouton icône (partage) */
.icon-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.85rem;
  height: 2.85rem;
  border: 0;
  border-radius: 0.7rem;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.icon-button svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: var(--deep);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button svg circle {
  fill: var(--deep);
  stroke: none;
}
.icon-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 0.4rem 1rem rgba(15, 24, 18, 0.14), 0 0 0 1px var(--line);
}
.icon-button:not(:disabled):active {
  transform: translateY(0);
}
.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- HUD ---------- */
.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.hud div {
  min-width: 0;
  padding: 0.5rem 0.4rem 0.55rem;
  text-align: center;
  border-radius: 0.7rem;
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line);
}

.hud span {
  display: block;
  font-size: clamp(1.25rem, 6vw, 1.7rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud small {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Jeu ---------- */
.game {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 2.5vw, 0.9rem);
  min-height: 0;
}

.sequence {
  min-height: 1rem;
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}
.pip {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: var(--line);
  transition: background-color 150ms ease, transform 150ms ease;
}
.pip.done {
  background: var(--deep);
  transform: scale(1.1);
}

.clock {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.clock-track {
  flex: 1;
  height: 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  overflow: hidden;
}
.clock-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 100ms linear, background-color 200ms ease;
}
.clock-value {
  min-width: 3.2ch;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--deep);
}
.clock.low .clock-fill {
  background: var(--red);
}
.clock.low .clock-value {
  color: var(--red);
}

.pads {
  flex: 1 1 auto;
  align-self: center;
  width: 100%;
  max-width: min(100%, 22rem);
  aspect-ratio: 1;
  max-height: 56vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(0.5rem, 2.5vw, 0.85rem);
}

.pad {
  position: relative;
  border: 0;
  border-radius: 0.85rem;
  cursor: pointer;
  box-shadow:
    inset 0 -0.45rem rgba(0, 0, 0, 0.2),
    0 0.9rem 1.4rem rgba(15, 24, 18, 0.14);
  transform: translateY(0);
  transition: filter 100ms ease, transform 100ms ease, box-shadow 100ms ease;
}
.pad-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(1.4rem, 7vw, 2.1rem);
  color: rgba(255, 255, 255, 0.9);
  opacity: 0.32;
  transition: opacity 120ms ease, transform 120ms ease;
}
.pad.active .pad-glyph,
.pad:active:not(:disabled) .pad-glyph {
  opacity: 0.95;
  transform: scale(1.12);
}
.pad:disabled {
  cursor: not-allowed;
  filter: saturate(0.7) brightness(0.92);
}
.pad.active,
.pad:active:not(:disabled) {
  filter: brightness(1.18) saturate(1.18);
  transform: translateY(0.22rem);
  box-shadow:
    inset 0 -0.18rem rgba(0, 0, 0, 0.18),
    0 0.45rem 0.8rem rgba(15, 24, 18, 0.12);
}
.pad-a { background: var(--green); }
.pad-b { background: var(--gold); }
.pad-c { background: var(--blue); }
.pad-d { background: var(--red); }

.status {
  min-height: 1.4rem;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
}
.status.hot {
  color: var(--deep);
}
.status.error {
  color: var(--red);
}

.actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
}
.primary-button,
.ghost-button {
  min-height: 3rem;
  border-radius: 0.7rem;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}
.primary-button {
  background: var(--deep);
  color: var(--on-deep);
  box-shadow: inset 0 -0.18rem rgba(0, 0, 0, 0.24);
  letter-spacing: 0.01em;
}
.primary-button:not(:disabled):active {
  transform: translateY(1px);
}
.ghost-button {
  min-width: 5.5rem;
  padding: 0 0.95rem;
  background: var(--panel);
  color: var(--deep);
  box-shadow: 0 0 0 1px var(--line);
}
.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  color: color-mix(in srgb, var(--ink) 38%, transparent);
  background: color-mix(in srgb, var(--panel-solid) 55%, transparent);
  box-shadow: 0 0 0 1px var(--line);
}

/* ---------- Pied : méta + réglages ---------- */
.meta {
  margin-top: 0.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.meta-stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.meta-stats div {
  min-width: 0;
}
.meta-stats dt {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.meta-stats dd {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.rules {
  flex: 1 1 auto;
  min-width: 0;
}
.rules summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.2rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.rules summary::-webkit-details-marker {
  display: none;
}
.rules summary::before {
  content: "›";
  display: inline-block;
  transition: transform 150ms ease;
  font-size: 1.05em;
}
.rules[open] summary::before {
  transform: rotate(90deg);
}
.rules-body {
  padding: 0.2rem 0 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.rules-body p {
  margin: 0.5rem 0 0;
}

/* Champ langue discret : icône globe + select transparent */
.lang-field {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.55rem;
  color: var(--muted);
  transition: background-color 120ms ease, color 120ms ease;
}
.lang-field:hover {
  background: var(--panel);
  color: var(--deep);
}
.lang-globe {
  display: grid;
  place-items: center;
}
.lang-globe svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.lang-select {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0.1rem;
}
.lang-select option {
  color: var(--ink);
  background: var(--panel-solid);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

/* Largeur confortable sur grand écran : on garde l'app centrée et étroite,
   c'est un jeu à une main. On élargit juste un peu les zones tactiles. */
@media (min-width: 700px) {
  .app {
    padding-top: 2rem;
  }
}
