/* ====================================================================
   CrossPlay — nuit d'arcade
   Palette : fond #141430 · surface #1E2044 · or pièce #FFC857
             vert succès #6EE7A0 · rouge erreur #FF6B6B · cases crème #FAF6E9
   Display : "Press Start 2P" (titres, scores) — corps : system sans.
   ==================================================================== */

:root {
  --bg: #141430;
  --bg-deep: #0D0D22;
  --surface: #1E2044;
  --surface-2: #272A58;
  --line: #3A3D77;
  --ink: #EDEDFa;
  --ink-dim: #9A9CC9;
  --gold: #FFC857;
  --green: #6EE7A0;
  --red: #FF6B6B;
  --blue: #7AB8FF;
  --cell: #FAF6E9;
  --cell-ink: #1B1B2E;
  --display: "Press Start 2P", monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -200px, #232560 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.5;
}

/* scanlines très discrètes, signature CRT */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px);
  z-index: 999;
}

/* ---------------- barre haute ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
  border-bottom: 2px solid var(--line);
  background: rgba(13,13,34,.7);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.logo {
  font-family: var(--display);
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(255,200,87,.35);
}
.logo span { color: var(--gold); }

nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav a, nav button {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  text-decoration: none;
  cursor: pointer;
}
nav a.on { color: var(--gold); border-color: var(--line); background: var(--surface); }
nav a:hover, nav button:hover { color: var(--ink); }

.footbar {
  padding: 18px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 12px;
  border-top: 1px solid var(--line);
  margin-top: auto;
}

/* ---------------- structure ---------------- */
main {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
  flex: 1;
}

.boot {
  font-family: var(--display);
  font-size: 13px;
  color: var(--ink-dim);
  text-align: center;
  padding: 80px 0;
}
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

h1.screen-title {
  font-family: var(--display);
  font-size: clamp(14px, 2.6vw, 20px);
  color: var(--gold);
  margin: 0 0 6px;
  letter-spacing: 1px;
}
.sub { color: var(--ink-dim); margin: 0 0 22px; font-size: 14px; }

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: clamp(16px, 3vw, 26px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}

/* ---------------- formulaires ---------------- */
.authbox { max-width: 420px; margin: 6vh auto 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .8px; }
.field input {
  width: 100%;
  background: var(--bg-deep);
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
}
.field input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,200,87,.18); }

