* { box-sizing: border-box; }

:root{
  --bg: radial-gradient(circle at 35% 20%, #f7f1c8 0%, #e6dfb6 28%, #d3cda7 55%, #bdb792 100%);
  --card: rgba(255,255,255,.72);
  --muted:#475569;
  --text:#0f172a;
  --line: rgba(15,23,42,.18);

  --ok:#22c55e;
  --warn:#f59e0b;
  --bad:#ef4444;
}

html,body{
  margin:0;
  height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
}

#app{
  max-width: 980px;
  margin: 0 auto;
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.top{
  display:flex;
  gap:12px;
  align-items:flex-end;
  justify-content:space-between;
  flex-wrap:wrap;
}

.brand .title{
  font-size:18px;
  font-weight:800;
  letter-spacing:.2px;
}

.brand .subtitle{
  margin-top:2px;
  font-size:13px;
  color:var(--muted);
}

.hud{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:stretch;
  justify-content:flex-end;
}

.hudItem{
  border:1px solid var(--line);
  background: rgba(255,255,255,.55);
  border-radius:12px;
  padding:8px 10px;
  min-width:160px;
}

.hudLabel{
  font-size:12px;
  color:var(--muted);
}

.hudValue{
  font-size:16px;
  font-weight:800;
  margin-top:2px;
}

.card{
  border:1px solid var(--line);
  background:var(--card);
  border-radius:16px;
  padding:14px;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  display:flex;
  flex-direction:column;
  gap:12px;
}

.noteWrap{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height: 240px;
  border:1px dashed rgba(15,23,42,.22);
  border-radius:14px;
  background: rgba(255,255,255,.60);
  padding:10px;
}

#noteImg{
  display:none; /* évite icône image cassée */
  max-width:min(520px, 92vw);
  max-height: 260px;
  width:auto;
  height:auto;
  image-rendering: auto;
}
#noteImg.ready{ display:block; }

.timer{
  height:10px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--line);
  background: rgba(255,255,255,.45);
}

.timer .bar{
  height:100%;
  width:0%;
  background: rgba(15,23,42,.35);
  transition: width .08s linear;
}

.feedback{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.55);
  font-size:14px;
  line-height:1.35;
  white-space:pre-line;
}

.controls{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

button{
  border:1px solid var(--line);
  background: rgba(255,255,255,.55);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
}

button:hover{ background: rgba(255,255,255,.72); }
button:active{ transform: translateY(1px); }

button.primary{
  background: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.35);
}

button:disabled{
  opacity:.55;
  cursor:not-allowed;
}

/* --- Grille des réponses --- */
.answerGrid{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
}

.answerBtn{
  padding:14px 10px;
  font-size:18px;
  letter-spacing:.3px;
}

.small{
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}

/* ======================================================
   MODE SMARTPHONE (détecté par JS : class "isMobile")
   Objectif : zone note 4x moins haute (240px -> 60px)
====================================================== */

html.isMobile #app{
  padding:10px;
}

html.isMobile .hudItem{
  min-width:140px;
}

html.isMobile .noteWrap{
  min-height: 60px;       /* 4x moins haut */
  padding:6px;
}

html.isMobile #noteImg{
  max-height: 65px;       /* 260px -> ~65px */
}

html.isMobile .answerGrid{
  grid-template-columns: repeat(3, 1fr);
}

html.isMobile .answerBtn{
  padding:16px 10px;      /* boutons plus faciles à cliquer */
  font-size:18px;
}

/* Sécurité : si écran étroit sans détection (ex. desktop fenêtré) */
@media (max-width: 520px){
  .answerGrid{
    grid-template-columns: repeat(3, 1fr);
  }
  .answerBtn{
    font-size:17px;
    padding:14px 8px;
  }
}
