/* LE MOT — grille, clavier AZERTY, surligneurs (le reste vient de carnet.css). */
:root {
  --hi-green:  rgba(200, 255, 61, .95);   /* surligneur fluo de la charte */
  --hi-orange: rgba(255, 158, 27, .88);   /* surligneur orangé : cercle */
}

/* ---- Modes ---- */
.modes { display: flex; gap: 8px; }

.mode {
  padding: 4px 12px 5px;
  border: 2px solid var(--ink);
  border-radius: var(--box-a);
  background: #fff;
  color: var(--ink);
  font: 600 20px var(--hand);
  cursor: pointer;
  touch-action: manipulation;
}

.mode + .mode { border-radius: var(--box-b); }

.mode[aria-pressed="true"] { background: var(--fluo); }

.stats > .icons { margin-left: auto; display: flex; flex-direction: row; gap: 10px; }

.stats .icons .icon-btn {
  margin: 0;
  display: grid;
  place-items: center;
  font: 400 22px var(--marker);
  color: var(--ink);
}

/* ---- Grille ---- */
.layout {
  grid-template-columns: minmax(0, 380px) minmax(300px, 500px);
  justify-content: center;
  gap: 48px;
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 11px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; }

.t {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-family: var(--marker);
  font-size: clamp(30px, 9vw, 42px);
  line-height: 1;
  color: var(--ink);
  text-transform: uppercase;
}

.t .ink { z-index: 0; }

.row.future .t .ink { opacity: .28; }

.t .l {
  position: relative;
  z-index: 2;
  display: inline-block;
  transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--r, 0deg));
}

.t.typed .l { animation: pop .18s ease; }

/* Surligneur : une tache posée derrière la lettre. */
.t::before {
  content: '';
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

/* Bien placée : fluo plein, la lettre reste noire. */
.t.correct::before {
  inset: 9% 6% 11% 7%;
  background: var(--hi-green);
  border-radius: 12% 30% 14% 26% / 30% 12% 28% 14%;
  transform: rotate(-3deg) skewX(-4deg);
}

/* Mal placée : cercle épais au surligneur orangé (forme différente). */
.t.present::before {
  inset: 11%;
  border: 5px solid var(--hi-orange);
  border-radius: 52% 46% 50% 44% / 46% 52% 44% 50%;
  background: rgba(255, 190, 60, .12);
  transform: rotate(-12deg);
}

/* Absente : crayon gris, lettre légèrement barrée. */
.t.absent { color: var(--pencil); }

.t.absent::after {
  content: '';
  position: absolute;
  z-index: 3;
  left: 24%; right: 22%;
  top: 50%;
  height: 2.5px;
  border-radius: 2px;
  background: var(--pencil);
  opacity: .85;
  transform: rotate(-16deg);
}

/* Écriture de la réponse : la case « se retourne », puis le surligneur passe. */
.t.rev .l { animation: write .5s ease both; animation-delay: var(--d, 0s); }

@keyframes write {
  0%   { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--r, 0deg)) scaleY(1); }
  45%  { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--r, 0deg)) scaleY(0); }
  100% { transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--r, 0deg)) scaleY(1); }
}

.t.swipe::before { animation: swipe .35s ease-out both; }
.t.swipe.present::before { animation: circle .35s ease-out both; }
.t.swipe.absent::after { animation: strike .3s ease-out both; }

@keyframes swipe  { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes circle { from { opacity: 0; transform: rotate(-80deg) scale(.6); } to { opacity: 1; transform: rotate(-12deg) scale(1); } }
@keyframes strike { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.row.shake { animation: shake .45s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  35% { transform: translateX(7px); }
  55% { transform: translateX(-5px); }
  75% { transform: translateX(3px); }
}

.t.win { animation: hop .5s ease both; animation-delay: var(--d, 0s); }

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-14px) rotate(-3deg); }
  70% { transform: translateY(3px); }
}

/* ---- Message ---- */
.toast {
  position: fixed;
  left: 50%;
  top: 84px;
  z-index: 20;
  margin: 0;
  padding: 6px 16px 8px;
  border: 2px solid var(--ink);
  border-radius: var(--sketch);
  background: #fff;
  font: 400 22px var(--marker);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px) rotate(-2deg);
  transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-2deg); }

/* ---- Clavier ---- */
.kbd { display: flex; flex-direction: column; gap: 7px; touch-action: manipulation; }

.krow { display: flex; gap: 5px; }

