﻿:root {
  --bg: #0d0b14;
  --panel: #1a1626;
  --panel-2: #241e35;
  --line: #3a3150;
  --text: #f3eefc;
  --muted: #a99fc0;
  --accent: #ff5d8f;
  --accent-2: #ffd166;
  --danger: #ff4d4d;
  --ok: #06d6a0;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
[hidden] { display: none !important; }
button { font: inherit; }
input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  width: 100%;
  user-select: text;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  transition: transform .08s, background .15s;
}
.btn:hover { background: #2f2745; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a0510; }
.btn.primary:hover { background: #ff7aa3; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.big { padding: 16px 22px; font-size: 18px; }
.btn.active { outline: 2px solid var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: flex; }

/* ---------- Accueil ---------- */
#screen-home, #screen-end {
  align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 20%, #2a1d3d 0, var(--bg) 60%);
}
.home-card, .end-card {
  width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  text-align: center;
}
.logo {
  font-family: 'Special Elite', monospace;
  font-size: 110px; line-height: 1; margin: 0;
  letter-spacing: -4px;
  color: var(--text);
  text-shadow: 0 0 30px rgba(255, 93, 143, .45);
}
.logo span { color: var(--accent); font-size: 56px; letter-spacing: 0; }
.tagline { color: var(--muted); margin: 0 0 10px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 14px; color: var(--muted); }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 800; }

