/* =====================================================
   OTADLE — style principal
   Thème : encre de nuit + néon sakura, posé sur le
   wallpaper (assets/wallpaper.jpg) fourni par toi.
   ===================================================== */

:root {
  --bg: #0b0c14;
  --ink: #eef0ff;
  --ink-dim: #9aa0c3;
  --panel: rgba(15, 17, 30, 0.78);
  --panel-line: rgba(255, 255, 255, 0.08);
  --accent: #ff5c8a;       /* rose sakura néon */
  --accent-2: #7c6bff;     /* violet électrique */
  --correct: #2fbf71;
  --present: #f5b93d;
  --absent: #3a3d52;
  --key: #232637;
  --radius: 14px;
  --font-display: "Mochiy Pop One", sans-serif;
  --font-body: "Outfit", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* ---------- Wallpaper ---------- */
.wallpaper {
  position: fixed;
  inset: 0;
  background: url("../assets/wallpaper.jpg") center / cover no-repeat, var(--bg);
  z-index: -2;
}
.wallpaper-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(124, 107, 255, 0.20), transparent 60%),
    linear-gradient(180deg, rgba(11, 12, 20, 0.72), rgba(11, 12, 20, 0.90));
  z-index: -1;
}

/* ---------- Barre du haut ---------- */
.topbar {
  width: min(560px, 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px 8px;
}

.logo {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255, 92, 138, 0.35);
  cursor: pointer;
}
.logo span { color: var(--accent); }

#btn-back { position: absolute; left: 16px; }

.topbar-actions {
  position: absolute;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-btn,
.language-btn {
  min-width: 64px;
  height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s;
}
.language-btn { min-width: 42px; padding: 0 10px; color: var(--present); }
.help-btn:hover,
.language-btn:hover { transform: translateY(-1px); border-color: var(--accent); background: rgba(255, 92, 138, .12); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.1rem;
  font-family: var(--font-body);
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.icon-btn:hover { transform: scale(1.06); border-color: var(--accent); }
.icon-btn:focus-visible,
.help-btn:focus-visible,
.language-btn:focus-visible,
.logo:focus-visible,
.btn:focus-visible,
.key:focus-visible,
.grid-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Écrans ---------- */
.screen {
  width: min(560px, 100%);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  flex: 1;
}
.hidden { display: none !important; }

.tagline {
  text-align: center;
  color: var(--ink-dim);
  font-size: 1.05rem;
  margin-top: 10px;
}

.date-line { color: var(--ink-dim); font-size: .85rem; }

.creator-credit {
  margin-top: -10px;
  color: var(--ink-dim);
  font-size: .82rem;
  text-align: center;
  font-style: italic;
}

/* ---------- Choix du mode ---------- */
.mode-picker {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.mode-card {
  min-height: 190px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-body);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 8px 30px rgba(255, 92, 138, .15); }
.mode-card strong { font-family: var(--font-display); font-size: 1.15rem; }
.mode-card small { color: var(--ink-dim); font-size: .88rem; line-height: 1.4; }
.mode-icon { font-size: 2.5rem; }

/* ---------- Cartes de choix de grille ---------- */
.grid-picker {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.grid-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-body);
  text-align: left;
  backdrop-filter: blur(6px);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  overflow: hidden;
}
.grid-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.grid-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 30px rgba(255, 92, 138, 0.15);
}

.grid-card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 4px;
}
.grid-card p { color: var(--ink-dim); font-size: .9rem; }

.mini-preview {
  display: flex;
  gap: 4px;
  margin: 10px 0 12px;
}
.mini-preview i {
  width: 16px; height: 16px;
  border-radius: 4px;
  background: var(--key);
  border: 1px solid var(--panel-line);
}

.status-badge {
  position: absolute;
  top: 12px; right: 12px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 4px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}
.status-badge.todo     { background: var(--key); color: var(--ink-dim); }
.status-badge.playing  { background: rgba(245, 185, 61, .15); color: var(--present); }
.status-badge.won      { background: rgba(47, 191, 113, .15); color: var(--correct); }
.status-badge.lost     { background: rgba(255, 92, 138, .15); color: var(--accent); }

/* ---------- Plateau de jeu ---------- */
.game-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chip {
  font-family: var(--font-display);
  font-size: .95rem;
  color: var(--accent);
}
.tries { color: var(--ink-dim); font-size: .9rem; }