.key {
  flex: 1 1 0;
  min-width: 0;
  height: 56px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 12px 4px 14px 5px / 5px 14px 4px 12px;
  background: #fff;
  color: var(--ink);
  font: 400 24px var(--marker);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key:nth-child(even) { border-radius: 4px 13px 5px 12px / 12px 5px 13px 4px; }

.key.wide { flex-grow: 1.55; font: 700 19px var(--hand); }

.key.wide.back { font: 400 24px var(--marker); }

.key:active { transform: translateY(1px); }

.key.correct { background: var(--fluo); }

.key.present { box-shadow: inset 0 -9px 0 var(--hi-orange); }

.key.absent {
  background: #E4E1D8;
  border-color: var(--pencil);
  color: var(--pencil);
  text-decoration: line-through 2px;
}

.side .actions { margin-top: 18px; }

.btn:disabled { opacity: .35; cursor: default; }

/* ---- Légende ---- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 16px;
  font: 500 19px var(--hand);
  color: var(--text-2);
}

.lg { display: inline-flex; align-items: center; gap: 6px; }

.t.mini { width: 32px; font-size: 20px; }

.row-ex { display: flex; justify-content: center; gap: 9px; margin: 6px 0 2px; }

.row-ex .t { width: 44px; font-size: 26px; }

/* ---- Fenêtres ---- */
.modal-card { position: relative; max-height: calc(100vh - 32px); overflow-y: auto; }

.modal-card .close {
  position: absolute;
  top: 8px; right: 10px;
  width: 40px; height: 40px;
  border: 0;
  background: transparent;
  font: 400 30px var(--marker);
  color: var(--ink);
  cursor: pointer;
}

.help-card { max-width: 420px; text-align: left; }

.help-card h2, .help-card > .label { text-align: center; }

.help-card p { font-size: 20px; margin: 8px 0; line-height: 1.25; }

.help-card .ex p { font-size: 19px; margin: 2px 0 10px; text-align: center; }

.help-card .small { font-size: 18px; color: var(--pencil); }

.end-card { max-width: 400px; }

.end-card h2 { font-size: clamp(34px, 10vw, 46px); }

.end-card #end-text { margin: 0 0 10px; }

.end-card #end-text b {
  font: 400 30px var(--marker);
  color: var(--ink);
  letter-spacing: .08em;
  background: linear-gradient(transparent 50%, var(--fluo) 50%, var(--fluo) 92%, transparent 92%);
}

.st-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 6px 0 14px; }

.st-grid div { display: flex; flex-direction: column; align-items: center; }

.st-grid b { font: 400 28px var(--marker); line-height: 1.1; white-space: nowrap; }

.st-grid span { font: 500 16px var(--hand); color: var(--label); line-height: 1.05; }

.modal-card p.dist-title { margin: 0 0 6px; font-size: 18px; }

.dist { display: flex; flex-direction: column; gap: 4px; text-align: left; }

.dist .bar-row { display: flex; align-items: center; gap: 8px; font: 400 18px var(--marker); }

.dist .bar-row > span:first-child { width: 12px; }

.dist .bar {
  min-width: 26px;
  padding: 0 8px;
  border-radius: 3px 8px 4px 9px;
  background: #E4E1D8;
  text-align: right;
  font: 400 17px var(--marker);
}

.dist .bar.now { background: var(--fluo); }

.countdown { margin: 12px 0 0 !important; font-size: 20px !important; }

.countdown b { font: 400 22px var(--marker); color: var(--ink); }

.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.end-card .btn.primary { width: auto; }

.share-fallback {
  width: 100%;
  height: 150px;
  margin-top: 12px;
  font: 14px var(--mono);
  border: 2px solid var(--ink);
  border-radius: 8px;
}

.share-fallback[hidden] { display: none; }

/* ---- Mobile ---- */
@media (max-width: 820px) {
  .game { padding-top: 16px; }
  .head h1 { font-size: 44px; }
  .mode { font-size: 18px; padding: 3px 10px 4px; }
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .board { max-width: 318px; gap: 9px; }
  .row { gap: 9px; }
  .t { font-size: 34px; }
  .kbd { gap: 6px; }
  .krow { gap: 4px; }
  .key { height: 54px; font-size: 22px; }
  .key.wide { font-size: 16px; }
  .stats { margin: 10px 0 12px; }
  .toast { top: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .t.rev .l, .t.swipe::before, .t.swipe::after, .t.win, .row.shake, .t.typed .l { animation: none !important; }
}