.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .05s ease, background .15s;
}
.btn:hover { background: #2F3268; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #201A05; }
.btn-gold:hover { background: #FFD685; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

.formerr { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }
.switchline { margin-top: 14px; font-size: 13px; color: var(--ink-dim); text-align: center; }
.switchline a { color: var(--gold); }

/* ---------------- écran de jeu ---------------- */
.gamehead {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 14px;
}
.gamehead .meta { color: var(--ink-dim); font-size: 13px; }
.hud {
  display: flex; gap: 14px; align-items: center;
  font-family: var(--display); font-size: 11px; color: var(--ink-dim);
}
.hud .timer { color: var(--green); }
.hud .errors { color: var(--red); }

.playzone {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(260px, 1fr);
  gap: clamp(14px, 2.5vw, 28px);
  align-items: start;
}
@media (max-width: 860px) {
  .playzone { grid-template-columns: 1fr; }
}

/* --- grille --- */
.gridwrap { display: flex; flex-direction: column; gap: 12px; }
.grid {
  display: grid;
  gap: 2px;
  background: var(--line);
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  width: fit-content;
  max-width: 100%;
  touch-action: manipulation;
  user-select: none;
}
.cell {
  position: relative;
  width: var(--cs, 44px);
  height: var(--cs, 44px);
  background: var(--cell);
  color: var(--cell-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: calc(var(--cs, 44px) * .5);
  cursor: pointer;
  border-radius: 3px;
}
.cell.block { background: var(--bg-deep); cursor: default; border-radius: 0; }
.cell .num {
  position: absolute; top: 1px; left: 3px;
  font-size: calc(var(--cs, 44px) * .24);
  font-weight: 700; color: #6B6B8A;
}
.cell.word { background: #FFF3CE; }                /* mot actif */
.cell.sel  { background: var(--gold); box-shadow: inset 0 0 0 2px #B97E00; }
.cell.wrong { animation: shake .25s; background: #FFD2D2; color: #8E1F1F; }
.cell.hinted { color: #1463B8; }
.cell.ok { background: #D9F7E5; }
@keyframes shake {
  25% { transform: translateX(-3px); } 75% { transform: translateX(3px); }
}

.gridbtns { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- panneau définitions + thème --- */
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.themebox {
  border: 2px dashed var(--gold);
  border-radius: 12px;
  padding: 14px;
  background: rgba(255,200,87,.06);
}
.themebox h3 {
  margin: 0 0 8px;
  font-family: var(--display); font-size: 11px; color: var(--gold);
}
.themebox .hint-txt { font-size: 13px; color: var(--ink-dim); margin: 0 0 10px; }
.themerow { display: flex; gap: 8px; }
.themerow input {
  flex: 1; min-width: 0;
  background: var(--bg-deep); border: 2px solid var(--line); border-radius: 8px;
  color: var(--ink); padding: 9px 10px; font-size: 14px; outline: none;
}
.themerow input:focus { border-color: var(--gold); }
.theme-found { color: var(--green); font-weight: 700; }
.tries { display: flex; gap: 6px; margin-top: 8px; }
.try { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); }
.try.used { background: var(--red); }
.try.win { background: var(--green); }

.clues h3 {
  font-family: var(--display); font-size: 11px;
  color: var(--blue); margin: 14px 0 8px;
}
.clues ol { list-style: none; margin: 0; padding: 0; }
.clues li {
  padding: 7px 9px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: flex; gap: 8px;
}
.clues li:hover { background: var(--surface-2); }
.clues li.on { background: var(--surface-2); outline: 1px solid var(--gold); }
.clues li.done { color: var(--ink-dim); text-decoration: line-through; }
.clues .n { font-weight: 800; color: var(--gold); min-width: 22px; }

/* ---------------- écran de fin (borne d'arcade) ---------------- */
.gameover {
  max-width: 560px; margin: 4vh auto 0;
  border: 3px solid var(--gold);
  border-radius: 16px;
  background: linear-gradient(180deg, #23255B, var(--surface));
  box-shadow: 0 0 0 6px var(--bg-deep), 0 0 50px rgba(255,200,87,.25);
  padding: clamp(18px, 4vw, 30px);
  text-align: center;
}
.gameover h2 {
  font-family: var(--display); font-size: clamp(15px, 3vw, 20px);
  color: var(--gold); margin: 4px 0 4px;
  text-shadow: 0 0 14px rgba(255,200,87,.6);
}
.gameover .theme-reveal { color: var(--ink-dim); margin: 0 0 16px; font-size: 14px; }
.gameover .theme-reveal b { color: var(--ink); }

.scoreline {
  font-family: var(--display);
  font-size: clamp(22px, 6vw, 34px);
  color: var(--green);
  margin: 8px 0 16px;
  text-shadow: 0 0 18px rgba(110,231,160,.55);
}
.breakdown {
  text-align: left;
  margin: 0 auto 16px;
  max-width: 340px;
  font-size: 14px;
  border-top: 1px dashed var(--line);
}
.breakdown div {
  display: flex; justify-content: space-between;
  padding: 7px 2px; border-bottom: 1px dashed var(--line);
}
.breakdown .v { font-weight: 800; }
.breakdown .plus { color: var(--green); }
.breakdown .minus { color: var(--red); }
.breakdown .mult { color: var(--gold); }

.streakline { font-family: var(--display); font-size: 12px; color: var(--gold); margin-bottom: 16px; }

.sharebox {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  text-align: left;
  margin-bottom: 10px;
}
.endbtns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------------- archive / calendrier ---------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h2 { font-family: var(--display); font-size: 13px; margin: 0; color: var(--ink); }
.calendar {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-dow { text-align: center; font-size: 11px; color: var(--ink-dim); text-transform: uppercase; }
.day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 13px; font-weight: 700;
  color: var(--ink-dim);
  text-decoration: none;
}
.day.empty { background: transparent; border: none; }
.day.none { opacity: .35; }
.day.playable:hover { border-color: var(--gold); color: var(--ink); }
.day.done { background: #1E4634; border-color: var(--green); color: var(--green); }
.day.gold { background: #4A3A12; border-color: var(--gold); color: var(--gold); }
.day.today { outline: 2px solid var(--blue); }
.day .sc { font-size: 10px; font-weight: 600; }
.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 12px; color: var(--ink-dim); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------------- stats ---------------- */
.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px;
  padding: 16px; text-align: center;
}
.stat .v { font-family: var(--display); font-size: clamp(16px, 3vw, 22px); color: var(--gold); }
.stat .v.green { color: var(--green); }
.stat .l { font-size: 12px; color: var(--ink-dim); margin-top: 8px; text-transform: uppercase; letter-spacing: .6px; }

/* ---------------- divers ---------------- */
#kbd {
  position: fixed; top: -100px; left: 0;
  opacity: 0; height: 1px; width: 1px; border: none;
}
#toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-deep); color: var(--ink);
  border: 2px solid var(--gold);
  padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.banner-done {
  background: rgba(110,231,160,.1);
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  .hud { font-size: 9px; gap: 10px; }
  .logo { font-size: 11px; }
}
