@font-face {
  font-family: 'IM Fell English';
  src: url('/fonts/fell/im-fell-english-latin-400-normal.woff2') format('woff2');
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('/fonts/fell/im-fell-english-latin-400-italic.woff2') format('woff2');
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English SC';
  src: url('/fonts/fell-sc/im-fell-english-sc-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  --soot: #080504;
  --bone: #e7dcc3;
  --bone-dim: #b3a78f;
  --tallow: #f0b35a;
  --sang: #c9463a;
  --paper: #e6d9bd;
  --ink: #1b1512;
  --text: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --caps: 'IM Fell English SC', 'IM Fell English', Georgia, serif;
  --edge: clamp(14px, 2.4vw, 30px);
  --on-scene: 0 1px 0 #000, 0 0 3px #000, 0 0 16px rgba(0, 0, 0, 0.9);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--soot);
  color: var(--bone);
  font: 18px/1.45 var(--text);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  image-rendering: pixelated;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--tallow);
  outline-offset: 3px;
}

/* ───────── boutons : des plaques gravées, pas des pastilles ───────── */

.btn {
  font-family: var(--caps);
  font-size: 18px;
  letter-spacing: 0.03em;
  line-height: 1;
  padding: 11px 18px 12px;
  background: rgba(8, 5, 4, 0.72);
  border: 1px solid rgba(231, 220, 195, 0.55);
  color: var(--bone);
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  background: var(--bone);
  border-color: var(--bone);
  color: var(--ink);
}
.btn.main {
  background: var(--tallow);
  border-color: var(--tallow);
  color: var(--ink);
}
.btn.main:hover:not(:disabled) {
  background: #ffd08a;
  border-color: #ffd08a;
}
.btn[aria-pressed='true'] {
  background: var(--bone);
  color: var(--ink);
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.link {
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  font-style: italic;
  color: var(--bone-dim);
  text-decoration: underline;
  text-decoration-color: rgba(231, 220, 195, 0.35);
  text-underline-offset: 4px;
  text-shadow: var(--on-scene);
}
.link:hover {
  color: var(--tallow);
  text-decoration-color: currentColor;
}

/* ───────── l'accueil ───────── */

#home {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  padding: var(--edge) clamp(20px, 7vw, 110px);
  background: linear-gradient(90deg, rgba(8, 5, 4, 0.9) 0%, rgba(8, 5, 4, 0.62) 42%, rgba(8, 5, 4, 0) 78%);
  overflow-y: auto;
}
.home-col {
  width: min(640px, 100%);
  margin: auto 0;
}
#home h1 {
  margin: 0 0 0.3em;
  font-size: clamp(58px, 10.5vw, 148px);
  font-weight: 400;
  font-style: italic;
  line-height: 0.84;
  letter-spacing: -0.02em;
  text-shadow: 0 3px 0 #000;
}
.home-pitch {
  max-width: 34ch;
  margin: 0 0 1.7em;
  font-size: 21px;
  color: var(--bone);
  text-shadow: var(--on-scene);
}
#join-form label {
  display: block;
  margin-bottom: 4px;
  font-style: italic;
  color: var(--bone-dim);
}
#join-form input:not([type='checkbox']) {
  background: rgba(8, 5, 4, 0.6);
  border: 0;
  border-bottom: 1px solid var(--bone);
  padding: 6px 2px 7px;
  font-size: 26px;
  caret-color: var(--tallow);
}
#name {
  width: min(340px, 100%);
}
#code {
  width: 4.4em;
  font-family: var(--caps);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#join-form input::placeholder {
  color: rgba(231, 220, 195, 0.35);
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
}
#join-form .check {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 18px 0 22px;
  max-width: 44ch;
  font-style: normal;
  color: var(--bone);
  cursor: pointer;
}
.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--tallow);
  flex: none;
  translate: 0 2px;
}
.home-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}
.home-or {
  font-style: italic;
  color: var(--bone-dim);
}
#invite {
  margin: 0 0 18px;
  padding-left: 12px;
  border-left: 2px solid var(--tallow);
  font-size: 21px;
}
#home-error {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: var(--sang);
  font-style: italic;
}
#home > .home-col > .link {
  margin-top: 6px;
}

/* ───────── en jeu : le texte se pose sur la scène, sans cadres ───────── */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#hud > * {
  pointer-events: auto;
}

#corner {
  position: absolute;
  top: var(--edge);
  left: var(--edge);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-shadow: var(--on-scene);
}
.corner-code {
  font-family: var(--caps);
  font-size: 20px;
}
.corner-code b {
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--tallow);
  user-select: all;
}

#tools {
  position: absolute;
  top: var(--edge);
  right: var(--edge);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
#tools .off {
  color: rgba(179, 167, 143, 0.7);
}

#phase {
  position: absolute;
  top: var(--edge);
  left: 50%;
  translate: -50% 0;
  width: min(560px, calc(100vw - 2 * var(--edge) - 300px));
  text-align: center;
  pointer-events: none;
  text-shadow: var(--on-scene);
}
#phase-title {
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 400;
  font-style: italic;
  line-height: 1;
}
#phase-sub {
  margin: 8px 0 0;
  color: var(--bone);
  line-height: 1.3;
  text-wrap: balance;
}
#timer {
  margin: 6px 0 0;
  font-family: var(--caps);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  color: var(--tallow);
}
#timer.late {
  color: var(--sang);
}

