/* CHRONO : thème sombre de table de jeu. --c = couleur du joueur concerné. */
:root {
  --bg: #0d0f12;
  --surface: #161a20;
  --surface-2: #1e232b;
  --line: #2b323c;
  --text: #eef1f5;
  --muted: #929bab;
  --accent: #e8c547;
  --warn: #f2a33a;
  --crit: #ff5a4d;
  --radius: 14px;
  --c: var(--accent);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #1a1f27 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.table-mode { overflow: hidden; }
h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.875rem; }
.clock { font-variant-numeric: tabular-nums; font-weight: 750; letter-spacing: -0.02em; line-height: 1; }

/* ---------- mise en page générale ---------- */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}

.brand { display: flex; flex-direction: column; gap: 2px; padding: 8px 0 4px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-size: 1.75rem; font-weight: 800; text-decoration: none; letter-spacing: -0.02em; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 50%;
  border: 4px solid var(--accent);
  position: relative;
}
.logo-mark::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 4px; height: 10px; margin: -10px 0 0 -2px; border-radius: 2px;
  background: var(--text); transform-origin: 50% 100%; transform: rotate(35deg);
}
.tagline { margin: 0; color: var(--muted); }

/* ---------- boutons et champs ---------- */
.btn, .icon, .choice, .chip {
  font: inherit; color: var(--text); cursor: pointer;
  touch-action: manipulation;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 600; text-decoration: none; text-align: center;
  transition: background 0.15s, transform 0.08s;
}
.btn:hover { background: #262c36; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1c1700; }
.btn.primary:hover { background: #f1d363; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; }
.btn.danger, .danger { color: #ff8a80; }
.icon {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 1.2rem; text-decoration: none; padding: 0;
}
.icon.small { width: 36px; height: 36px; font-size: 0.85rem; }
.icon:disabled { opacity: 0.35; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field .label { font-weight: 600; font-size: 0.95rem; }
.field small { color: var(--muted); }
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--text);
  background: #0f1216; border: 1px solid var(--line); border-radius: 10px;
}
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.inline { display: flex; flex-wrap: wrap; gap: 8px; }
.inline input { flex: 1 1 9em; min-width: 0; }
.inline .btn { flex: 1 0 auto; }

/* ---------- accueil ---------- */
.rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rooms .empty { color: var(--muted); padding: 16px 0; }
.room-link {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none;
  --status: var(--muted);
}
.room-link:hover { background: var(--surface-2); }
.room-link.status-running { --status: #4cb86b; }
.room-link.status-paused { --status: var(--warn); }
.room-link.status-setup { --status: #4aa3df; }
.room-meta::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--status); vertical-align: 1px; }
.room-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.room-meta { grid-column: 1; color: var(--muted); font-size: 0.875rem; }
.room-mine { grid-row: 1 / span 2; grid-column: 2; color: var(--accent); font-size: 0.75rem; }

/* ---------- choix de l'appareil ---------- */
.choice {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
}
button.choice:hover { border-color: var(--accent); }
.choice strong { font-size: 1.1rem; }
.choice small { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px; min-height: 44px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 18%, var(--surface));
  border: 2px solid var(--c); font-weight: 600;
}

/* ---------- barre du haut ---------- */
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.topbar .title { display: flex; flex-direction: column; min-width: 0; text-align: center; }
.topbar strong { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar small { color: var(--muted); }

/* ---------- préparation ---------- */
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; min-height: 56px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 9%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.players li::before, .others .pname::before, .owner-head .pname::before {
  content: ""; display: inline-block; flex: none;
  width: 12px; height: 12px; margin-right: 8px; border-radius: 50%;
  background: var(--c); vertical-align: 0;
}
.players li::before { margin-right: 0; }
.players .handle { order: -1; }
.players .pname { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.players .pname em { color: var(--muted); font-style: normal; font-weight: 400; }
.players .ptime { font-variant-numeric: tabular-nums; color: var(--muted); }
.handle {
  touch-action: none; cursor: grab; user-select: none;
  display: grid; place-items: center; width: 32px; height: 40px;
  color: var(--muted); font-size: 1.3rem;
}
.players li.dragging { opacity: 0.9; transform: scale(1.02); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); position: relative; z-index: 1; }
.time-input { width: 6.5em; min-height: 40px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- vue table ---------- */
.table {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.table.seats-2 { grid-template-rows: minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1fr); }
.side { display: flex; gap: 8px; min-height: 0; min-width: 0; }
.middle { display: flex; gap: 8px; min-height: 0; }
.side.left, .side.right { flex: 0 0 27%; flex-direction: column; }

.tile {
  flex: 1; min-width: 0; min-height: 0;
  display: grid; place-items: center;
  padding: 0; border-radius: 20px;
  border: 2px solid color-mix(in srgb, var(--c) 30%, transparent);
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  color: var(--text); font: inherit; cursor: pointer;
  container-type: size;
  touch-action: manipulation;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s, opacity 0.25s;
}
.tile[aria-disabled="true"] { cursor: default; }
.tile-inner { display: flex; flex-direction: column; align-items: center; gap: 0.15em; max-width: 100%; }
.tile.top .tile-inner { transform: rotate(180deg); }
.tile.left .tile-inner { writing-mode: vertical-rl; }
.tile.right .tile-inner { writing-mode: vertical-rl; transform: rotate(180deg); }
.tile .pname {
  font-size: min(11cqh, 9cqw); font-weight: 650;
  max-width: 92cqw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .clock { font-size: min(36cqh, 29cqw); }
.tile .clock.long { font-size: min(30cqh, 21cqw); }
.tile .badge { font-size: min(7cqh, 5.5cqw); min-height: 1.2em; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c); }
.tile.left .pname, .tile.right .pname { font-size: min(15cqw, 8cqh); max-width: none; max-height: 92cqh; }
.tile.left .clock, .tile.right .clock { font-size: min(36cqw, 29cqh); }
.tile.left .clock.long, .tile.right .clock.long { font-size: min(30cqw, 21cqh); }
.tile.left .badge, .tile.right .badge { font-size: min(7cqw, 5.5cqh); }

.tile.current {
  background: color-mix(in srgb, var(--c) 30%, var(--surface));
  border-color: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent), 0 0 48px color-mix(in srgb, var(--c) 30%, transparent);
}
.tile.active:not(.current) { border-color: var(--c); border-style: dashed; }
.tile.out { opacity: 0.35; filter: grayscale(0.85); }
.tile.out .pname { text-decoration: line-through; }
.tile.winner { border-color: var(--c); background: color-mix(in srgb, var(--c) 30%, var(--surface)); }

.center { flex: 1; min-width: 0; display: grid; grid-template-rows: 1fr auto; place-items: center; container-type: size; }
.big-button {
  width: min(74cqh, 92cqw, 440px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
  border: none; cursor: pointer; touch-action: manipulation;
  color: #121212; font: inherit;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--c) 70%, white) 0%, var(--c) 55%, color-mix(in srgb, var(--c) 70%, black) 100%);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--c) 40%, transparent), inset 0 -8px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s, box-shadow 0.2s;
}
.big-button:active { transform: scale(0.96); box-shadow: 0 4px 16px color-mix(in srgb, var(--c) 40%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.big-button:disabled { cursor: default; filter: saturate(0.6); }
.big-button.paused { --c: #9aa3b2; }
.big-face { display: flex; flex-direction: column; align-items: center; gap: 0.4em; max-width: 78%; transform: rotate(var(--rot, 0deg)); transition: transform 0.4s ease; }
.big-label { font-size: clamp(18px, 7.5cqmin, 42px); font-weight: 850; text-transform: uppercase; letter-spacing: 0.03em; text-align: center; line-height: 1.1; }
.big-sub { font-size: clamp(13px, 4.2cqmin, 22px); font-weight: 650; opacity: 0.75; text-align: center; }
.center-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; padding-top: 4px; flex-wrap: wrap; justify-content: center; }
.center-meta .hint { opacity: 0.8; }
.center-meta .icon { width: 40px; height: 40px; font-size: 1rem; }

/* ---------- vue joueur ---------- */
.player-view {
  min-height: 100dvh; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}
.me {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px; border-radius: 20px;
  background: color-mix(in srgb, var(--c) 10%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.me.current { background: color-mix(in srgb, var(--c) 26%, var(--surface)); border-color: var(--c); }
.me .pname { font-weight: 700; font-size: 1.1rem; }
.me .clock { font-size: clamp(64px, 23vw, 150px); }
.me .badge { min-height: 1.3em; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c); }
.me.out { opacity: 0.5; }

.action {
  flex: 1 0 auto; min-height: 34dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border-radius: 28px; padding: 20px; border: none; cursor: pointer; touch-action: manipulation;
  font: inherit; color: #121212;
  transition: transform 0.08s;
}
.action:active { transform: scale(0.98); }
.action .big-label { font-size: clamp(28px, 9vw, 54px); }
.action .big-sub { font-size: 1.05rem; }
.action.go {
  background: radial-gradient(ellipse at 50% 20%, color-mix(in srgb, var(--c) 70%, white), var(--c) 60%, color-mix(in srgb, var(--c) 70%, black));
  box-shadow: 0 12px 40px color-mix(in srgb, var(--c) 35%, transparent), inset 0 -8px 0 rgba(0, 0, 0, 0.18);
}
.action.respond { background: transparent; color: var(--text); border: 3px dashed color-mix(in srgb, var(--c) 70%, transparent); }
.action.respond .big-sub { color: var(--muted); opacity: 1; }
.action.holder { background: var(--warn); }
.action.neutral { background: #c8ced8; }
.action.wait, .action:disabled { background: var(--surface); color: var(--muted); border: 2px solid var(--line); cursor: default; transform: none; }
.action.wait .big-label { font-size: clamp(22px, 6vw, 36px); }

.others { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.others li {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px;
  padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 25%, transparent);
}
.others .pname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.others .clock { font-size: 1.25rem; }
.others .badge { grid-column: 1 / -1; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c); min-height: 1em; }
.others li.current { background: color-mix(in srgb, var(--c) 24%, var(--surface)); }
.others li.out { opacity: 0.4; }
.footer-actions { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- états de temps ---------- */
.low .clock { color: var(--warn); }
.critical .clock, .negative .clock { color: var(--crit); }
.critical .clock { animation: blink 1s steps(2, jump-none) infinite; }
.flag .badge { color: var(--crit); }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---------- menu ---------- */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: 88dvh;
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.menu { display: flex; flex-direction: column; gap: 20px; padding: 16px 18px 20px; }
.menu header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; }
.seg button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 40px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
.owner-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.owner-list li { padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); display: flex; flex-direction: column; gap: 8px; }
.owner-list li.out .pname { text-decoration: line-through; opacity: 0.6; }
.owner-head { display: flex; align-items: center; gap: 8px; }
.owner-head .pname { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-head .clock { font-size: 1.1rem; }
.owner-row { display: flex; gap: 8px; flex-wrap: wrap; }
.owner-row .time-input { flex: 1; min-width: 5em; }

/* ---------- notifications ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, 160%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: #2a3039; border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }
.toast:empty { display: none; }
.net {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  padding: 8px 16px; text-align: center; font-weight: 600;
  background: var(--warn); color: #1c1200;
}

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