/* =====================================================================
   MOT MALIN 2.0 — interface sombre, chaleureuse et lisible.
   Mobile first, safe-areas Android/iOS, aucun framework.
   ===================================================================== */

:root {
  --bg: #080c18;
  --bg-2: #0d1426;
  --panel: rgba(20, 30, 52, 0.78);
  --panel-solid: #121b30;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f6ff;
  --muted: #9aa8c4;
  --muted-2: #71809e;
  --mint: #5eead4;
  --mint-2: #2dd4bf;
  --mint-deep: #0f766e;
  --violet: #a78bfa;
  --violet-2: #8b5cf6;
  --amber: #fbbf24;
  --coral: #fb7185;
  --danger: #f43f5e;
  --success: #34d399;
  --info: #60a5fa;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);
  --shadow-soft: 0 12px 30px -18px rgba(0, 0, 0, 0.75);
  --font: "Segoe UI", "Trebuchet MS", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 8% -10%, rgba(94, 234, 212, 0.14), transparent 62%),
    radial-gradient(900px 600px at 100% 0%, rgba(167, 139, 250, 0.16), transparent 55%),
    linear-gradient(160deg, #070b15 0%, #0a1120 45%, #0a0f1d 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button, input { font: inherit; }
button { color: inherit; }
img { max-width: 100%; display: block; }

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ------------------------------- décor ------------------------------- */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite alternate;
}
.ambient-orb-1 { width: 46vw; height: 46vw; left: -14vw; top: 8vh; background: rgba(45, 212, 191, 0.16); }
.ambient-orb-2 { width: 40vw; height: 40vw; right: -12vw; top: -8vh; background: rgba(139, 92, 246, 0.18); animation-delay: -6s; }
.ambient-orb-3 { width: 34vw; height: 34vw; left: 40vw; bottom: -20vw; background: rgba(251, 113, 133, 0.1); animation-delay: -11s; }
.ambient-grain {
  position: absolute;
  inset: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.055'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}
@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(2vw, 3vh, 0) scale(1.08); }
}

/* ------------------------------ structure ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: calc(10px + var(--safe-top)) clamp(14px, 4vw, 34px) 10px;
  background: linear-gradient(180deg, rgba(8, 12, 24, 0.94), rgba(8, 12, 24, 0.62) 70%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: none;
  padding: 4px;
  cursor: pointer;
}
.brand-logo { width: 32px; height: 32px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(94, 234, 212, 0.3)); }
.brand-text { font-size: 0.92rem; letter-spacing: 0.18em; font-weight: 500; color: var(--muted); }
.brand-text b { color: var(--text); font-weight: 800; }
.brand-version { font-size: 0.6rem; color: var(--muted-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 6px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.pill-idle { color: var(--muted-2); }
.pill-connecting { color: var(--amber); }
.pill-online { color: var(--mint); }
.pill-offline { color: var(--coral); }
.pill-accent { color: var(--mint); border-color: rgba(94, 234, 212, 0.28); background: rgba(94, 234, 212, 0.08); }

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  transition: 0.18s ease;
}
.icon-btn:hover, .icon-btn:focus-visible { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.08); transform: translateY(-1px); }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 8px clamp(14px, 4vw, 34px) calc(40px + var(--safe-bottom));
}

.screen { animation: screen-in 0.36s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 10px 0 22px;
  flex-wrap: wrap;
}
.screen-title { margin: 0; font-size: clamp(1.5rem, 4vw, 2.4rem); letter-spacing: -0.03em; }

/* ------------------------------- accueil ----------------------------- */
.hero { padding: clamp(18px, 4vw, 42px) 0 22px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mint);
  font-weight: 700;
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 16px var(--mint); }

