:root {
  --bg: #0c0f12;
  --panel: #171c22;
  --line: #303843;
  --text: #f5f7f8;
  --muted: #97a0aa;
  --lime: #dfff53;
  --ink: #11160a;
  --yellow: #e4c060;
  --absent: #2b323a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px system-ui, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; }

header {
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px max(5vw, 16px);
}

.eyebrow { color: var(--lime); }
nav { display: flex; align-items: center; gap: clamp(10px, 3vw, 18px); }

button {
  border: 0;
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--lime);
  color: var(--ink);
  font: 700 14px inherit;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease, opacity 120ms ease;
}

button:hover { filter: brightness(1.06); }
button:disabled { cursor: wait; opacity: .65; }

#loading-retry { min-width: 44px; min-height: 44px; }

.action-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--lime);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.action-link:hover { filter: brightness(1.06); }

nav button {
  min-height: 44px;
  background: none;
  color: var(--muted);
  padding: 4px;
}

.brand {
  display: grid;
  gap: 2px;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand:hover { filter: none; }

.brand-signature {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .22em;
}

.brand-name {
  color: var(--text);
  font-size: .86rem;
  font-weight: 850;
  letter-spacing: .18em;
  white-space: nowrap;
}

.brand-name i {
  color: var(--lime);
  font-style: normal;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 150px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}

.profile-trigger[hidden] { display: none; }
.profile-trigger span:last-child { overflow: hidden; text-overflow: ellipsis; }

main {
  width: min(620px, 94vw);
  margin: auto;
  padding: 64px 0;
}

.eyebrow {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 {
  font-size: clamp(3.4rem, 12vw, 5.8rem);
  line-height: .9;
  letter-spacing: -.08em;
  margin: 16px 0 42px;
}

h2 {
  font-size: 2.7rem;
  letter-spacing: -.06em;
}

form, .result {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  display: grid;
  gap: 12px;
}

.info-card {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.info-card h3 { margin: 7px 0 12px; font-size: 1.35rem; }
.previous-word { display: block; color: var(--lime); font-size: 2rem; letter-spacing: .14em; }
.muted-copy, .loading-copy, .status-copy { color: var(--muted); }
.inline-error { min-height: 1.25em; margin: 0; color: #ffa7a7; }

label { font-weight: 700; }

input {
  margin-top: 8px;
  width: 100%;
  padding: 13px;
  background: #0d1115;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  text-transform: uppercase;
  font: inherit;
}

textarea {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  resize: vertical;
  background: #0d1115;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

small { color: var(--muted); }
.top { display: flex; justify-content: space-between; }
.top p { color: var(--muted); }
.top em { color: var(--lime); font-style: normal; }
.top > strong { font-size: 2rem; }

.grid {
  display: grid;
  gap: 7px;
  justify-content: center;
  margin: 36px 0 14px;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, 54px);
  gap: 7px;
}

.cell {
  height: 54px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 800;
}

.active-cell {
  cursor: pointer;
  user-select: none;
}

.active-cell.cursor {
  border-color: var(--muted);
  box-shadow: inset 0 -3px 0 var(--lime);
}

.correct, .key-correct {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
}

.cell.correct, .key-correct { border-style: double; border-width: 3px; }

.present, .key-present {
  background: var(--yellow);
  color: var(--ink);
  border-color: var(--yellow);
}

.cell.present, .key-present { border-style: dashed; border-width: 2px; }

.absent, .key-absent { background: var(--absent); }
.cell.absent, .key-absent { border-style: dotted; border-width: 2px; }

#keys {
  width: 100%;
  margin-top: 18px;
  touch-action: manipulation;
  user-select: none;
}

.keys {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(3px, 1vw, 6px);
  margin: 6px 0;
}

.keys-third {
  grid-template-columns: repeat(10, minmax(0, 1fr));
}

.key {
  min-width: 0;
  height: clamp(42px, 11vw, 52px);
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #3a424c;
  color: var(--text);
  font-size: clamp(.72rem, 3.2vw, .95rem);
  transition: transform 70ms ease, filter 70ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key-action {
  grid-column: span 2;
  background: #59636e;
}

.key.is-pressed, .key:active {
  transform: translateY(2px);
  filter: brightness(.86);
}

.key:focus-visible, .active-cell:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

.key-correct {
  background: var(--lime);
  color: var(--ink);
}

.key-present {
  background: var(--yellow);
  color: var(--ink);
}

.key-absent {
  background: var(--absent);
  color: #b4bbc2;
}

#error {
  height: 20px;
  color: #ffa7a7;
  text-align: center;
}

.result {
  font-size: 1rem;
  line-height: 2;
  margin: 28px 0;
}

#performance-title {
  font-size: clamp(2.7rem, 10vw, 5rem);
}

#win-attempts {
  color: var(--muted);
  font-weight: 750;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 24px 0 10px;
}

.stats-grid article {
  min-width: 0;
  padding: 16px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats-grid strong, .stats-grid span { display: block; }
.stats-grid strong { color: var(--lime); font-size: 1.25rem; }
.stats-grid span { margin-top: 5px; color: var(--muted); font-size: .76rem; }
.table-wrap { overflow-x: auto; }

.profile-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  font-size: 1.5rem;
}

.profile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-grid article:first-child { grid-column: span 3; }

.text-button {
  padding: 0;
  background: transparent;
  color: var(--muted);
}

#account-recovery {
  min-height: 44px;
  padding: 10px 12px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
}