/* ---------- Salon ---------- */
#screen-lobby { overflow-y: auto; justify-content: center; padding: 16px; }
.lobby { width: min(720px, 100%); padding-bottom: 40px; }
.lobby h2 { font-size: 16px; color: var(--muted); font-weight: 600; margin: 24px 0 10px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.code-box { text-align: center; }
.code-box span { display: block; font-size: 12px; color: var(--muted); }
.code-box strong { font-size: 36px; letter-spacing: 8px; font-family: 'Special Elite', monospace; color: var(--accent-2); }
.player-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.player-list li.empty { color: var(--muted); border-style: dashed; justify-content: center; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; color: #120c1c;
}
.player-list .crown { margin-left: auto; font-size: 14px; }
.player-list .off { opacity: .4; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice {
  text-align: left; cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; color: var(--text);
}
.choice b { display: block; font-size: 18px; margin-bottom: 4px; }
.choice small { color: var(--muted); font-size: 13px; line-height: 1.4; display: block; }
.choice.selected { border-color: var(--accent); background: #2a1830; }
.choice.locked { opacity: .45; cursor: not-allowed; }
.choice .soon { display: inline-block; margin-top: 8px; font-size: 11px; background: var(--panel-2); padding: 3px 8px; border-radius: 6px; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice-row .choice { flex: 1 1 150px; text-align: center; }
.choice-row .choice b { font-size: 16px; }
.note { color: var(--muted); font-size: 14px; text-align: center; }
#btn-start { width: 100%; margin-top: 10px; }

/* ---------- Jeu ---------- */
#screen-game { flex-direction: column; background: #07060b; }
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.hud-room { font-size: 14px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.hud-room b { color: var(--text); }
.timer {
  font-family: 'Special Elite', monospace; font-size: 32px; letter-spacing: 2px;
  padding: 0 12px; color: var(--text);
}
.timer.warn { color: var(--accent-2); }
.timer.danger { color: var(--danger); animation: pulse 1s infinite; }
.timer.hit { animation: shake .4s; }
#btn-hint { flex: none; }

.stage-wrap { flex: 1; display: grid; place-items: center; min-height: 0; padding: 6px; }
.stage {
  position: relative;
  width: min(100%, calc((100dvh - 150px) * 10 / 7));
  aspect-ratio: 10 / 7;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0,0,0,.6);
  touch-action: none;
  container-type: inline-size;
}
.stage.ping-mode { cursor: crosshair; }
.scene, .layer { position: absolute; inset: 0; }
.scene svg { width: 100%; height: 100%; display: block; }
.no-pointer { pointer-events: none; }
#sprites { pointer-events: none; }
.sprite {
  position: absolute; transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.7));
  animation: float 3s ease-in-out infinite;
}

.hotspot {
  position: absolute; cursor: pointer; border-radius: 10px;
  border: 2px solid transparent; background: transparent;
  transition: border-color .15s, background .15s;
}
.hotspot:hover, .hotspot:focus-visible { border-color: rgba(255, 209, 102, .8); background: rgba(255, 209, 102, .08); outline: none; }
.hotspot .tag {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -4px);
  white-space: nowrap; font-size: 12px; font-weight: 600;
  background: rgba(13, 11, 20, .85); color: var(--text);
  padding: 3px 8px; border-radius: 6px; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.hotspot:hover .tag, .stage.show-tags .hotspot .tag { opacity: 1; }
.hotspot.lock { animation: glow 2.4s ease-in-out infinite; }
.hotspot .watchers { position: absolute; top: -10px; right: -10px; display: flex; gap: 2px; }
.hotspot .watchers span {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #120c1c; box-shadow: 0 0 0 2px #07060b;
}
.hotspot .mine-dot {
  position: absolute; top: 4px; left: 4px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2);
}

.cursor {
  position: absolute; transform: translate(-50%, -50%);
  transition: left .09s linear, top .09s linear;
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.cursor .dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #120c1c;
  box-shadow: 0 0 0 3px rgba(0,0,0,.5), 0 0 14px currentColor;
}
.cursor .name { font-size: 11px; font-weight: 600; margin-top: 3px; background: rgba(0,0,0,.65); padding: 1px 6px; border-radius: 5px; }
.cursor .bubble {
  position: absolute; bottom: 120%; white-space: nowrap;
  background: #fff; color: #120c1c; font-weight: 600; font-size: 13px;
  padding: 5px 10px; border-radius: 12px; animation: pop .2s;
}
.ping {
  position: absolute; width: 70px; height: 70px; transform: translate(-50%, -50%);
  border-radius: 50%; border: 4px solid currentColor; animation: ping 1.6s ease-out forwards;
}

.dock {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.team { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.team li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.team .avatar { width: 28px; height: 28px; font-size: 13px; }
.team .off { opacity: .35; }
.quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.quick-list { display: flex; gap: 6px; flex-wrap: wrap; }

.hint-banner {
  position: absolute; left: 50%; top: 70px; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  background: #2a2140; border: 1px solid var(--accent-2); color: var(--text);
  padding: 10px 14px; border-radius: 12px; font-size: 14px; z-index: 5;
}
.hint-banner b { color: var(--accent-2); }

/* ---------- Gros plan ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5, 3, 10, .78); display: grid; place-items: center; padding: 16px;
  animation: fade .15s;
}
.modal-card {
  position: relative; width: min(460px, 100%); max-height: 90dvh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  animation: zoom .18s;
}
.modal-card h3 { margin: 0 0 14px; font-size: 20px; }
.modal-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 16px;
}
.paper {
  background: #efe4cc; color: #2d2216; border-radius: 6px; padding: 16px 18px;
  font-family: 'Special Elite', monospace; font-size: 17px; line-height: 1.5;
  box-shadow: inset 0 0 40px rgba(120, 80, 30, .35);
  user-select: text;
}
.paper p { margin: 0 0 8px; }
.paper p:last-child { margin: 0; }
.paper ul { margin: 6px 0 0; padding-left: 18px; }
.paper table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.paper td { padding: 4px 6px; border-bottom: 1px dashed rgba(45, 34, 22, .3); }
.paper .big { font-size: 24px; }
.paper .hand { font-style: italic; }
.paper .ink { text-shadow: 0 0 1px rgba(0,0,0,.4); }
.paper.blackboard { background: #1f3a2c; color: #eef5ee; box-shadow: inset 0 0 40px rgba(0,0,0,.5); }
.paper.blackboard .ink { background: rgba(255,255,255,.88); padding: 0 6px; border-radius: 4px; text-shadow: none; }
.paper.blackboard .chalk { font-size: 20px; text-align: center; line-height: 1.8; }
.paper .code-word { font-size: 34px; letter-spacing: 8px; text-align: center; font-weight: bold; }
.paper .alphabet { font-size: 20px; letter-spacing: 2px; word-spacing: 4px; line-height: 1.6; }
.paper .mirror { transform: scaleX(-1); font-size: 19px; }
.paper .clock {
  width: 90px; height: 90px; margin: 0 auto 10px; border-radius: 50%;
  border: 4px solid #2d2216; display: grid; place-items: center; font-size: 34px;
}
.locked-msg {
  text-align: center; padding: 24px 10px; color: var(--muted);
  border: 2px dashed var(--line); border-radius: 12px;
}
.locked-msg .avatar { margin: 0 auto 10px; width: 46px; height: 46px; font-size: 20px; }
.locked-msg b { color: var(--text); }

.lock-ui { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.lock-input {
  font-family: 'Special Elite', monospace; font-size: 30px; text-align: center; letter-spacing: 10px;
  text-transform: uppercase;
}
.lock-ui.wrong { animation: shake .4s; }
.candles { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.candle {
  width: 56px; height: 96px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--panel-2); cursor: pointer; position: relative; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px; font-size: 11px; color: var(--muted);
}
.candle::before {
  content: ''; position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  width: 20px; height: 46px; border-radius: 4px; background: var(--c);
}
.candle.lit::after {
  content: ''; position: absolute; left: 50%; top: 4px; transform: translateX(-50%);
  width: 12px; height: 18px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: #ffcf4d; box-shadow: 0 0 14px #ffae00; animation: flicker .3s infinite alternate;
}
.seq-display { display: flex; justify-content: center; gap: 8px; min-height: 26px; }
.seq-display span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); }

/* Serrures à touches (manette, attaques) */
.keypad { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.keybtn {
  min-width: 58px; height: 58px; padding: 0 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid #3cf2ff; background: #10162e; color: #e8fbff;
  font-size: 26px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 0 #0b7a88; transition: transform .05s, box-shadow .05s;
}
.keybtn small { font-size: 11px; font-weight: 600; color: var(--muted); }
.keybtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0b7a88; }
.seq-display .chip {
  min-width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  background: #1d2547; border: 1px solid #3cf2ff; font-size: 18px; color: #e8fbff;
}
.seq-display .chip.empty { border-style: dashed; color: var(--muted); background: transparent; }

/* Papiers version écran (GLITCH) */
.paper.monitor {
  background: #071018; color: #7dffb0; font-family: 'Courier New', monospace; font-size: 17px;
  border: 1px solid #1e4d3a; box-shadow: inset 0 0 30px rgba(57, 255, 136, .12);
  text-shadow: 0 0 6px rgba(57, 255, 136, .5);
}
.paper.monitor .big { font-size: 20px; }
.paper.monitor td { border-bottom-color: rgba(125, 255, 176, .2); }
.paper .keys { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.paper .key {
  width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center;
  border: 2px solid #3cf2ff; color: #e8fbff; font-size: 24px; font-weight: bold;
}
.paper .bits { font-size: 24px; letter-spacing: 4px; color: #ffd166; }
.paper .cube { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.paper .bitrow { display: inline-flex; gap: 6px; }
.paper .bit { display: flex; flex-direction: column; align-items: center; width: 34px; }
.paper .bit i { font-style: normal; font-size: 26px; line-height: 1; color: #2a5a44; text-shadow: none; }
.paper .bit.on i { color: #ffd166; text-shadow: 0 0 8px rgba(255, 209, 102, .6); }
.paper .bit small { font-size: 13px; color: #7dffb0; }
.paper .slots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.paper .slots span {
  width: 30px; height: 40px; display: grid; place-items: center; font-size: 24px; font-weight: bold;
  border-bottom: 3px solid #7dffb0;
}
.paper .slots span.empty { color: transparent; text-shadow: none; border-bottom-color: #2a5a44; }
.paper.postit { background: #ffe66d; color: #3a3000; transform: rotate(-2deg); font-family: 'Special Elite', monospace; }
.paper .symtable td { font-size: 22px; }
.paper .symtable .sym { width: 50px; text-align: center; font-size: 28px; }

/* Thème GLITCH */
body[data-universe="glitch"] #screen-game { background: #05030d; }
body[data-universe="glitch"] .hud, body[data-universe="glitch"] .dock { background: #0e0a1f; border-color: #2b1f55; }
body[data-universe="glitch"] .timer { color: #3cf2ff; text-shadow: 0 0 10px rgba(60, 242, 255, .6); }
body[data-universe="glitch"] .timer.danger { color: #ff3c8e; }
body[data-universe="glitch"] .transition h2 { color: #3cf2ff; text-shadow: 3px 0 #ff3c8e, -3px 0 #39ff88; animation: glitchtxt 1.2s infinite steps(1); }
body[data-universe="glitch"] .hotspot:hover { border-color: #3cf2ff; background: rgba(60, 242, 255, .08); }
@keyframes glitchtxt { 0%, 88% { transform: none; } 90% { transform: translate(3px, -2px) skewX(8deg); } 94% { transform: translate(-3px, 1px); } }

.keybtn.toggle { min-width: 84px; height: 76px; }
.keybtn.toggle.on { background: #3a2f0b; border-color: #ffd166; box-shadow: 0 4px 0 #8a6a12, 0 0 14px rgba(255, 209, 102, .5); }

/* Cartels et documents de musée (LE CASSE) */
.paper.card {
  background: #fbfaf6; color: #1d1d24; font-family: 'Rubik', system-ui, sans-serif; font-size: 16px;
  box-shadow: inset 0 0 0 1px #d8d4c6;
}
.paper.card .big { font-size: 22px; font-weight: 800; }
.paper.card small { color: #6b6a72; }
.paper .num { font-weight: bold; color: #8a6a12; }

/* Thème LE CASSE */
body[data-universe="casse"] #screen-game { background: #04070d; }
body[data-universe="casse"] .hud, body[data-universe="casse"] .dock { background: #0b1220; border-color: #1f2c44; }
body[data-universe="casse"] .timer { color: #ffd166; }
body[data-universe="casse"] .timer.danger { color: #ff4d4d; }
body[data-universe="casse"] .transition h2 { color: #ffd166; letter-spacing: 2px; }
body[data-universe="casse"] .hotspot:hover { border-color: #ffd166; }

/* ---------- Transition & toasts ---------- */
.transition {
  position: fixed; inset: 0; z-index: 30; background: #050308;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px;
  animation: fade .3s;
}
.transition p { color: var(--muted); max-width: 520px; }
.transition h2 { font-family: 'Special Elite', monospace; font-size: 44px; margin: 6px 0; }
#transition-step { color: var(--accent-2); font-weight: 600; letter-spacing: 3px; text-transform: uppercase; font-size: 13px; }

.toasts { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 14px; animation: pop .2s; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

.end-card h1 { font-family: 'Special Elite', monospace; font-size: 48px; margin: 0; }
.end-card .score { font-size: 64px; font-family: 'Special Elite', monospace; color: var(--accent-2); display: block; }

.flash-red { animation: flashred .4s; }

@keyframes pulse { 50% { opacity: .55; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes glow { 50% { box-shadow: 0 0 22px rgba(255, 209, 102, .35); } }
@keyframes float { 50% { transform: translate(-50%, calc(-50% - 6px)); } }
@keyframes ping { from { opacity: 1; transform: translate(-50%, -50%) scale(.3); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes zoom { from { transform: scale(.92); opacity: 0; } }
@keyframes flicker { to { transform: translateX(-50%) scale(1.1, .92); } }
@keyframes flashred { 0% { box-shadow: inset 0 0 0 999px rgba(255, 0, 0, .25); } }

.stage-wrap { position: relative; }
.rotate-hint { display: none; position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 14px; margin: 0; }
#btn-quick { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate-hint { display: block; }
}
@media (max-width: 900px), (max-height: 500px) {
  #btn-quick { display: inline-block; }
  .dock { position: relative; flex-wrap: nowrap; }
  .quick-list {
    display: none; position: absolute; right: 12px; bottom: calc(100% + 6px); z-index: 6;
    flex-direction: column; align-items: stretch;
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  }
  .quick-list.open { display: flex; }
}
@media (max-height: 500px) {
  .hud, .dock { padding-top: 4px; padding-bottom: 4px; }
  .timer { font-size: 24px; }
  .stage { width: min(100%, calc((100dvh - 100px) * 10 / 7)); }
}

@media (max-width: 560px) {
  .logo { font-size: 84px; }
  .timer { font-size: 26px; }
  .hud-room { font-size: 12px; }
  .stage { width: min(100%, calc((100dvh - 190px) * 10 / 7)); }
  .code-box strong { font-size: 28px; }
}