.hero-title {
  margin: 12px 0 4px;
  font-size: clamp(3.4rem, 13vw, 8rem);
  line-height: 0.84;
  letter-spacing: -0.07em;
  font-weight: 900;
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  gap: 0.12em;
}
.hero-title span {
  background: linear-gradient(135deg, #ffffff 8%, #b8fff1 42%, #5eead4 70%, #7dd3fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 40px rgba(94, 234, 212, 0.18));
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(135deg, #f5d0fe 0%, #c4b5fd 40%, #8b5cf6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { max-width: 640px; margin: 16px 0; color: var(--muted); font-size: clamp(0.98rem, 2.2vw, 1.16rem); line-height: 1.55; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-tags span {
  padding: 6px 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.home-layout { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 18px; align-items: start; }

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(24, 35, 60, 0.88), rgba(14, 22, 40, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 160px at 10% -20%, rgba(94, 234, 212, 0.1), transparent 70%);
  pointer-events: none;
}
.panel > * { position: relative; }
.panel-main { padding: clamp(18px, 3vw, 30px); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.02rem; letter-spacing: -0.01em; }
.panel-hint { font-size: 0.72rem; color: var(--muted-2); }
.count-badge { font-size: 0.72rem; color: var(--mint); border: 1px solid rgba(94, 234, 212, 0.25); padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }

.field-label { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-2); font-weight: 700; margin-bottom: 8px; }

.text-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(6, 11, 23, 0.62);
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
  transition: 0.18s ease;
}
.text-input::placeholder { color: var(--muted-2); }
.text-input:focus { border-color: rgba(94, 234, 212, 0.65); box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.12); background: rgba(6, 11, 23, 0.86); }

.action-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 700;
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