.history-list { display: grid; gap: 13px; margin-top: 22px; }
.history-more { display: block; margin: 18px auto 0; }
.history-more[hidden] { display: none; }

.history-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.history-card h3 { margin: 0 0 10px; }
.history-found { color: var(--lime); }
.history-missed { color: var(--muted); }
.history-word { font-size: 1.2rem; font-weight: 800; letter-spacing: .08em; }
.history-details { display: flex; flex-wrap: wrap; gap: 8px 15px; color: var(--muted); }

.result strong { font-size: 1.45rem; display: block; }
.result small { display: block; }
table { width: 100%; border-collapse: collapse; margin-top: 24px; }
th, td { padding: 15px 5px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .75rem; }
td:last-child { text-align: right; }
pre { padding: 16px; background: var(--panel); white-space: pre-wrap; }

.report-button {
  min-height: 44px;
  padding: 7px 9px;
  background: transparent;
  color: var(--muted);
  font-size: .76rem;
  text-decoration: underline;
  text-underline-offset: .2em;
}

.preferences-card {
  display: grid;
  gap: 12px;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(150deg, #171c22, #11160f);
}

.preferences-card h3 { margin: 0; font-size: 1.5rem; }
.preferences-card .eyebrow, .preferences-card p { margin: 0; }
.preference-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.preference-row strong, .preference-row small { display: block; }
.preference-row small { margin-top: 3px; }
.preference-toggle { cursor: pointer; }
.preference-toggle input {
  appearance: none;
  flex: 0 0 auto;
  width: 48px;
  height: 27px;
  margin: 0;
  padding: 3px;
  border-radius: 999px;
  background: var(--absent);
  transition: background 120ms ease;
}
.preference-toggle input::before {
  content: '';
  display: block;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 120ms ease;
}
.preference-toggle input:checked { background: var(--lime); }
.preference-toggle input:checked::before { transform: translateX(19px); background: var(--ink); }
.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}
.danger-button { background: #ffb4b4; color: #2b0808; }
.danger-copy { color: #ffb4b4; }
.data-policy-link { color: var(--muted); text-underline-offset: .2em; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  padding: 24px max(5vw, 16px) max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}
.site-footer a { min-height: 44px; display: inline-flex; align-items: center; color: inherit; }

.update-notes-backdrop, .roadmap-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, .68);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.help-backdrop, .migration-backdrop, .profile-action-dialog-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, .72);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.migration-dialog, .profile-action-dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.migration-dialog h2, .profile-action-dialog h2 { margin: 8px 40px 16px 0; font-size: clamp(1.8rem, 7vw, 2.7rem); }
.dialog-actions { display: grid; gap: 10px; margin-top: 22px; }
.weekly-podium { overflow-wrap: anywhere; }
.weekly-podium h2 { font-size: clamp(1.5rem, 5vw, 2rem); }
.weekly-podium > button:last-child { min-height: 44px; }

.account-pin-row small { line-height: 1.45; }
.pin-field { display: block; margin-top: 16px; }
.pin-field:first-of-type { margin-top: 0; }
#account-pin-value, #account-pin-confirm, #account-recovery-pin {
  font-size: 1.35rem;
  letter-spacing: .5em;
  text-align: center;
}
.account-pin-dialog button[type="submit"],
.account-recovery-dialog button[type="submit"] { margin-top: 20px; min-height: 44px; }

.help-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 18px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d1115;
}
.help-tabs button { color: var(--muted); background: transparent; }
.help-tabs button[aria-selected="true"] { color: var(--ink); background: var(--lime); }
.notification-state {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #11161b;
}
.notification-state p { margin: 0; }
.notification-state ol { margin: 0; padding-left: 22px; }

