/* ==========================================================
   DécoDawn — feuille de style commune
   ========================================================== */
:root {
  --bg: #07081a;
  --bg2: #0e1030;
  --panel: #12143a;
  --panel2: #1a1d4d;
  --line: #2c2f72;
  --ink: #e8e9ff;
  --muted: #8c8fc8;
  --amber: #ffb627;
  --amber-hot: #fff1b8;
  --cyan: #3cf2ff;
  --pink: #ff3fa4;
  --lime: #8cff5a;
  --red: #ff4d5e;
  --violet: #9b6bff;
  --pixel: 'Press Start 2P', ui-monospace, monospace;
  --mono: 'VT323', ui-monospace, 'Consolas', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% -20%, rgba(155,107,255,.25), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(60,242,255,.10), transparent 50%),
    linear-gradient(var(--bg), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 22px;
  line-height: 1.25;
  min-height: 100vh;
  overflow-x: hidden;
}
/* grille de sol rétro */
body::before {
  content: '';
  position: fixed; inset: auto 0 0 0; height: 38vh;
  background:
    linear-gradient(transparent 0, rgba(255,63,164,.18) 1px, transparent 2px) 0 0 / 100% 36px,
    linear-gradient(90deg, transparent 0, rgba(255,63,164,.18) 1px, transparent 2px) 50% 0 / 60px 100%;
  transform: perspective(300px) rotateX(55deg);
  transform-origin: bottom;
  mask-image: linear-gradient(transparent, #000 70%);
  -webkit-mask-image: linear-gradient(transparent, #000 70%);
  pointer-events: none; z-index: -1;
}
/* scanlines CRT */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
  pointer-events: none; z-index: 1000;
  mix-blend-mode: multiply;
}

a { color: var(--cyan); }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--pixel); font-size: 10px;
  display: inline-block; padding: 4px 6px 3px;
  background: var(--panel2); border: 2px solid var(--line);
  border-bottom-width: 4px; border-radius: 4px; color: var(--ink);
  vertical-align: middle; line-height: 1;
}

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: rgba(7,8,26,.85);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--line);
}
.logo {
  font-family: var(--pixel); font-size: 14px; text-decoration: none;
  color: var(--amber); text-shadow: 0 0 8px rgba(255,182,39,.7);
  white-space: nowrap; display: flex; align-items: center; gap: 10px;
}
.logo .mini-lamp {
  width: 12px; height: 12px; border-radius: 50%;
  background: #3a2a10; box-shadow: inset 0 0 0 2px #5a4420;
  transition: background .05s, box-shadow .05s;
}
.logo .mini-lamp.on { background: var(--amber-hot); box-shadow: 0 0 10px 3px var(--amber); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  font-family: var(--pixel); font-size: 10px; text-decoration: none;
  color: var(--muted); padding: 8px 10px; border: 2px solid transparent;
  border-radius: 4px;
}
.nav a:hover { color: var(--ink); border-color: var(--line); }
.nav a.active { color: var(--bg); background: var(--cyan); box-shadow: 0 0 12px rgba(60,242,255,.5); }
.icon-btn {
  background: var(--panel); border: 2px solid var(--line); border-radius: 6px;
  width: 38px; height: 38px; cursor: pointer; font-size: 18px; line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--cyan); }

/* ---------- Mise en page ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.page-title {
  font-family: var(--pixel); font-size: 22px; margin: 6px 0 4px;
  color: var(--ink); text-shadow: 3px 3px 0 var(--pink);
}
.page-sub { color: var(--muted); margin: 0 0 20px; }
.panel {
  background: linear-gradient(180deg, var(--panel), #0d0f30);
  border: 2px solid var(--line); border-radius: 10px;
  box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 12px 30px rgba(0,0,0,.4);
  padding: 18px;
}
.panel h2 {
  font-family: var(--pixel); font-size: 12px; color: var(--cyan);
  margin: 0 0 14px; letter-spacing: 1px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Boutons pixel ---------- */