.btn-primary {
  color: #04201d;
  background: linear-gradient(135deg, #7ff7e3 0%, #2dd4bf 45%, #22c5b0 100%);
  box-shadow: 0 16px 34px -16px rgba(45, 212, 191, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-accent {
  background: linear-gradient(135deg, #c4b5fd 0%, #8b5cf6 60%, #7c3aed 100%);
  color: #160a2e;
  box-shadow: 0 16px 34px -18px rgba(139, 92, 246, 0.7);
}
.btn-ghost { background: rgba(255, 255, 255, 0.055); border-color: var(--line-strong); }
.btn-quiet { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-quiet:hover { color: var(--text); }
.btn-success { background: linear-gradient(135deg, #6ee7b7, #10b981); color: #032019; }
.btn-danger { background: linear-gradient(135deg, #fda4af, #f43f5e); color: #2b0510; }
.btn-wide { width: 100%; }
.btn-small { min-height: 38px; padding: 8px 12px; font-size: 0.8rem; border-radius: 11px; }
.btn-back { min-height: 40px; }

.btn-hero {
  justify-content: flex-start;
  text-align: left;
  min-height: 74px;
  padding: 14px 18px;
  gap: 14px;
}
.btn-hero .btn-emoji { font-size: 1.6rem; filter: drop-shadow(0 0 12px rgba(4, 32, 29, 0.35)); }
.btn-hero b { display: block; font-size: 1.08rem; letter-spacing: -0.01em; }
.btn-hero small { display: block; font-size: 0.76rem; font-weight: 600; opacity: 0.72; margin-top: 2px; }

.kbd {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--muted-2);
}

.resume-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(94, 234, 212, 0.07);
  border: 1px solid rgba(94, 234, 212, 0.24);
}
.resume-box b { display: block; font-size: 0.88rem; }
.resume-box span { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 2px; }
.resume-actions { display: flex; align-items: center; gap: 6px; }

/* ------------------------------ options ------------------------------ */
.option-group { margin-bottom: 16px; }
.option-label { display: block; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; margin-bottom: 8px; }

.segmented {
  display: flex;
  gap: 5px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(5, 10, 20, 0.58);
  border: 1px solid var(--line);
}
.seg {
  flex: 1;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: 0.16s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 5px 6px;
}
.seg small { font-size: 0.62rem; font-weight: 600; opacity: 0.65; }
.seg:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.seg:disabled { opacity: 0.5; cursor: not-allowed; }
.seg.active {
  color: #04201d;
  background: linear-gradient(135deg, #7ff7e3, #2dd4bf);
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 20px -12px rgba(45, 212, 191, 0.85);
}
.seg.active small { opacity: 0.72; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.switch-row b { display: block; font-size: 0.86rem; }
.switch-row small { display: block; font-size: 0.72rem; color: var(--muted-2); margin-top: 2px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-strong);
  transition: 0.2s ease;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.2s ease;
}
.switch-row input:checked + .switch { background: rgba(45, 212, 191, 0.25); border-color: rgba(45, 212, 191, 0.55); }
.switch-row input:checked + .switch::after { transform: translateX(20px); background: var(--mint); box-shadow: 0 0 12px rgba(94, 234, 212, 0.7); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--mint); outline-offset: 2px; }

/* ------------------------------- howto ------------------------------- */
.howto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.howto-grid article {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.028);
}
.howto-grid span { font-family: var(--mono); font-size: 0.7rem; color: var(--mint); letter-spacing: 0.1em; }
.howto-grid h3 { margin: 8px 0 4px; font-size: 0.92rem; }
.howto-grid p { margin: 0; font-size: 0.8rem; line-height: 1.5; color: var(--muted); }

/* ------------------------------- join -------------------------------- */
.join-layout { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: 18px; align-items: start; }
.code-entry { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.code-input {
  font-family: var(--mono);
  font-size: 1.7rem;
  letter-spacing: 0.4em;
  text-align: center;
  text-transform: uppercase;
  padding-left: 0.4em;
}
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted-2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.rooms-list { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow-y: auto; padding-right: 2px; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}
.room-item-main b { display: block; font-size: 0.88rem; }
.room-item-main span { display: block; font-size: 0.73rem; color: var(--muted); margin-top: 2px; }
.room-code-tag { font-family: var(--mono); color: var(--mint); letter-spacing: 0.14em; font-size: 0.82rem; }
.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 0.86rem; }

/* ------------------------------- lobby -------------------------------- */
.lobby-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin: 6px 0 18px;
}
.lobby-code-block { display: flex; flex-direction: column; gap: 2px; }
.lobby-code {
  width: fit-content;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: clamp(2.6rem, 9vw, 4.6rem);
  letter-spacing: 0.16em;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  text-shadow: 0 0 42px rgba(94, 234, 212, 0.25);
}
.lobby-code:hover { color: var(--mint); }
.lobby-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.lobby-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.lobby-players { display: flex; flex-direction: column; gap: 7px; }
.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}
.lobby-player.is-me { border-color: rgba(94, 234, 212, 0.28); background: rgba(94, 234, 212, 0.055); }
.lobby-player .who { flex: 1; min-width: 0; }
.lobby-player b { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player small { display: block; font-size: 0.7rem; color: var(--muted-2); }
.lobby-player .crown { color: var(--amber); font-size: 0.85rem; }
.lobby-player .bot-tag { font-size: 0.62rem; border: 1px solid var(--line); border-radius: 99px; padding: 1px 6px; color: var(--muted); }
.lobby-host-actions { margin-top: 12px; }
.lobby-options .segmented { margin-bottom: 2px; }
.lobby-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.lobby-actions .btn-wide { flex: 1; }

.avatar {
  --who: #5eead4;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.88rem;
  color: #06121c;
  background: var(--who);
  background: linear-gradient(145deg, color-mix(in srgb, var(--who) 88%, white), color-mix(in srgb, var(--who) 66%, #0b1020));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 6px 16px -8px var(--who);
  text-transform: uppercase;
}
.avatar.online::after {
  content: "";
  position: absolute;
}
.avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-wrap .online-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--panel-solid);
}
.avatar-wrap .online-dot.off { background: var(--muted-2); }

/* -------------------------------- jeu --------------------------------- */
.game-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 35, 60, 0.9), rgba(13, 21, 38, 0.92));
  box-shadow: var(--shadow-soft);
  margin-bottom: 14px;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.hud-right { justify-content: flex-end; }
.hud-turn { font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.hud-clock { font-family: var(--mono); font-size: 0.76rem; font-weight: 700; color: var(--muted-2); border-left: 1px solid var(--line); padding-left: 9px; }
.hud-clock.warn { color: var(--amber); }
.hud-clock.danger { color: var(--coral); }
.hud-timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 104px; }
.hud-timer { font-family: var(--mono); font-size: 1.34rem; font-weight: 800; letter-spacing: 0.04em; }
.hud-timer.warn { color: var(--amber); }
.hud-timer.danger { color: var(--coral); animation: pulse 1s infinite; }
.hud-timer-bar { width: 100%; height: 3px; border-radius: 99px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.hud-timer-bar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--mint), var(--violet)); border-radius: inherit; transition: width 0.2s linear; }
.hud-stat { font-size: 0.76rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.hud-errors { color: var(--coral); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr); gap: 16px; align-items: start; }
.board-column { min-width: 0; }
.grid-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 35, 60, 0.78), rgba(11, 18, 33, 0.9));
  box-shadow: var(--shadow);
}
.grid {
  --n: 4;
  display: grid;
  grid-template-columns: minmax(48px, 1.1fr) repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: minmax(38px, 0.85fr) repeat(var(--n), minmax(0, 1fr));
  gap: 5px;
  aspect-ratio: 1 / 1;
  width: 100%;
}