.game-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.game-action {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
}
.game-action:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.game-action:disabled { opacity: .55; cursor: not-allowed; }
.hint-action { color: var(--present); }
.surrender-action { color: var(--accent); }

.hint-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--cell, 58px));
  gap: 6px;
  justify-content: center;
}
.hint-row:empty { display: none; }
.hint-cell {
  width: var(--cell, 58px);
  height: calc(var(--cell, 58px) * .62);
  display: grid;
  place-items: center;
  border: 1px dashed rgba(245, 185, 61, .5);
  border-radius: 8px;
  background: rgba(245, 185, 61, .08);
  color: var(--present);
  font-family: var(--font-display);
  font-size: calc(var(--cell, 58px) * .3);
}
.hint-cell.revealed { border-style: solid; background: rgba(245, 185, 61, .18); }

/* ---------- Pendu ---------- */
.hangman-word {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 24px 0;
}
.hangman-letter {
  width: min(48px, calc((100vw - 70px) / 9));
  height: 58px;
  display: grid;
  place-items: center;
  border-bottom: 3px solid var(--accent-2);
  font-family: var(--font-display);
  font-size: 1.45rem;
}
.hangman-result { width: 100%; text-align: center; padding: 16px; border-radius: var(--radius); background: var(--panel); }

.board {
  display: grid;
  gap: 6px;
  /* Colonnes définies en JS via --cols */
  grid-template-columns: repeat(var(--cols, 5), var(--cell, 58px));
  justify-content: center;
}

.cell {
  width: var(--cell, 58px);
  height: var(--cell, 58px);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: calc(var(--cell, 58px) * 0.44);
  border-radius: 10px;
  border: 2px solid var(--panel-line);
  background: rgba(20, 22, 38, 0.65);
  text-transform: uppercase;
  transition: transform .1s;
}
.cell.filled { border-color: var(--ink-dim); animation: pop .12s ease; }
.cell.correct { background: var(--correct); border-color: var(--correct); color: #06120b; }
.cell.present { background: var(--present); border-color: var(--present); color: #1a1204; }
.cell.absent  { background: var(--absent);  border-color: var(--absent);  color: var(--ink-dim); }
.cell.reveal  { animation: flip .45s ease; }

@keyframes pop  { 50% { transform: scale(1.12); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.row-shake { animation: shake .35s ease; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Toast ---------- */
.toast {
  min-height: 1.4em;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  transition: background .15s, box-shadow .15s;
}
.toast:not(:empty) {
  background: rgba(15, 17, 30, .94);
  box-shadow: 0 5px 20px rgba(0, 0, 0, .3);
}

/* ---------- Clavier AZERTY ---------- */
.keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  user-select: none;
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.key {
  flex: 1;
  max-width: 44px;
  height: 52px;
  border: none;
  border-radius: 8px;
  background: var(--key);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.key:active { transform: scale(.94); }
.key.wide { max-width: 76px; flex: 1.6; font-size: .75rem; }
.key.correct { background: var(--correct); color: #06120b; }
.key.present { background: var(--present); color: #1a1204; }
.key.absent  { background: #1b1d2c; color: #565a75; }

/* ---------- Modales ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  padding: 26px 22px 20px;
  text-align: center;
  backdrop-filter: blur(10px);
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--key);
  color: var(--ink);
  cursor: pointer;
}

.result-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 14px;
}
.result-title.win  { color: var(--correct); }
.result-title.lose { color: var(--accent); }

.reveal img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--panel-line);
}
.reveal img.img-missing { display: none; }
.reveal figcaption {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.reveal strong { font-size: 1.15rem; }
.reveal span { color: var(--ink-dim); font-size: .95rem; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 18px 0 10px;
  flex-wrap: wrap;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: .92rem;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--key); color: var(--ink); }

.countdown { color: var(--ink-dim); font-size: .85rem; }
.countdown span { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Aide ---------- */
.help-body { text-align: left; display: flex; flex-direction: column; gap: 12px; font-size: .95rem; }
.help-demo { display: flex; gap: 5px; }
.help-demo .cell { --cell: 42px; }
.dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 3px;
  margin-right: 6px;
}
.dot.green  { background: var(--correct); }
.dot.yellow { background: var(--present); }
.dot.gray   { background: var(--absent); }

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  .mode-picker { grid-template-columns: 1fr; }
  .mode-card { min-height: 140px; }
  .board { --cell: min(56px, calc((100vw - 60px) / var(--cols))); }
  .key { height: 48px; }
}
