:root {
  --ice: #bfe9ff;
  --ice-dark: #5aa9d6;
  --ink: #12304a;
  --pop: #ff4f81;
  --yellow: #ffd23f;
  --card: rgba(255, 255, 255, 0.92);
  font-family: ui-rounded, 'SF Pro Rounded', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); }
body {
  background: radial-gradient(circle at 30% 20%, #e9f8ff, #9fd6f5 60%, #6fb3e0);
}
.screen { display: none; position: fixed; inset: 0; align-items: flex-start; justify-content: center; padding: 16px; overflow: auto; }
.screen > * { margin: auto 0; }
.screen.active { display: flex; }
.overlay { background: rgba(10, 30, 50, 0.55); backdrop-filter: blur(3px); z-index: 10; }

.card {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 28px;
  box-shadow: 0 10px 0 var(--ice-dark), 0 20px 40px rgba(0, 40, 80, 0.25);
  max-width: 520px;
  width: 100%;
}
h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 54px);
  letter-spacing: 2px;
  text-align: center;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 4px 4px 0 var(--ice-dark);
  transform: rotate(-2deg);
}
h1 span { color: var(--pop); display: inline-block; transform: rotate(12deg); }
.tagline { text-align: center; margin-top: 6px; }
h3 { margin: 18px 0 8px; }
label { display: block; font-weight: 700; margin: 14px 0 6px; }
.small { font-size: 14px; opacity: 0.75; margin: 4px 0; }
.error { color: var(--pop); font-weight: 700; min-height: 1.2em; }

input {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 3px solid var(--ice-dark);
  outline: none;
}
input:focus { border-color: var(--pop); }
button {
  font: inherit;
  font-weight: 800;
  font-size: 17px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.05s;
}
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button.big { width: 100%; font-size: 21px; margin-top: 18px; background: var(--pop); color: #fff; }
button.ghost { background: #fff; font-size: 14px; padding: 6px 12px; }
button:hover { filter: brightness(1.05); }
.join-row { display: flex; gap: 10px; margin-top: 12px; }
.join-row input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; }

.chars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.chars button {
  font-size: 26px;
  padding: 4px 0;
  background: #fff;
  border-width: 2px;
  box-shadow: 0 2px 0 var(--ink);
}
.chars button.sel { background: var(--yellow); transform: scale(1.12) rotate(-6deg); }
.chars button.taken { opacity: 0.25; cursor: not-allowed; }

.lobby-grid { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; align-items: flex-start; width: 100%; max-width: 1040px; }
.lobby-grid .card { flex: 1 1 420px; }
.room-code {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 12px;
  text-align: center;
  color: var(--pop);
  text-shadow: 3px 3px 0 var(--ink);
}
#btn-copy { display: block; margin: 0 auto; }
.members { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.members li { background: #eaf7ff; border-radius: 10px; padding: 6px 10px; font-weight: 700; }
.members li .c { font-size: 22px; margin-right: 6px; }
.members li.me { outline: 3px solid var(--yellow); }
.durations { display: flex; gap: 8px; }
.durations button { flex: 1; background: #fff; }
.durations button.sel { background: var(--yellow); }
.help { max-width: 460px; font-size: 15px; }
.keys { padding-left: 18px; }
kbd { background: #fff; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; padding: 0 6px; font-size: 13px; }
.catalog { list-style: none; padding: 0; margin: 0; max-height: 330px; overflow: auto; }
.catalog li { padding: 4px 0; border-bottom: 1px dashed #c6e3f5; }
.catalog .e { font-size: 22px; margin-right: 6px; }

/* ---------- JEU ---------- */
#game { padding: 0; background: #0b2238; }
#canvas { display: block; }
#hud-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
#timer { font-size: 38px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 3px 3px 0 var(--ink); }
#mult { font-weight: 900; color: var(--yellow); text-shadow: 2px 2px 0 var(--ink); font-size: 20px; }
#banner {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%) rotate(-1.5deg);
  background: var(--pop); color: #fff; font-weight: 900; font-size: 22px;
  padding: 10px 22px; border-radius: 14px; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  display: none; text-align: center; max-width: 80vw; pointer-events: none;
}
#banner small { display: block; font-weight: 600; font-size: 15px; }
#scores {
  position: absolute; top: 10px; left: 10px; margin: 0; padding: 8px 12px 8px 34px;
  background: rgba(255, 255, 255, 0.85); border-radius: 14px; font-weight: 700; font-size: 14px; pointer-events: none; min-width: 190px;
}
#scores li { margin: 2px 0; }
#scores .bar { display: inline-block; height: 8px; background: var(--ice-dark); border-radius: 4px; vertical-align: middle; margin-left: 6px; }
#scores li.me { color: var(--pop); }
#log {
  position: absolute; top: 10px; right: 10px; width: min(380px, 35vw); list-style: none; margin: 0; padding: 0; pointer-events: none;
}
#log li {
  background: rgba(255, 255, 255, 0.88); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; font-size: 14px; font-weight: 600;
  animation: pop 0.25s ease-out; transition: opacity 0.5s;
}
@keyframes pop { from { transform: scale(0.6) translateX(40px); opacity: 0; } }
#held {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92); border: 3px solid var(--ink); border-radius: 16px; padding: 8px 16px;
  font-weight: 700; display: flex; gap: 12px; align-items: center; max-width: 90vw; box-shadow: 0 5px 0 var(--ink); pointer-events: none;
}
#held .e { font-size: 40px; }
#held.empty { opacity: 0.6; }

/* ---------- FIN ---------- */
.end-card { max-width: 560px; text-align: center; }
#end-winner .big-char { font-size: 90px; display: block; animation: bounce 0.8s infinite alternate; }
#end-winner h2 { margin: 6px 0; font-size: 30px; }
@keyframes bounce { to { transform: translateY(-14px) rotate(8deg); } }
#end-ranking { text-align: left; display: inline-block; font-weight: 700; }
.awards { list-style: none; padding: 0; text-align: left; }
.awards li { background: #eaf7ff; border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; }