.grid-corner {
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--line);
  color: var(--muted-2);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  padding: 3px;
}

.grid-header {
  border-radius: 10px;
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.05;
  font-weight: 800;
  font-size: clamp(0.5rem, 1.5vw, 0.78rem);
  color: #e8fff9;
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.2), rgba(139, 92, 246, 0.16));
  border: 1px solid rgba(94, 234, 212, 0.18);
  overflow: hidden;
}
.grid-header.col { color: #f1e9ff; border-color: rgba(167, 139, 250, 0.2); }
.grid-header span { display: block; font-family: var(--mono); font-size: 0.56rem; opacity: 0.55; margin-top: 2px; letter-spacing: 0.08em; }

.grid-cell {
  position: relative;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: clamp(0.54rem, 1.5vw, 0.7rem);
  letter-spacing: 0.06em;
  cursor: default;
  transition: 0.16s ease;
  overflow: hidden;
  padding: 2px;
  min-width: 0;
}
.grid-cell .coord { opacity: 0.5; transition: 0.16s ease; }
.grid-cell:hover { background: rgba(255, 255, 255, 0.075); }
.grid-cell:disabled { cursor: default; }
.grid-cell.clickable {
  cursor: pointer;
  border-color: rgba(94, 234, 212, 0.32);
  background: rgba(94, 234, 212, 0.075);
  color: var(--mint);
}
.grid-cell.clickable .coord { opacity: 0.9; }
.grid-cell.clickable:hover { transform: scale(1.035); z-index: 3; box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.3), 0 10px 24px -12px rgba(94, 234, 212, 0.5); }
.grid-cell.my-card {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.14), rgba(251, 113, 133, 0.08));
  color: var(--amber);
}
.grid-cell.my-card::after {
  content: "★";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.62rem;
  opacity: 0.8;
}
.grid-cell.my-card.selectable { cursor: pointer; }
.grid-cell.my-card.selectable:hover { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.4); }
.grid-cell.selected {
  border-color: var(--amber);
  background: linear-gradient(145deg, rgba(251, 191, 36, 0.34), rgba(251, 113, 133, 0.18));
  color: #fff7dd;
  box-shadow: 0 0 0 2px var(--amber), 0 0 26px -6px rgba(251, 191, 36, 0.65);
  transform: scale(1.04);
  z-index: 2;
}
.grid-cell.found {
  cursor: default;
  color: #041b15;
  background: linear-gradient(145deg, #8cf5dd, #2dd4bf 55%, #14b8a6);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.grid-cell.found .coord { opacity: 0; }
.grid-cell.found .finder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grid-cell.found .check { font-size: clamp(0.72rem, 2.2vw, 1.05rem); line-height: 1; }
.grid-cell.reveal-target {
  animation: reveal-pop 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  box-shadow: 0 0 0 2px var(--amber), 0 0 30px -4px rgba(251, 191, 36, 0.8);
  z-index: 4;
}
.grid-cell.reveal-miss { animation: shake 0.5s ease both; border-color: var(--coral); }
.grid-cell.dim { opacity: 0.35; }
@keyframes reveal-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-3px); } 40%, 80% { transform: translateX(3px); } }