.help-dialog {
  position: relative;
  width: min(600px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  max-height: min(760px, calc(100dvh - 40px));
  overflow: auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.help-dialog h2 { margin: 9px 35px 10px 0; font-size: clamp(2rem, 7vw, 3rem); }
.help-lead { color: var(--lime); font-size: 1.08rem; font-weight: 800; }
.help-rules { display: grid; gap: 8px; padding-left: 22px; }
.help-colors { display: grid; gap: 8px; margin: 18px 0; }
.help-colors p { display: flex; align-items: center; gap: 8px; margin: 0; }
.help-swatch { flex: 0 0 auto; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 4px; }
.help-confirm { width: 100%; margin-top: 14px; }

.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}

.update-notes, .roadmap {
  position: relative;
  width: min(520px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  max-height: min(720px, calc(100dvh - 40px));
  overflow: auto;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.update-notes h2, .roadmap h2 {
  margin: 8px 0 20px;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1;
}

.update-notes-thanks { margin: 20px 0 10px; font-weight: 800; }
.update-notes ul, .roadmap ul { display: grid; gap: 13px; padding: 0; margin: 0; list-style: none; }
.update-notes li { display: flex; gap: 12px; padding: 13px; background: #11161b; border: 1px solid var(--line); border-radius: 8px; }
.roadmap li { padding: 11px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.update-notes li > span { font-size: 1.25rem; }
.update-notes li strong, .update-notes li small { display: block; }
.update-notes li small { margin-top: 4px; }
.update-notes-confirm { width: 100%; margin-top: 22px; }
.update-notes-roadmap { display: block; width: 100%; padding: 14px 8px; background: transparent; color: var(--muted); font-weight: 700; }
.update-notes-roadmap:hover { text-decoration: underline; color: var(--text); }
.roadmap > button:last-child { width: 100%; margin-top: 22px; }

.update-notes-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}

.update-notes-close:hover { color: var(--text); border-color: var(--muted); }

@media (max-width: 450px) {
  main { width: min(100% - 16px, 620px); padding: 42px 0; }
  .row { grid-template-columns: repeat(5, 45px); }
  .cell { height: 45px; }
  .top p { font-size: .82rem; }
  .update-notes, .roadmap { padding: 26px 20px; }
  .update-notes h2, .roadmap h2 { padding-right: 25px; }
  .help-dialog { padding: 25px 19px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid article:first-child { grid-column: span 2; }
  .preferences-card { padding: 18px 15px; }
  .preference-row:not(.preference-toggle) { align-items: stretch; flex-direction: column; }
  .preference-row button { width: 100%; }
  th, td { padding-inline: 3px; font-size: .82rem; }
  .report-button { padding-inline: 3px; font-size: .68rem; }
}

@media (max-width: 650px) {
  header { align-items: flex-start; flex-wrap: wrap; gap: 9px; padding-block: 11px; }
  .header-actions { width: 100%; gap: 8px; }
  nav { flex: 1; justify-content: space-between; gap: 7px; }
  nav button { font-size: .76rem; }
  .profile-trigger { width: 44px; height: 44px; justify-content: center; padding: 0; }
  .profile-trigger span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (display-mode: standalone) {
  header { padding-top: max(10px, env(safe-area-inset-top)); }
}

/* v0.6.1 — entrée, compte, appareils, PIN et bandeau de mise à jour. */
.login-info { min-height: 0; margin: 0 0 16px; }
.login-info:empty { display: none; }
.account-status { margin: 0; }
.account-status:empty { display: none; }
.account-section { display: grid; margin-top: 4px; }
.account-heading { margin: 10px 0 4px; font-size: 1.1rem; }
.account-section .preference-row button { min-height: 44px; }
.device-list { display: grid; gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
.device-list[hidden] { display: none; }
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.device-row button, .device-revoke-all, .device-confirm button, .connected-devices-dialog button.secondary-button { min-height: 44px; }
.device-revoke-all { width: 100%; margin-top: 8px; }
.device-revoke-all[hidden], .device-confirm[hidden], .connected-devices-dialog [hidden] { display: none; }
.device-confirm { margin-top: 12px; }
.logout-dialog .dialog-actions button, .logout-confirm-form button { min-height: 44px; }
.logout-confirm-form[hidden] { display: none; }
.logout-confirm-form { margin-top: 16px; }
.pin-confinement-notice { margin: 16px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.45; }
.pin-revoke-others {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 8px;
  cursor: pointer;
}
.pin-revoke-others input { width: 22px; height: 22px; margin: 0; accent-color: var(--lime); }
.pin-revoke-others:has(input:disabled) { cursor: not-allowed; opacity: .7; }
.pin-trust-note { margin: 8px 0 0; font-size: .92rem; line-height: 1.45; }
.pin-trust-note[hidden] { display: none; }

.update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 10px;
  margin: 0 0 16px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
/* Spec PWA §6 : deux lignes de texte au plus, boutons sur une ligne, environ 88 px au plus à 360 px. */
.update-banner-copy { flex: 1 1 180px; min-width: 0; }
.update-banner-copy strong, .update-banner-copy p { display: block; margin: 0; font-size: .875rem; line-height: 1rem; }
.update-banner-copy p { color: var(--muted); font-size: .8rem; }
.update-banner-actions { display: flex; flex: 0 0 auto; gap: 6px; margin-left: auto; }
.update-banner-actions button { min-width: 44px; min-height: 44px; padding: 10px 12px; }
