:root {
  --panel: rgba(16,18,46,0.82);
  --border: rgba(130,140,255,0.25);
  --text: #e8eaff;
  --muted: #8f93c9;
  --accent: #7c5cff;
  --accent2: #ff3d7f;
  --bg: #07081a;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-user-select: none; user-select: none; }
canvas#board { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; touch-action: none; }
canvas#board.panning { cursor: grabbing; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
input { font: inherit; }

/* ---------- panneaux ---------- */
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}
.panel { position: fixed; padding: 12px 14px; z-index: 5; }
.top-left { top: 14px; left: 14px; min-width: 190px; }
.top-right { top: 14px; right: 14px; width: 240px; max-height: 60vh; display: flex; flex-direction: column; }
.bottom-left { bottom: 14px; left: 14px; padding: 8px 14px; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.toolbar { position: fixed; z-index: 5; display: flex; gap: 8px; }
.bottom-right { bottom: 14px; right: 14px; }

.brand { font-weight: 800; letter-spacing: .3px; font-size: 14px; color: var(--muted); }
.inf { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 900; }
.me-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 700; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 10px currentColor; flex: none; }
.score { font-size: 34px; font-weight: 900; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; transition: transform .15s; }
.score small { font-size: 13px; color: var(--muted); margin-left: 4px; font-weight: 600; }
.score.bump { transform: scale(1.08); }
.score.hurt { animation: hurt .5s; }
@keyframes hurt { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px); color: var(--accent2); } 60% { transform: translateX(6px); color: var(--accent2); } }
.me-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.me-stats b { color: var(--text); }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab { flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 700; font-size: 13px; }
.tab.active { background: rgba(127,127,127,0.18); color: var(--text); }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.plist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; font-size: 14px; cursor: pointer; }
.plist li:hover { background: rgba(127,127,127,0.14); }
.plist li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist li .s { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; font-size: 13px; }
.plist li .r { width: 18px; color: var(--muted); font-size: 12px; text-align: right; }
.plist li.me .n { font-weight: 800; }
.world-stats { font-size: 11px; color: var(--muted); margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }

.conn { font-size: 11px; }
.conn.ok { color: #4ade80; }
.conn.ko { color: #f43f5e; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- boutons ---------- */
.btn { border: 1px solid var(--border); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-radius: 12px; padding: 10px 16px; cursor: pointer; font-weight: 700; transition: transform .08s, background .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.btn:active { transform: translateY(1px); }
.btn.icon { width: 46px; height: 46px; padding: 0; font-size: 20px; display: grid; place-items: center; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: 0; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 6px; }
.btn.on { background: var(--accent2); color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.2), 0 0 24px var(--accent2); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(0,0,0,.25), rgba(0,0,0,.65)); }
.card { padding: 26px; width: min(440px, 100%); max-height: 92vh; overflow-y: auto; }
.login-card { animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.9) translateY(10px); opacity: 0; } }
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { margin: 0; font-size: 32px; font-weight: 900; letter-spacing: -.5px; }
.logo-bomb { font-size: 40px; animation: wobble 2.4s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) scale(1.06); } }
.subtitle { color: var(--muted); margin: 6px 0 18px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
input[type=text], input:not([type]) { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: rgba(127,127,127,0.12); color: var(--text); outline: none; font-size: 16px; -webkit-user-select: text; user-select: text; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; transition: transform .1s; padding: 0; }
.swatch:hover { transform: scale(1.12); }
.swatch.sel { border-color: var(--text); box-shadow: 0 0 14px currentColor; }
.swatch.picker { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch.picker input { position: absolute; inset: -10px; opacity: 0; cursor: pointer; width: 60px; height: 60px; }
.error { color: var(--accent2); min-height: 1.2em; margin: 10px 0 0; font-weight: 600; }
.rules { margin-top: 8px; color: var(--muted); font-size: 13px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules ul { padding-left: 18px; line-height: 1.6; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.theme-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid transparent; border-radius: 999px; padding: 5px 12px 5px 6px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 700; background: rgba(127,127,127,.14); }
.chip.sel { border-color: var(--accent); }
.chip i { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }

.card-head { display: flex; justify-content: space-between; align-items: center; }
.card-head h2 { margin: 0; }
.theme-card { width: min(620px, 100%); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.tcard { border-radius: 12px; overflow: hidden; cursor: pointer; border: 2px solid transparent; position: relative; transition: transform .12s; background: rgba(127,127,127,.12); }
.tcard:hover { transform: translateY(-2px); }
.tcard.sel { border-color: var(--accent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 50%, transparent); }
.tcard canvas { width: 100%; display: block; }
.tcard .tname { padding: 6px 8px; font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; }
.tcard .del { border: 0; background: none; cursor: pointer; opacity: .6; }
.tcard .del:hover { opacity: 1; }
.theme-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 10px; }
.theme-editor label { display: flex; align-items: center; gap: 8px; font-size: 13px; background: rgba(127,127,127,.1); padding: 6px 8px; border-radius: 10px; }
.theme-editor input[type=color] { width: 28px; height: 28px; border: 0; padding: 0; background: none; cursor: pointer; }
.theme-editor select { flex: 1; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.theme-editor select option { color: #000; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

/* ---------- fil d'événements ---------- */
.feed { position: fixed; left: 14px; bottom: 60px; z-index: 4; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; max-width: min(360px, 70vw); }
.toast { background: var(--panel); border: 1px solid var(--border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 7px 12px; border-radius: 10px; font-size: 13px; animation: slidein .3s ease-out; transition: opacity .6s, transform .6s; }
.toast b { font-weight: 800; }
.toast.out { opacity: 0; transform: translateX(-20px); }
.toast.boom { border-color: var(--accent2); }
.toast.done { border-color: var(--accent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent); }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } }

@media (max-width: 640px) {
  .top-right { width: 170px; max-height: 34vh; font-size: 12px; }
  .top-left { min-width: 0; padding: 10px; }
  .score { font-size: 24px; }
  .btn.icon { width: 42px; height: 42px; font-size: 18px; }
  .feed { bottom: 110px; }
  .bottom-right { flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
}