.players-bar { display: flex; gap: 7px; overflow-x: auto; padding: 10px 2px 2px; scrollbar-width: none; }
.players-bar::-webkit-scrollbar { display: none; }
.player-chip {
  --who: #5eead4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 7px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  flex: 0 0 auto;
  min-width: 118px;
  transition: 0.18s ease;
}
.player-chip.active {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.08);
  box-shadow: 0 0 22px -10px rgba(251, 191, 36, 0.7);
}
.player-chip.offline { opacity: 0.45; }
.player-chip .pc-main { min-width: 0; }
.player-chip b { display: block; font-size: 0.76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 88px; }
.player-chip small { display: block; font-size: 0.65rem; color: var(--muted-2); white-space: nowrap; }
.player-chip .pc-score { margin-left: auto; font-family: var(--mono); font-weight: 800; font-size: 0.82rem; color: var(--mint); }
.player-chip.active .pc-score { color: var(--amber); }
.player-chip .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 0.7rem; }
.player-chip .avatar-wrap .online-dot { width: 8px; height: 8px; }

.play-column { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.action-panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 35, 60, 0.9), rgba(13, 21, 38, 0.94));
  padding: clamp(14px, 2.5vw, 20px);
  box-shadow: var(--shadow-soft);
  min-height: 240px;
}
.action-kicker { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mint); font-weight: 800; margin-bottom: 6px; }
.action-title { font-size: clamp(1.15rem, 3vw, 1.55rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 8px; }
.action-copy { color: var(--muted); font-size: 0.86rem; line-height: 1.5; margin: 0 0 14px; }
.action-copy b { color: var(--text); }

.clue-display {
  margin: 4px 0 14px;
  padding: 16px;
  border-radius: 16px;
  text-align: center;
  background: radial-gradient(400px 160px at 50% 0%, rgba(251, 191, 36, 0.16), transparent 70%), rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(251, 191, 36, 0.3);
}
.clue-display .clue-word {
  display: block;
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff3c4;
  text-shadow: 0 0 34px rgba(251, 191, 36, 0.35);
  line-height: 1.05;
}
.clue-display .clue-giver { display: block; margin-top: 8px; font-size: 0.76rem; color: var(--muted); }
.clue-display.oral .clue-word { font-size: 1.2rem; letter-spacing: 0.02em; color: var(--mint); }

.card-picker { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 14px; }
.card-chip {
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: 0.15s ease;
  text-align: left;
}
.card-chip:hover { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.08); }
.card-chip.active { border-color: var(--amber); background: rgba(251, 191, 36, 0.16); color: #fff3c4; box-shadow: 0 0 0 1px var(--amber); }
.card-chip small { display: block; font-weight: 500; color: var(--muted); font-size: 0.66rem; margin-top: 1px; }

.clue-form { display: flex; flex-direction: column; gap: 8px; }
.clue-form .text-input { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; }
.clue-form-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.clue-form-actions .btn { min-height: 44px; }

.target-reminder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px dashed rgba(251, 191, 36, 0.35);
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.target-reminder b { color: var(--amber); font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.1em; }

.wait-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.wait-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--mint); animation: blink 1.2s infinite; }
.wait-dots i:nth-child(2) { animation-delay: 0.2s; }
.wait-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.guess-progress { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0; }
.guess-progress span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  font-size: 0.68rem;
  color: var(--muted);
}
.guess-progress span.ok { color: var(--mint); border-color: rgba(94, 234, 212, 0.28); }
.guess-progress span.no { color: var(--coral); border-color: rgba(251, 113, 133, 0.28); }

