/* ============================================================
   MOTUS — Jeu télévisé France 2  |  Reproduction fidèle
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@600;700;800&family=Roboto+Condensed:wght@400;700&display=swap');

:root {
  /* Palette officielle Motus */
  --mr:       #cc1a2e;   /* rouge Motus */
  --mr-dark:  #8b0a1f;
  --mr-deep:  #3d0010;
  --my:       #f5c518;   /* jaune Motus */
  --my-dark:  #c49a00;
  --mg-abs:   #444;      /* absente */
  --mg-abs-t: #999;
  --mbg:      #12010a;   /* fond page */
  --mcard:    #1e0312;
  --mborder:  #3a1020;
  --mtext:    #ffffff;
  --cell:     clamp(42px, 11.5vw, 56px);
  --gap:      5px;
  --radius:   50%;
  --font:     'Oswald', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--mbg);
  font-family: var(--font);
  color: var(--mtext);
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   WRAP
   ============================================================ */
#motusWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%; height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 0%, #3d0012 0%, #0e0108 100%);
}

/* ============================================================
   HEADER
   ============================================================ */
#motusHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #c0001e 0%, #8a0016 100%);
  box-shadow: 0 3px 16px rgba(0,0,0,.6);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* Back button */
.m-back-btn {
  background: rgba(0,0,0,.25);
  border: 1.5px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.m-back-btn:hover { background: rgba(0,0,0,.45); }

/* Logo MOTUS */
.m-logo {
  display: flex;
  gap: 2px;
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(24px, 7vw, 32px);
  letter-spacing: 3px;
  position: relative;
}
.m-logo span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em; height: 1em;
  border-radius: 4px;
  line-height: 1;
}
.m-logo span:nth-child(odd)  { color: var(--my); text-shadow: 0 0 8px rgba(245,197,24,.6); }
.m-logo span:nth-child(even) { color: #fff; }

/* Stats */
.m-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-stat {
  text-align: center;
  min-width: 36px;
}
.m-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--my);
  line-height: 1;
}
.m-stat-lbl {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.7);
  font-family: 'Roboto Condensed', sans-serif;
}
.m-stat-sep {
  width: 1px; height: 28px;
  background: rgba(255,255,255,.25);
}

/* ============================================================
   BOARD
   ============================================================ */
#motusBoard {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 12px 0;
  flex: 1;
  justify-content: center;
}

.m-row {
  display: flex;
  gap: var(--gap);
}

/* ── Cell base ── */
.m-cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: var(--radius);
  border: 2.5px solid var(--mborder);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 800;
  font-size: calc(var(--cell) * 0.46);
  letter-spacing: 0;
  color: transparent;
  background: var(--mcard);
  position: relative;
  transition: border-color .15s, transform .12s;
  overflow: hidden;
}

/* Dot inside empty cell */
.m-cell::before {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #3a1525;
  transition: opacity .2s;
}
.m-cell.m-typed::before  { opacity: 0; }
.m-cell.m-revealed::before { opacity: 0; }

/* Typed (current row, letter entered) */
.m-cell.m-typed {
  border-color: rgba(255,255,255,.5);
  color: #fff;
  background: #2a0a1a;
  transform: scale(1.06);
}

/* First letter: always gold */
.m-cell.m-first {
  border-color: var(--my);
  background: var(--my-dark);
  color: #fff;
}

/* ── Revealed states ── */
.m-cell.m-correct {
  background: var(--mr);
  border-color: var(--mr);
  color: #fff;
  box-shadow: 0 0 12px rgba(204,26,46,.7), inset 0 1px 0 rgba(255,255,255,.2);
}

.m-cell.m-present {
  background: var(--my);
  border-color: var(--my-dark);
  color: #3d0010;
  box-shadow: 0 0 12px rgba(245,197,24,.55);
}

.m-cell.m-absent {
  background: var(--mg-abs);
  border-color: #555;
  color: var(--mg-abs-t);
}

/* ── Reveal animation ── */
@keyframes mFlip {
  0%   { transform: scaleY(1); }
  45%  { transform: scaleY(0); }
  55%  { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}
@keyframes mBounce {
  0%, 100% { transform: scale(1); }
  40%       { transform: scale(1.18); }
}
@keyframes mShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(4px); }
}
@keyframes mPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.m-cell.m-reveal { animation: mFlip .5s ease forwards; }
.m-cell.m-win-pop { animation: mBounce .5s ease forwards; }
.m-row.m-row-shake .m-cell { animation: mShake .4s ease; }

/* ============================================================
   MESSAGE BAR
   ============================================================ */
#motusMsg {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  letter-spacing: 1px;
  color: var(--my);
  text-transform: uppercase;
  flex-shrink: 0;
  transition: opacity .3s;
}