#banner {
  position: absolute;
  top: 34%;
  left: 50%;
  translate: -50% -50%;
  width: min(760px, 86vw);
  margin: 0;
  text-align: center;
  font-size: clamp(26px, 3.6vw, 44px);
  font-style: italic;
  line-height: 1.12;
  text-wrap: balance;
  text-shadow: 0 2px 0 #000, 0 0 6px #000, 0 0 30px #000;
  pointer-events: none;
}
#banner:empty {
  display: none;
}
#banner small {
  display: block;
  margin-top: 10px;
  font-size: 0.55em;
  font-style: normal;
  color: var(--tallow);
}

/* le billet du rôle : le seul papier à l'écran */
#note {
  position: absolute;
  left: var(--edge);
  bottom: calc(var(--edge) + 150px);
  width: min(340px, calc(100vw - 2 * var(--edge)));
  padding: 16px 18px 18px;
  background: var(--paper);
  color: var(--ink);
  rotate: -1.6deg;
  box-shadow: 5px 6px 0 rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
#note h3 {
  margin: 0 0 6px;
  font-size: 27px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.05;
}
#note p {
  margin: 6px 0 0;
  font-size: 17px;
  line-height: 1.32;
}

#panel {
  position: absolute;
  left: 50%;
  bottom: calc(var(--edge) + 64px);
  translate: -50% 0;
  width: min(720px, calc(100vw - 2 * var(--edge)));
  padding: 26px 20px 4px;
  text-align: center;
  text-shadow: var(--on-scene);
  background: radial-gradient(ellipse at 50% 60%, rgba(8, 5, 4, 0.78) 0%, rgba(8, 5, 4, 0.5) 45%, rgba(8, 5, 4, 0) 72%);
}
#panel:empty {
  display: none;
}
#panel .prompt {
  margin: 0 0 12px;
  font-size: 25px;
  font-style: italic;
}
#panel .chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}
.chip {
  font-family: var(--caps);
  font-size: 21px;
  line-height: 1;
  padding: 10px 16px 11px;
  background: rgba(8, 5, 4, 0.78);
  border: 1px solid currentColor;
  cursor: pointer;
  text-shadow: none;
}
.chip:hover {
  background: rgba(40, 26, 18, 0.95);
}
.chip[aria-pressed='true'] {
  background: var(--bone);
  border-color: var(--bone);
  color: var(--ink) !important;
}
#panel .wait {
  margin: 0;
  font-style: italic;
  color: var(--bone);
}
#panel table,
#score-table {
  margin: 0 auto 14px;
  border-collapse: collapse;
  background: rgba(8, 5, 4, 0.74);
  text-shadow: none;
}
#panel td,
#panel th,
#score-table td,
#score-table th {
  padding: 5px 16px;
  text-align: left;
  font-weight: 400;
  border-bottom: 1px solid rgba(231, 220, 195, 0.18);
}
#panel th,
#score-table th {
  font-style: italic;
  color: var(--bone-dim);
}
#panel td.num,
#score-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td .who {
  font-family: var(--caps);
}
tr.won td:last-child {
  color: var(--tallow);
}

#log {
  position: absolute;
  left: var(--edge);
  bottom: calc(var(--edge) + 46px);
  width: min(360px, 44vw);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
  text-shadow: var(--on-scene);
  line-height: 1.25;
}
#log li {
  margin-top: 3px;
  transition: opacity 1.2s;
}
#log li.old {
  opacity: 0;
}
#log .who {
  font-family: var(--caps);
}

#chat-form {
  position: absolute;
  left: var(--edge);
  bottom: var(--edge);
  width: min(360px, 44vw);
}
#chat {
  width: 100%;
  background: rgba(8, 5, 4, 0.6);
  border: 0;
  border-bottom: 1px solid rgba(231, 220, 195, 0.5);
  padding: 6px 4px;
  caret-color: var(--tallow);
}
#chat::placeholder {
  color: rgba(231, 220, 195, 0.45);
  font-style: italic;
}
#chat:focus {
  outline: none;
  border-bottom-color: var(--tallow);
  background: rgba(8, 5, 4, 0.85);
}

#actions {
  position: absolute;
  right: var(--edge);
  bottom: var(--edge);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  max-width: min(520px, 50vw);
}
#actions .hint {
  flex-basis: 100%;
  margin: 0;
  text-align: right;
  font-style: italic;
  text-shadow: var(--on-scene);
}
#actions label {
  font-style: italic;
  text-shadow: var(--on-scene);
}
#actions select {
  background: rgba(8, 5, 4, 0.78);
  border: 1px solid rgba(231, 220, 195, 0.55);
  padding: 8px 8px 9px;
  font-family: var(--caps);
}