.reveal-box { padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); }
.reveal-box.ok { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.reveal-box.miss { border-color: rgba(251, 113, 133, 0.4); background: rgba(251, 113, 133, 0.08); }
.reveal-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 0.84rem; }
.reveal-line span:first-child { color: var(--muted); }
.reveal-line b { font-family: var(--mono); letter-spacing: 0.06em; }
.reveal-big { font-size: 1.3rem; font-weight: 900; letter-spacing: 0.02em; margin-bottom: 6px; }
.reveal-big.ok { color: var(--success); }
.reveal-big.miss { color: var(--coral); }

.reading-ring {
  width: 84px;
  height: 84px;
  margin: 6px auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--mint);
  background: radial-gradient(circle at 50% 50%, rgba(94, 234, 212, 0.16), transparent 65%);
  border: 2px solid rgba(94, 234, 212, 0.3);
  box-shadow: 0 0 50px -12px rgba(94, 234, 212, 0.5);
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.event-panel {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.028);
  padding: 12px 14px;
}
.event-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted-2); font-weight: 800; margin-bottom: 8px; }
.event-log { display: flex; flex-direction: column; gap: 5px; max-height: 150px; overflow-y: auto; font-size: 0.76rem; color: var(--muted); }
.event-log .ev { display: flex; gap: 7px; align-items: baseline; animation: screen-in 0.25s ease both; }
.event-log .ev::before { content: "›"; color: var(--muted-2); flex: 0 0 auto; }
.event-log .ev.found::before { content: "✓"; color: var(--success); }
.event-log .ev.wrong::before { content: "✕"; color: var(--coral); }
.event-log .ev.timeout::before { content: "◷"; color: var(--amber); }
.event-log .ev.end::before { content: "◆"; color: var(--violet); }