/* ============================================================
   KEYBOARD
   ============================================================ */
#motusKbd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0 6px 10px;
  flex-shrink: 0;
}

.mk-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.mk-key {
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(12px, 3.2vw, 15px);
  color: #fff;
  background: #2e0e1c;
  border: 1.5px solid #4a1a2a;
  border-radius: 6px;
  min-width: clamp(26px, 7.5vw, 34px);
  height: clamp(34px, 9vw, 42px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .12s, transform .1s, border-color .2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mk-key:active { transform: scale(.92); }
.mk-key.mk-action {
  min-width: clamp(46px, 13vw, 58px);
  font-size: clamp(10px, 2.8vw, 13px);
  letter-spacing: .5px;
  background: #3d0010;
  border-color: var(--mr-dark);
}
.mk-key.mk-action:hover { background: var(--mr-dark); }

/* Key states after reveal */
.mk-key.k-correct {
  background: var(--mr);
  border-color: var(--mr-dark);
  box-shadow: 0 0 8px rgba(204,26,46,.5);
}
.mk-key.k-present {
  background: var(--my-dark);
  border-color: var(--my);
  color: #fff;
}
.mk-key.k-absent {
  background: #1a1a1a;
  border-color: #333;
  color: #555;
}

/* ============================================================
   OVERLAYS (shared)
   ============================================================ */
#motusIntro,
#motusOver {
  position: fixed;
  inset: 0;
  background: rgba(10, 0, 6, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}

.mo-box {
  background: linear-gradient(160deg, #1e0312 0%, #12010a 100%);
  border: 1.5px solid var(--mr-dark);
  border-radius: 18px;
  padding: 28px 24px 24px;
  max-width: 340px;
  width: 92%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.7), 0 0 0 1px rgba(204,26,46,.2);
}

/* Intro logo */
.mo-logo-big {
  font-family: var(--font);
  font-weight: 800;
  font-size: 52px;
  letter-spacing: 6px;
  color: var(--my);
  text-shadow: 0 0 20px rgba(245,197,24,.6), 0 2px 0 var(--my-dark);
  margin-bottom: 4px;
  line-height: 1;
}

.mo-tagline {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,.7);
  margin: 0 0 20px;
  letter-spacing: 1px;
}

/* Rules */
.mo-rules {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.mo-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,.85);
}
.mo-rule strong { color: #fff; }
.mo-sample {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
}
.mo-correct { background: var(--mr); color: #fff; box-shadow: 0 0 10px rgba(204,26,46,.5); }
.mo-present { background: var(--my); color: #3d0010; box-shadow: 0 0 10px rgba(245,197,24,.45); }
.mo-absent  { background: var(--mg-abs); color: #ccc; }

.mo-hint-note {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  color: var(--my);
  margin: 0 0 20px;
  letter-spacing: .5px;
}

/* Play button */
.mo-play-btn {
  background: linear-gradient(135deg, var(--mr) 0%, var(--mr-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 12px 36px;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(204,26,46,.5);
  transition: transform .15s, box-shadow .15s;
}
.mo-play-btn:hover { transform: scale(1.04); box-shadow: 0 8px 30px rgba(204,26,46,.65); }
.mo-play-btn:active { transform: scale(.97); }

/* ── Game over overlay ── */
.mgo-icon {
  font-size: 52px;
  margin-bottom: 8px;
  display: block;
}
.mgo-title {
  font-family: var(--font);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--my);
  text-shadow: 0 0 16px rgba(245,197,24,.5);
  margin-bottom: 10px;
}
.mgo-word {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  color: #fff;
  background: var(--mr);
  display: inline-block;
  padding: 6px 18px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.mgo-sub {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  color: rgba(255,255,255,.65);
  margin-bottom: 22px;
  letter-spacing: .5px;
}
.mgo-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.mgo-btn-primary {
  background: linear-gradient(135deg, var(--mr) 0%, var(--mr-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 24px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(204,26,46,.5);
  transition: transform .15s;
}
.mgo-btn-primary:hover { transform: scale(1.04); }
.mgo-btn-secondary {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.75);
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 24px;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s;
}
.mgo-btn-secondary:hover { background: rgba(255,255,255,.14); }

/* ============================================================
   RESPONSIVE — très petits écrans
   ============================================================ */
@media (max-height: 620px) {
  #motusHeader { padding: 5px 12px; }
  .m-logo { font-size: 22px; }
  #motusBoard { padding: 6px 0; gap: 4px; }
  #motusMsg { height: 18px; font-size: 11px; }
  #motusKbd { gap: 3px; padding-bottom: 6px; }
  .mk-key { height: clamp(28px, 8vw, 36px); }
}
