/* iCACA — thème "cahier doodle" : carreaux, traits irréguliers, ombres dures, caca kawaii */

:root {
  --paper: #fffdf6;
  --grid: #dce8f3;
  --card: #ffffff;
  --ink: #34231b;
  --ink-soft: #6f5a4e;
  --shadow: #34231b;
  --on-color: #34231b; /* texte posé sur une couleur vive */

  --brown: #9b5e30;
  --brown-light: #d29a5e;
  --pink: #ff8fb5;
  --mint: #80ddbc;
  --sun: #ffd94d;
  --sky: #93ccff;
  --lilac: #bdaeff;
  --red: #f2545b;
  --focus: #5b4bdb;

  --font-display: 'Chewy', 'Baloo 2', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --font-body: 'Patrick Hand', 'Comic Neue', 'Comic Sans MS', 'Chalkboard SE', sans-serif;

  /* rectangles "dessinés à la main" */
  --r1: 255px 16px 225px 16px / 16px 225px 16px 255px;
  --r2: 16px 255px 16px 225px / 225px 16px 255px 16px;
  --r3: 225px 20px 255px 14px / 14px 255px 20px 225px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1.5px, transparent 1.5px),
    linear-gradient(90deg, var(--grid) 1.5px, transparent 1.5px);
  background-size: 30px 30px;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.1; margin: 0; }
p { margin: 0 0 .6rem; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brown); }

:focus-visible { outline: 3px dashed var(--focus); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap;
}

#app { position: relative; z-index: 1; min-height: 100vh; }

/* ---------- décor : petits doodles dans les coins ---------- */
.doodles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.doodles svg { position: absolute; opacity: .55; }

/* ---------- boutons ---------- */
.btn {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: .02em;
  border: 3px solid var(--ink);
  background: var(--sun);
  color: var(--on-color);
  padding: .5rem 1.2rem;
  border-radius: var(--r3);
  box-shadow: 3px 4px 0 var(--shadow);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.btn:hover { transform: translate(-1px, -1px) rotate(-1deg); box-shadow: 4px 5px 0 var(--shadow); }
.btn:active { transform: translate(3px, 4px); box-shadow: 0 0 0 var(--shadow); }
.btn.primary { background: var(--brown); color: #fff; }
.btn.pink { background: var(--pink); }
.btn.mint { background: var(--mint); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border-style: dashed; }
.btn.ghost:hover { box-shadow: none; }
.btn.small { font-size: 1rem; padding: .25rem .8rem; box-shadow: 2px 3px 0 var(--shadow); }
.btn.big { font-size: 1.4rem; padding: .7rem 1.6rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 3px 4px 0 var(--shadow); }
.btn.selected { background: var(--mint); }

/* ---------- cartes & champs ---------- */
.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--r1);
  box-shadow: 5px 6px 0 var(--shadow);
  padding: 1.4rem 1.6rem;
}
.card.alt { border-radius: var(--r2); }
.card.tilt-l { transform: rotate(-1deg); }
.card.tilt-r { transform: rotate(1deg); }

.field { display: grid; gap: .25rem; margin-bottom: 1rem; }
.field > span { font-family: var(--font-display); font-size: 1.05rem; }
.field small { color: var(--ink-soft); font-size: .9rem; }
.input {
  width: 100%;
  padding: .55rem .9rem;
  border: 3px solid var(--ink);
  border-radius: var(--r2);
  background: #fff;
  color: #34231b;
  font-size: 1.1rem;
}
.input::placeholder { color: #9b8a80; }

.error {
  color: #a3202a;
  background: #ffe3e5;
  border: 3px dashed var(--red);
  border-radius: var(--r2);
  padding: .4rem .8rem;
  margin: 0 0 1rem;
}

.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .2rem .8rem .2rem .3rem;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
}

/* ---------- avatars ---------- */
.avatar {
  width: 2.2rem; height: 2.2rem; flex: none;
  display: inline-grid; place-items: center;
  font-family: var(--font-display); font-size: 1.15rem; color: var(--on-color);
  border: 3px solid var(--ink);
  border-radius: 55% 45% 50% 50% / 50% 55% 45% 50%;
}
.avatar.big { width: 3.2rem; height: 3.2rem; font-size: 1.6rem; }

/* ---------- mascotte ---------- */
.mascot { display: inline-block; line-height: 0; }
.mascot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.mascot.blink .eyes { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* ---------- logo ---------- */
.logo {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--sun);
  text-decoration: none;
  letter-spacing: .02em;
}
.logo .mascot { width: 2.6rem; height: 2.6rem; }
.logo b { color: var(--brown); font-weight: 400; }