.btn {
  font-family: var(--pixel); font-size: 11px; cursor: pointer;
  padding: 12px 16px 10px; border-radius: 6px;
  background: var(--panel2); color: var(--ink);
  border: 2px solid var(--line); border-bottom-width: 5px;
  transition: transform .05s, filter .1s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { filter: brightness(1.25); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; margin-bottom: 3px; }
.btn.primary { background: var(--amber); color: #2a1600; border-color: #a86a00; }
.btn.cyan { background: var(--cyan); color: #00262a; border-color: #0a8a95; }
.btn.pink { background: var(--pink); color: #2a0016; border-color: #9c1a5f; }
.btn.toggle[aria-pressed="true"] { background: var(--lime); color: #0d2600; border-color: #4a9a1f; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- La loupiotte ---------- */
.lamp {
  --size: 120px;
  width: var(--size); height: var(--size); position: relative;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #3b3a46 0 58%, #22212b 60% 66%, #6b6a78 67% 70%, #2a2934 71%);
  box-shadow: 0 6px 0 #0005, inset 0 -4px 8px #0008;
  flex: none;
}
.lamp::before { /* vis du boîtier */
  content: ''; position: absolute; inset: 6%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 4%, #9a99a8 0 3%, transparent 3.5%),
    radial-gradient(circle at 50% 96%, #9a99a8 0 3%, transparent 3.5%),
    radial-gradient(circle at 4% 50%, #9a99a8 0 3%, transparent 3.5%),
    radial-gradient(circle at 96% 50%, #9a99a8 0 3%, transparent 3.5%);
}
.lamp .bulb {
  position: absolute; inset: 20%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a4a18, #3a2408 60%, #1e1204);
  box-shadow: inset 0 0 12px #000;
  transition: background .04s, box-shadow .04s;
}
.lamp .bulb::after { /* reflet */
  content: ''; position: absolute; left: 22%; top: 16%; width: 26%; height: 18%;
  border-radius: 50%; background: rgba(255,255,255,.22); transform: rotate(-30deg);
}
.lamp.on .bulb {
  background: radial-gradient(circle at 40% 35%, #fff 0, var(--amber-hot) 25%, var(--amber) 60%, #d07800);
  box-shadow:
    0 0 calc(var(--size) * .25) calc(var(--size) * .08) rgba(255,182,39,.85),
    0 0 calc(var(--size) * .8) calc(var(--size) * .25) rgba(255,140,0,.35),
    inset 0 0 10px #fff8;
}
.lamp.on { box-shadow: 0 6px 0 #0005, 0 0 80px 10px rgba(255,170,30,.25); }
.lamp.err .bulb { background: radial-gradient(circle at 40% 35%, #fff, #ff8a95 30%, var(--red)); box-shadow: 0 0 40px 10px rgba(255,77,94,.7); }
.lamp.ok .bulb { background: radial-gradient(circle at 40% 35%, #fff, #c8ffad 30%, var(--lime)); box-shadow: 0 0 40px 10px rgba(140,255,90,.7); }

/* ---------- Symboles morse ---------- */
.code { display: inline-flex; gap: .35em; align-items: center; }
.sym { display: inline-block; background: var(--ink); border-radius: 999px; }
.sym.dot { width: .5em; height: .5em; }
.sym.dash { width: 1.6em; height: .5em; }
.code.big { font-size: 64px; gap: 22px; min-height: 64px; }
.code.big .sym { background: #2c2f72; box-shadow: inset 0 0 0 2px #3e42a0; transition: background .06s, box-shadow .06s, transform .1s; }
.code.big .sym.lit { background: var(--amber); box-shadow: 0 0 18px 4px rgba(255,182,39,.8); transform: scale(1.12); }
.code.big .sym.done { background: var(--amber); opacity: .85; }
.code.big .sym.hidden { opacity: 0; }

/* ---------- Coeurs ---------- */
.hearts { display: inline-flex; gap: 6px; }
.heart { width: 26px; height: 24px; position: relative; }
.heart svg { width: 100%; height: 100%; display: block; }
.heart.lost svg { opacity: .2; filter: grayscale(1); }
.heart.pop { animation: heartPop .5s ease; }
@keyframes heartPop { 0%{transform:scale(1)} 40%{transform:scale(1.6) rotate(-10deg)} 100%{transform:scale(1)} }

/* ---------- HUD ---------- */
.hud {
  display: flex; gap: 22px; align-items: center; flex-wrap: wrap;
  font-family: var(--pixel); font-size: 12px;
  padding: 12px 16px; background: #0009; border: 2px solid var(--line); border-radius: 8px;
}
.hud .lbl { color: var(--muted); font-size: 9px; display: block; margin-bottom: 4px; }
.hud .val { color: var(--amber); }
.hud .val.cyan { color: var(--cyan); }
.hud .val.pink { color: var(--pink); }

/* ---------- Overlay / modale ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(4,4,16,.82); backdrop-filter: blur(3px);
  display: none; place-items: center; padding: 20px;
}
.overlay.show { display: grid; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0 } }
.modal {
  width: min(560px, 100%); max-height: 90vh; overflow: auto;
  background: var(--panel); border: 3px solid var(--cyan); border-radius: 12px;
  box-shadow: 0 0 0 4px #000, 0 0 40px rgba(60,242,255,.3);
  padding: 24px;
}
.modal h2 { font-family: var(--pixel); font-size: 16px; margin: 0 0 18px; color: var(--cyan); }
.modal.pink { border-color: var(--pink); box-shadow: 0 0 0 4px #000, 0 0 40px rgba(255,63,164,.35); }
.modal.pink h2 { color: var(--pink); }

.field { margin: 0 0 16px; }
.field label { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 4px; }
.field label b { color: var(--amber); font-weight: normal; }
input[type=range] { width: 100%; accent-color: var(--amber); }
input[type=text] {
  font: inherit; font-size: 24px; width: 100%; color: var(--ink);
  background: #05061a; border: 2px solid var(--line); border-radius: 6px; padding: 8px 12px;
  text-transform: uppercase;
}
input[type=text]:focus { outline: none; border-color: var(--cyan); }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--lime); }

/* ---------- Écrans de départ ---------- */
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.shake { animation: shake .35s; }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}
.toast {
  position: fixed; left: 50%; top: 90px; transform: translateX(-50%);
  font-family: var(--pixel); font-size: 14px; padding: 12px 18px;
  background: var(--panel); border: 2px solid var(--amber); border-radius: 8px;
  z-index: 300; pointer-events: none; animation: toast 1.6s forwards;
}
@keyframes toast { 0%{opacity:0; transform:translate(-50%,-10px)} 12%,75%{opacity:1; transform:translate(-50%,0)} 100%{opacity:0} }

/* ---------- Clavier visuel AZERTY ---------- */
.kbd { display: flex; flex-direction: column; gap: 6px; align-items: center; user-select: none; }
.kbd .krow { display: flex; gap: 6px; }
.kbd .key {
  width: 46px; height: 50px; border-radius: 6px; cursor: pointer;
  font-family: var(--pixel); font-size: 13px;
  background: var(--panel2); border: 2px solid var(--line); border-bottom-width: 5px;
  display: grid; place-items: center; transition: background .15s, transform .05s;
  position: relative;
}
.kbd .key small { position: absolute; bottom: 2px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.kbd .key:hover { border-color: var(--cyan); }
.kbd .key.off { opacity: .28; }
.kbd .key.press { transform: translateY(3px); border-bottom-width: 2px; }
.kbd .key.good { background: var(--lime); color: #0d2600; border-color: #4a9a1f; }
.kbd .key.bad { background: var(--red); color: #2a0006; border-color: #9a1f2a; }

/* ---------- Jauge du manipulateur ---------- */
.gauge {
  position: relative; height: 26px; border-radius: 6px; overflow: hidden;
  background: #05061a; border: 2px solid var(--line);
}
.gauge-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.gauge-fill.dash { background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.gauge-mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--pink); left: 50%; }
.gauge-l, .gauge-r { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--pixel); font-size: 8px; color: #fff; mix-blend-mode: difference; }
.gauge-l { left: 8px; } .gauge-r { right: 8px; }

footer.foot { text-align: center; color: var(--muted); font-size: 18px; padding: 30px 0 10px; }

@media (max-width: 720px) {
  body { font-size: 19px; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .nav { margin-left: 0; width: 100%; order: 3; }
  .nav a { font-size: 8px; padding: 6px; }
  .page-title { font-size: 16px; }
  .code.big { font-size: 40px; gap: 14px; }
  .kbd .key { width: 28px; height: 40px; font-size: 10px; }
  .kbd .krow { gap: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; }
}

/* ---------- Compte NintenDawn et classements ---------- */
.acct { display: flex; align-items: center; gap: 10px; }
.acct .who { font-family: var(--pixel); font-size: 10px; color: var(--lime); white-space: nowrap; }
.link { background: none; border: 0; padding: 0; cursor: pointer; font-family: var(--pixel); font-size: 9px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--ink); }
.btn.sm { font-size: 9px; padding: 8px 10px 6px; border-bottom-width: 4px; }
.rank-line { margin: -4px 0 16px; padding: 10px 12px; border: 2px dashed var(--line); border-radius: 8px; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rank-line b { font-family: var(--pixel); font-size: 13px; color: var(--lime); font-weight: normal; }
.board-tabs { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.board-tabs button { font-family: var(--pixel); font-size: 10px; cursor: pointer; color: var(--muted); background: none; padding: 8px 10px; border: 2px solid var(--line); border-radius: 4px; }
.board-tabs button[aria-selected="true"] { color: var(--bg); background: var(--amber); border-color: var(--amber); box-shadow: 0 0 12px rgba(255,182,39,.5); }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ranking li { display: grid; grid-template-columns: 34px 28px 1fr auto; gap: 10px; align-items: center; padding: 5px 10px; border-radius: 6px; background: #ffffff08; font-size: 22px; }
.ranking li:nth-child(-n+3) .rk { color: var(--amber); }
.ranking li.me { background: color-mix(in srgb, var(--cyan) 18%, transparent); outline: 2px solid var(--cyan); }
.ranking li.gap { display: block; text-align: center; background: none; color: var(--muted); padding: 0; }
.ranking .rk { font-family: var(--pixel); font-size: 11px; color: var(--muted); }
.ranking img, .ranking i { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #ffffff14; display: block; }
.ranking .ps { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking b { font-family: var(--pixel); font-size: 11px; color: var(--amber); font-weight: normal; }
.board-empty { color: var(--muted); margin: 10px 0 0; font-size: 20px; }
@media (max-width: 760px) { .acct .who { display: none; } }