#mirror {
  position: absolute;
  right: var(--edge);
  bottom: calc(var(--edge) + 96px);
  width: 66px;
  height: 77px;
  border: 1px solid rgba(231, 220, 195, 0.5);
  scale: -1 1;
  image-rendering: pixelated;
  filter: sepia(0.35) contrast(1.1);
  pointer-events: none;
}

#keys {
  position: absolute;
  left: var(--edge);
  top: calc(var(--edge) + 76px);
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  white-space: nowrap;
  font-size: 15px;
  font-style: italic;
  color: var(--bone-dim);
  text-shadow: var(--on-scene);
  pointer-events: none;
}
#keys b {
  font-family: var(--caps);
  font-style: normal;
  font-weight: 400;
  color: var(--bone);
}

#toast {
  position: absolute;
  top: 22%;
  left: 50%;
  translate: -50% 0;
  margin: 0;
  padding: 6px 14px;
  background: var(--paper);
  color: var(--ink);
  font-style: italic;
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
#toast.on {
  opacity: 1;
}

/* ───────── les noms au-dessus des têtes ───────── */

#labels {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.tag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 240px;
  margin-left: -120px;
  text-align: center;
  text-shadow: var(--on-scene);
  will-change: transform;
}
.tag-inner {
  position: absolute;
  bottom: 0;
  left: 50%;
  translate: -50% 0;
  width: max-content;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tag-name {
  font-family: var(--caps);
  font-size: 22px;
  line-height: 1.1;
}
.tag.away .tag-name {
  opacity: 0.45;
}
.tag-sub {
  font-size: 16px;
  font-style: italic;
  line-height: 1.15;
  color: var(--bone);
}
.tag-sub.know {
  color: var(--tallow);
}
.tag-sub.bad {
  color: var(--sang);
}
.tag-say {
  max-width: 230px;
  margin-bottom: 7px;
  padding: 5px 10px 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
  text-shadow: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  overflow-wrap: anywhere;
}

/* ───────── la roue des gestes ───────── */

#wheel {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none !important;
}
.wheel-disc {
  position: absolute;
  left: -150px;
  top: -150px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(8, 5, 4, 0) 0 34px, rgba(8, 5, 4, 0.82) 35px 149px, rgba(8, 5, 4, 0) 150px);
  border: 1px solid rgba(231, 220, 195, 0.4);
}
.wheel-disc::after {
  content: '';
  position: absolute;
  inset: 115px;
  border-radius: 50%;
  border: 1px solid rgba(231, 220, 195, 0.4);
}
.wheel-item {
  position: absolute;
  width: 124px;
  margin: -22px 0 0 -62px;
  height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
  font-family: var(--caps);
  font-size: 16px;
  line-height: 1.02;
  color: var(--bone-dim);
}
.wheel-item.on {
  color: var(--ink);
  background: var(--tallow);
}

/* ───────── fenêtres ───────── */

dialog {
  width: min(600px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 26px 30px 24px;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.6);
  font-size: 18px;
}
dialog::backdrop {
  background: rgba(8, 5, 4, 0.72);
}
dialog h2 {
  margin: 0 0 6px;
  font-size: 40px;
  font-weight: 400;
  font-style: italic;
  line-height: 1;
}
dialog h3 {
  margin: 20px 0 4px;
  font-family: var(--caps);
  font-size: 20px;
  font-weight: 400;
}
dialog p,
dialog ol {
  margin: 0 0 8px;
}
dialog .lead {
  font-size: 21px;
  font-style: italic;
}
dialog dl {
  margin: 0;
}
dialog dt {
  margin-top: 8px;
  font-style: italic;
}
dialog dd {
  margin: 0;
}
dialog dl.keys {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 18px;
}
dialog dl.keys dt {
  margin: 0;
  font-family: var(--caps);
  font-style: normal;
}
dialog ol {
  padding-left: 1.3em;
}
dialog form {
  margin-top: 20px;
}
dialog .btn {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
dialog .btn:hover:not(:disabled) {
  background: #40322a;
  color: var(--paper);
}
#score-table {
  width: 100%;
  margin: 10px 0 0;
  background: none;
}
#score-table td,
#score-table th {
  border-bottom-color: rgba(27, 21, 18, 0.25);
  padding-left: 0;
}
#score-table th {
  color: #6b5a4b;
}

/* ───────── petits écrans ───────── */

@media (max-width: 820px) {
  #keys {
    display: none;
  }
  #phase {
    top: calc(var(--edge) + 56px);
    width: calc(100vw - 2 * var(--edge));
  }
  #tools {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px 12px;
    max-width: 62vw;
  }
  #log,
  #chat-form {
    width: calc(100vw - 2 * var(--edge));
  }
  #actions {
    bottom: calc(var(--edge) + 48px);
    max-width: calc(100vw - 2 * var(--edge));
  }
  #log {
    bottom: calc(var(--edge) + 104px);
  }
  #panel {
    bottom: calc(var(--edge) + 112px);
  }
  #note {
    bottom: calc(var(--edge) + 190px);
  }
  #mirror {
    bottom: auto;
    top: calc(var(--edge) + 62px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