/* ---------- écran de connexion ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.auth-card { width: min(100%, 26rem); position: relative; margin-top: 3.5rem; padding-top: 3.2rem; }
.auth-mascot {
  position: absolute; left: 50%; top: -4.6rem; width: 8rem; height: 8rem;
  transform: translateX(-50%) rotate(-4deg);
}
.auth h1 { font-size: 3.2rem; text-align: center; text-shadow: 4px 4px 0 var(--sun); }
.auth h1 b { color: var(--brown); font-weight: 400; }
.auth .sub { text-align: center; color: var(--ink-soft); margin-bottom: 1.2rem; }
.tabs { display: flex; gap: .6rem; margin-bottom: 1.2rem; }
.tabs .btn { flex: 1; font-size: 1rem; padding: .35rem .5rem; }

/* ---------- accueil ---------- */
.page { max-width: 62rem; margin: 0 auto; padding: 1.2rem 1.2rem 4rem; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 2rem;
}
.topbar .right { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.page h2.title { font-size: 2.2rem; margin-bottom: 1.2rem; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: var(--mint); color: var(--on-color);
  border: 3px solid var(--ink); border-radius: var(--r2); box-shadow: 4px 5px 0 var(--shadow);
  padding: .7rem 1.2rem; margin-bottom: 1.8rem;
}
.banner strong { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1.8rem; margin-bottom: 2.4rem; }
.game-card { display: flex; flex-direction: column; gap: .7rem; padding: 1.2rem 1.3rem 1.4rem; }
.game-card:nth-child(even) { transform: rotate(1deg); border-radius: var(--r2); }
.game-card:nth-child(odd) { transform: rotate(-1deg); }
.game-card .icon {
  width: 4.4rem; height: 4.4rem; display: grid; place-items: center; font-size: 2.4rem;
  border: 3px solid var(--ink); border-radius: 50% 45% 55% 50% / 55% 50% 45% 50%;
  background: var(--accent, var(--sun));
}
.game-card h3 { font-size: 1.8rem; }
.game-card .tag { color: var(--ink-soft); flex: 1; }
.game-card .meta { font-size: .95rem; color: var(--ink-soft); }
.game-card.soon { border-style: dashed; box-shadow: none; background: transparent; text-align: center; align-items: center; justify-content: center; color: var(--ink-soft); min-height: 14rem; }
.game-card.soon .q { font-family: var(--font-display); font-size: 3.4rem; color: var(--brown-light); }

.join { display: flex; gap: .8rem; flex-wrap: wrap; align-items: end; max-width: 30rem; }
.join .field { margin: 0; flex: 1; min-width: 9rem; }
.join .input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-family: var(--font-display); font-size: 1.4rem; }

/* ---------- salle ---------- */
.roombar {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.roombar .info { font-family: var(--font-display); font-size: 1.1rem; }
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.8rem; align-items: start; }
.code {
  display: inline-block; margin: .3rem 0 .4rem;
  font-family: var(--font-display); font-size: 3.6rem; letter-spacing: .25em; padding-left: .25em;
  background: var(--sun); color: var(--on-color);
  border: 3px solid var(--ink); border-radius: var(--r3); box-shadow: 4px 5px 0 var(--shadow);
  cursor: pointer;
}
.players { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.players li { display: flex; align-items: center; gap: .6rem; }
.players li.off { opacity: .5; }
.players .crown { font-size: 1.2rem; }
.settings { display: grid; gap: .5rem; margin: 1rem 0; }
.settings label { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.settings input[type=checkbox] { width: 1.4rem; height: 1.4rem; accent-color: var(--brown); }
.settings select { padding: .3rem .6rem; border: 3px solid var(--ink); border-radius: var(--r2); background: #fff; color: #34231b; }
.settings .ro { display: flex; justify-content: space-between; border-bottom: 2px dashed var(--ink-soft); padding: .15rem 0; }
.actions { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.2rem; align-items: center; }
.hint { color: var(--ink-soft); font-size: .95rem; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  display: grid; gap: .5rem; z-index: 50; width: min(92vw, 28rem); pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: .6rem 1rem;
  border: 3px solid #fff; border-radius: var(--r2); box-shadow: 3px 4px 0 rgba(0,0,0,.25);
  text-align: center;
}
.toast.err { background: #a3202a; }

/* ---------- compte à rebours ---------- */
.cd {
  display: inline-grid; place-items: center; min-width: 3.4rem; height: 3.4rem; padding: 0 .5rem;
  font-family: var(--font-display); font-size: 1.5rem; color: var(--on-color);
  background: var(--sun); border: 3px solid var(--ink); border-radius: 50% 45% 55% 50% / 55% 50% 45% 50%;
}
.cd.low { background: var(--pink); }

/* ---------- petits écrans ---------- */
@media (max-width: 760px) {
  body { font-size: 18px; }
  .page { padding: .8rem .8rem 3rem; }
  .lobby-grid { grid-template-columns: 1fr; }
  .code { font-size: 2.8rem; }
  .logo { font-size: 2rem; }
  .auth h1 { font-size: 2.6rem; }
}

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