/* -------------------------------- fin --------------------------------- */
.end-hero { text-align: center; padding: clamp(14px, 4vw, 34px) 0 18px; }
.end-emoji { font-size: clamp(2.4rem, 8vw, 4rem); line-height: 1; margin-bottom: 8px; filter: drop-shadow(0 0 26px rgba(94, 234, 212, 0.35)); }
.end-title { margin: 8px 0 4px; font-size: clamp(2rem, 6vw, 3.6rem); letter-spacing: -0.045em; line-height: 1; }
.end-subtitle { margin: 6px auto 0; max-width: 620px; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.end-team { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.end-team .pill { font-size: 0.72rem; }

.end-layout { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; align-items: start; }
.ranking { display: flex; flex-direction: column; gap: 7px; }
.rank-row {
  --who: #5eead4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}
.rank-row.winner { border-color: rgba(251, 191, 36, 0.38); background: rgba(251, 191, 36, 0.07); }
.rank-pos { width: 26px; font-family: var(--mono); font-weight: 800; color: var(--muted-2); text-align: center; flex: 0 0 auto; }
.rank-row:nth-child(1) .rank-pos { color: var(--amber); }
.rank-main { flex: 1; min-width: 0; }
.rank-main b { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-main small { display: block; font-size: 0.68rem; color: var(--muted-2); }
.rank-score { font-family: var(--mono); font-weight: 800; color: var(--mint); font-size: 1rem; }
.rank-row.winner .rank-score { color: var(--amber); }

.end-grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-box { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.035); }
.stat-box b { display: block; font-family: var(--mono); font-size: 1.35rem; color: var(--text); }
.stat-box span { display: block; font-size: 0.7rem; color: var(--muted-2); margin-top: 1px; }
.end-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.end-actions .btn-wide { flex: 1; }

/* ------------------------------ modales ------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 5, 12, 0.72);
  backdrop-filter: blur(12px);
  animation: screen-in 0.2s ease both;
}
.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 760px);
  overflow-y: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #17223c, #0e1729);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9);
  padding: clamp(20px, 4vw, 30px);
}
.modal-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.modal h2 { margin: 0 0 8px; font-size: 1.3rem; letter-spacing: -0.02em; }
.modal h3 { margin: 18px 0 6px; font-size: 0.95rem; }
.modal p { color: var(--muted); line-height: 1.58; font-size: 0.88rem; margin: 6px 0; }
.modal ul { margin: 6px 0; padding-left: 18px; color: var(--muted); font-size: 0.86rem; line-height: 1.6; }
.modal .text-input { margin: 4px 0 10px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.modal-help { font-size: 0.76rem; color: var(--muted-2); margin-top: 8px; }
.server-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.76rem;
}
.server-box span { color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.64rem; font-weight: 700; }
.server-box b { flex: 1; min-width: 160px; font-family: var(--mono); font-weight: 600; color: var(--mint); word-break: break-all; }
.server-box .btn { flex: 0 0 auto; }
.modal code { font-family: var(--mono); font-size: 0.8em; color: var(--mint); background: rgba(94, 234, 212, 0.08); border-radius: 5px; padding: 1px 4px; }
.account-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 14px 0; }
.account-stats .stat-box b { font-size: 1.05rem; }
.history-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.history-item { padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 0.78rem; }
.history-item b { font-size: 0.8rem; }
.history-item span { color: var(--muted-2); }

/* -------------------------------- toast ------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 90;
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  max-width: min(92vw, 560px);
  padding: 12px 16px;
  border-radius: 13px;
  background: rgba(23, 34, 60, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.9);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
  transition: 0.24s ease;
  backdrop-filter: blur(12px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(52, 211, 153, 0.45); color: #c9ffe9; }
.toast.warn { border-color: rgba(251, 191, 36, 0.45); color: #fff0c2; }
.toast.error { border-color: rgba(244, 63, 94, 0.5); color: #ffd5dd; }

/* ------------------------------ responsive ---------------------------- */
@media (max-width: 920px) {
  .home-layout, .join-layout, .lobby-layout, .end-layout { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr; }
  .play-column { order: 2; }
  .board-column { order: 1; }
  .howto-grid { grid-template-columns: 1fr; }
  .panel-options { order: 2; }
}

@media (max-width: 620px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .brand-text { display: none; }
  .brand-version { display: none; }
  .pill { font-size: 0.62rem; padding: 5px 8px; }
  .hero { padding-top: 12px; }
  .hero-title { font-size: clamp(3rem, 18vw, 5.2rem); }
  .game-hud { grid-template-columns: auto 1fr auto; padding: 8px 10px; gap: 8px; }
  .hud-timer { font-size: 1.1rem; }
  .hud-turn { display: none; }
  .hud-stat { font-size: 0.68rem; }
  .grid { gap: 3px; grid-template-columns: minmax(40px, 1.05fr) repeat(var(--n), minmax(0, 1fr)); }
  .grid-header { font-size: 0.44rem; padding: 2px; border-radius: 7px; }
  .grid-header span { font-size: 0.48rem; }
  .grid-cell { border-radius: 7px; font-size: 0.52rem; }
  .grid-wrap { padding: 5px; border-radius: 16px; }
  .action-panel { min-height: 0; }
  .end-actions, .lobby-actions { flex-direction: column; align-items: stretch; }
  .modal-actions { grid-template-columns: 1fr; }
  .account-stats { grid-template-columns: 1fr 1fr; }
  .end-grid-stats { grid-template-columns: 1fr 1fr; }
  .action-row { grid-template-columns: 1fr; }
}

@media (min-width: 1280px) {
  .hero-title { font-size: 8.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
