@font-face { font-family: "Young Serif"; src: url(fonts/young-serif-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url(fonts/hanken-grotesk-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url(fonts/hanken-grotesk-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url(fonts/hanken-grotesk-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --bg: #0e0d18;
  --panel: #15141f;
  --track: #221f33;
  --line: #24223a;
  --text: #ebe8f7;
  --muted: #9a96b8;
  --faint: #5f5b80;

  /* La jauge : un seul dégradé, fixe sur toute la largeur, que le remplissage dévoile */
  --heat: linear-gradient(90deg, #464aaa 0%, #685cde 35%, #9668f0 60%, #cc68e2 80%, #f062b4 93%, #ff5c95 100%);
  --ice: #8ecbff;
  --cold: #6c80c4;
  --cool: #9a86f2;
  --warm: #c879ee;
  --fire: #ee66c4;
  --max: #ff5c95;
  --win: #7ce8d6;

  --serif: "Young Serif", Georgia, serif;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--sans);
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; }

/* ---------- En-tête ---------- */
.top {
  width: 100%; max-width: 1320px; margin: 0 auto;
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 28px 28px 22px;
}
.logo { margin: 0; font: 400 30px/1 var(--serif); letter-spacing: -0.01em; }
.logo span { color: var(--faint); }
.top-right { display: flex; align-items: baseline; gap: 26px; }
.level { margin: 0; color: var(--muted); font-size: 15px; }
.level b { font: 400 26px/1 var(--serif); color: var(--text); margin-left: 4px; display: inline-block; }
.level b.bump { animation: bump .7s ease-out; }
@keyframes bump { 30% { transform: translateY(-4px); color: var(--win); } }
.links { display: flex; gap: 16px; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-size: 15px; }
.link:hover { color: var(--text); }
.link.quiet { color: var(--faint); font-size: 14px; }
.link.quiet:hover { color: var(--muted); }
.link.armed { color: var(--fire); }

/* Compte */
.account { position: relative; display: flex; align-items: center; }
.discord {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: 8px; background: #5865f2; color: #fff; text-decoration: none; font-size: 14px; font-weight: 600;
}
.discord:hover { background: #6a75f5; }
.discord svg { width: 18px; height: 18px; }
.acct { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--text); font-size: 15px; }
.acct img { width: 26px; height: 26px; border-radius: 50%; background: var(--track); }
img.av-missing { visibility: hidden; }
.acct:hover span { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}

/* ---------- Mise en page ---------- */
.layout {
  width: 100%; max-width: 1320px; margin: 0 auto; flex: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 48px;
  padding: 4px 28px 40px; align-items: start;
}
.pane-map { position: sticky; top: 24px; }
.tabs { display: none; }

/* ---------- Saisie ---------- */
.guess { display: flex; gap: 10px; }
#input {
  flex: 1; min-width: 0; height: 54px; padding: 0 18px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: 500 19px var(--sans); outline: none;
  transition: border-color .15s;
}
#input::placeholder { color: var(--faint); font-weight: 400; }
#input:focus { border-color: #4d4878; }
#input.shake { animation: shake .3s; }
@keyframes shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

.btn {
  height: 54px; padding: 0 22px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px;
}
.btn:hover { border-color: #3d3a5c; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #fff; }
kbd { font: 12px var(--mono); opacity: .55; }

.meta { margin: 12px 2px 0; font-size: 14px; color: var(--muted); }
.meta b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.msg { min-height: 22px; margin: 4px 2px 0; font-size: 14px; color: var(--muted); }
.msg.err { color: #ff8fb0; }

/* ---------- Relevé du dernier essai ---------- */
.readout { margin: 22px 0 34px; min-height: 128px; }
.ro-intro { color: var(--muted); max-width: 46ch; margin: 18px 0 0; }
.ro-top { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.ro-word { font: 400 40px/1.1 var(--serif); letter-spacing: -0.01em; word-break: break-word; margin-right: auto; }
.ro-temp { font: 500 30px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--text); transition: color .3s; }
.ro-temp small { font-size: 16px; color: var(--muted); margin-left: 2px; }
.ro-emoji { font-size: 30px; line-height: 1; width: 36px; text-align: center; display: inline-block; }
.ro-emoji.pop { animation: pop .35s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.ro-gauge { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.ro-gauge .heat { height: 12px; border-radius: 6px; }
.ro-rank small { font: 500 15px var(--sans); color: var(--faint); }
.ro-temp.pending { color: var(--faint); }
.ro-rank { font: 500 15px var(--mono); color: var(--muted); width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.ro-cold { margin-top: 16px; color: var(--faint); font-size: 14px; }
.ro-sub { color: var(--muted); margin: 10px 0 0; }
.ro-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.readout.done .ro-word { color: var(--win); }
.readout.lost .ro-word { color: var(--text); }

/* La jauge en dégradé */
.heat {
  --p: 0;
  position: relative; flex: 1; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--heat);
}
.heat::after {
  content: ""; position: absolute; top: 0; right: 0; bottom: 0;
  width: calc((1 - var(--p)) * 100%);
  background: var(--track);
}

/* ---------- Liste ---------- */
.row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 70px 30px 190px;
  align-items: center; gap: 12px; height: 40px; padding: 0 4px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.row.head { height: 30px; font-size: 13px; color: var(--faint); }
.row.head .r { text-align: right; }
.row .n { font: 13px var(--mono); color: var(--faint); }
.row .w { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .row { cursor: pointer; }
#list .row:hover { background: var(--panel); }
.row .t { font: 500 14px var(--mono); text-align: right; }
.row .e { text-align: center; font-size: 17px; }
.row .p { display: flex; align-items: center; gap: 10px; }
.row .p .k { font: 12px var(--mono); color: var(--muted); width: 28px; text-align: right; flex: none; }
.row.me { background: var(--panel); }
.row.me .w { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 4px; }
.row.found .w { color: var(--win); }
.row.new { animation: arrive .6s ease-out; }
@keyframes arrive { from { background: #2a2545; } }
.empty { color: var(--faint); font-size: 14px; padding: 20px 4px; margin: 0; }
.giveup-wrap { margin: 22px 0 0; }

.c-ice { color: var(--ice); } .c-cold { color: var(--cold); } .c-cool { color: var(--cool); }
.c-warm { color: var(--warm); } .c-fire { color: var(--fire); } .c-max { color: var(--max); } .c-win { color: var(--win); }

/* ---------- Carte ---------- */
.map {
  position: relative; width: 100%; height: min(calc(100vh - 150px), 820px); min-height: 420px;
  background: #11101d; border-radius: 14px; overflow: hidden;
  touch-action: none; cursor: grab;
}
.map.dragging { cursor: grabbing; }
.map canvas { display: block; width: 100%; height: 100%; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--text); color: var(--bg); border-radius: 8px;
  padding: 6px 10px; font-size: 14px; white-space: nowrap; line-height: 1.35;
  transform: translate(-50%, calc(-100% - 14px));
}
.map-tip.below { transform: translate(-50%, 14px); }
.map-tip b { font-weight: 600; display: block; }
.map-tip span { font-family: var(--mono); font-size: 12px; opacity: .7; }
.map-tip span i { font: normal 12px var(--sans); }
.map-tools { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; }
.tool {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(14, 13, 24, .85); color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.tool.wide { font-size: 13px; }
.tool:hover { color: var(--text); }
.map-caption { color: var(--faint); font-size: 13px; margin: 12px 2px 0; line-height: 1.5; }

.foot { color: var(--faint); font-size: 13px; padding: 10px 28px 30px; max-width: 1320px; width: 100%; margin: 0 auto; }
.foot a { color: var(--muted); }

/* ---------- Fenêtres ---------- */
.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: min(86vh, 900px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text);
}
.dlg.wide { width: min(700px, calc(100vw - 24px)); }
.dlg[open] { display: flex; flex-direction: column; animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.dlg::backdrop { background: rgba(6, 5, 14, .72); }
.dlg-head { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 26px 6px; }
.dlg-head h2 { margin: 0; font: 400 24px var(--serif); }
.dlg-body { padding: 8px 26px 26px; overflow-y: auto; outline: none; }
.prose p { margin: 0 0 14px; color: #d6d0c5; }
.legend { margin: 6px 0 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; }
.legend div { display: flex; gap: 10px; align-items: baseline; }
.legend dt { width: 24px; }
.legend dd { margin: 0; color: var(--muted); font-size: 14px; }

/* Stats */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px 20px; margin: 10px 0 8px; }
.fig small { display: block; color: var(--muted); font-size: 13px; }
.fig b { display: block; font: 400 28px/1.15 var(--serif); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fig i { display: block; font-style: normal; color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec { margin: 30px 0 10px; font: 400 18px var(--serif); }
.spread { display: grid; gap: 7px; }
.spread div { display: grid; grid-template-columns: 26px 1fr 50px; gap: 12px; align-items: center; font: 13px var(--mono); color: var(--muted); }
.spread .bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.spread .bar i { display: block; height: 100%; background: currentColor; }
.hist { display: grid; }
.hist div { display: grid; grid-template-columns: 64px 1fr auto 70px; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.hist .lv { font: 12px var(--mono); color: var(--faint); align-self: center; }
.hist .w { font-weight: 500; }
.hist .w.gave { color: var(--faint); text-decoration: line-through; font-weight: 400; }
.hist .k, .hist .d { font: 13px var(--mono); color: var(--muted); text-align: right; align-self: center; }
.danger { margin-top: 26px; }

/* Classement */
.board-invite { color: var(--muted); margin: 0 0 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.board { display: grid; }
.brow {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 80px 100px 110px; gap: 12px;
  align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--line);
}
.brow.head { font-size: 13px; color: var(--faint); padding-top: 0; }
.brow.me { background: var(--track); border-radius: 8px; }
.brow .pl { font: 13px var(--mono); color: var(--faint); text-align: right; }
.brow:not(.head):nth-child(2) .pl, .brow:not(.head):nth-child(3) .pl, .brow:not(.head):nth-child(4) .pl { color: var(--fire); }
.brow .who { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 500; }
.brow .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .who img { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--track); }
.brow .lv { font: 400 22px var(--serif); text-align: right; }
.brow.head .lv { font: inherit; }
.brow .nb { font: 13px var(--mono); color: var(--muted); text-align: right; }
.brow.head .nb { font: inherit; color: var(--faint); }
.brow .nb small { color: var(--faint); }
.sync { margin-top: 26px; color: var(--faint); font-size: 14px; }
.sync b { color: var(--muted); font-weight: 500; }

/* Plus proches */
.near .row { grid-template-columns: 48px minmax(0, 1fr) 70px 150px; }
.near .row.me .w { color: var(--text); text-decoration: underline; }
.near-more { margin-top: 16px; }

/* ---------- Écrans moyens et mobiles ---------- */
@media (max-width: 1020px) {
  .layout { display: block; max-width: 680px; }
  .map { height: min(72vh, 640px); }
  .top { max-width: 680px; }
  .foot { max-width: 680px; }
  .tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .tab { background: none; border: 0; padding: 0 0 10px; cursor: pointer; color: var(--faint); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .tab.on { color: var(--text); border-color: var(--text); }
  .pane-list:not(.on), .pane-map:not(.on) { display: none; }
  .pane-map { position: static; padding-top: 16px; }
}
@media (max-width: 560px) {
  .top { padding: 20px 16px 16px; }
  .logo { font-size: 25px; }
  .top { flex-wrap: wrap; row-gap: 10px; }
  .top-right { gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
  .links { gap: 12px; }
  .acct span { display: none; }
  .discord span { display: none; }
  .discord { padding: 0 9px; }
  .brow { grid-template-columns: 26px minmax(0, 1fr) 54px 64px; gap: 8px; }
  .brow > :nth-child(5) { display: none; }
  .level b { font-size: 22px; }
  .layout { padding: 0 16px 30px; }
  .btn { padding: 0 16px; }
  .ro-word { font-size: 32px; }
  .ro-temp { font-size: 24px; }
  .readout { margin: 16px 0 22px; min-height: 0; }
  .row { grid-template-columns: 26px minmax(0, 1fr) 56px 24px 84px; gap: 8px; padding: 0 2px; }
  .row .w { font-size: 15px; }
  .row .t { font-size: 13px; }
  .row .e { font-size: 15px; }
  .row .p { gap: 6px; }
  .row .p .k { width: 24px; font-size: 11px; }
  .near .row { grid-template-columns: 36px minmax(0, 1fr) 60px 70px; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .legend { grid-template-columns: 1fr; }
  .foot { padding: 6px 16px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
