/* games.maximerocher.fr — styles communs */

:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --bg-2: #12151c;
  --surface: #181c25;
  --surface-2: #1f2430;
  --surface-3: #282e3c;
  --line: #2b3140;
  --text: #eef1f6;
  --muted: #98a1b3;
  --faint: #636c7e;
  --accent: #8b6cff;
  --accent-ink: #ffffff;
  --good: #2fd39a;
  --bad: #ff5b6e;
  --warn: #ffbf3c;
  --p0: #ff5b6e;
  --p1: #3ea6ff;
  --p2: #ffbf3c;
  --p3: #2fd39a;
  --p4: #c07dff;
  --p5: #ff8a3d;
  --p6: #3fe0e0;
  --p7: #ff7bc8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f5f8;
    --bg-2: #eceef3;
    --surface: #ffffff;
    --surface-2: #f1f3f7;
    --surface-3: #e4e7ee;
    --line: #dde1e9;
    --text: #151821;
    --muted: #5d6576;
    --faint: #9098a8;
    --accent: #6c4cf0;
    --good: #0fa874;
    --bad: #e23a50;
    --warn: #d99100;
    --p2: #e5a400;
    --p3: #10b47c;
    --p6: #10b8b8;
    --shadow: 0 8px 24px rgb(20 24 40 / 0.1);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

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

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

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

/* ---------- Barre du haut ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
}

.topbar .back:hover {
  color: var(--text);
  background: var(--surface);
}

.topbar .tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---------- Boutons & champs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, white);
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
  border-radius: 10px;
}

.btn.icon {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.btn.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
}

.input,
.select {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.input:focus,
.select:focus {
  border-color: var(--accent);
  outline: none;
}

.input.code {
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
}

label.field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  flex-wrap: wrap;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.on {
  background: var(--surface-3);
  color: var(--text);
}

/* ---------- Mise en page des jeux ---------- */

.page {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}

.stat {
  min-width: 88px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.stat .k {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.stat .v {
  display: block;
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.kbd {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-2);
  touch-action: none;
  max-width: 100%;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.overlay h2 {
  font-size: 28px;
}

.overlay p {
  color: var(--muted);
}

/* ---------- Toast ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 100;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}

.toast.bad {
  border-color: color-mix(in srgb, var(--bad) 60%, var(--line));
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Écran de choix du mode (jeux multi) ---------- */

.menu {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.menu .intro {
  text-align: center;
  display: grid;
  gap: 6px;
  padding: 8px 0 4px;
}

.menu .intro h2 {
  font-size: 28px;
}

.menu .intro p {
  color: var(--muted);
}

.mode-list {
  display: grid;
  gap: 12px;
}

.mode {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.mode-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-head .ico {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--accent);
}

.mode-head h3 {
  font-size: 17px;
}

.mode-head p {
  color: var(--muted);
  font-size: 14px;
}

.mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.join-row {
  display: flex;
  gap: 8px;
}

.join-row .input {
  flex: 1;
  min-width: 0;
}

/* ---------- Salon en ligne ---------- */

.lobby {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.lobby .code-box {
  padding: 20px;
  text-align: center;
  display: grid;
  gap: 10px;
}

.lobby .code {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.25em;
  padding-left: 0.25em;
}

.lobby .players {
  padding: 8px;
  display: grid;
  gap: 4px;
}

.lobby .player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
}

.lobby .player:nth-child(odd) {
  background: var(--surface-2);
}

.lobby .player .name {
  flex: 1;
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.tag.accent {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: color-mix(in srgb, var(--accent) 70%, var(--text));
}

.tag.good {
  background: color-mix(in srgb, var(--good) 20%, transparent);
  color: var(--good);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}

.lobby .opts {
  padding: 16px;
  display: grid;
  gap: 12px;
}

/* ---------- Partie ---------- */

.play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.seats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.seat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid transparent;
  font-weight: 650;
  font-size: 14px;
  transition: border-color 0.2s, opacity 0.2s;
  max-width: 100%;
}

.seat.active {
  border-color: var(--seat-color, var(--accent));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--seat-color, var(--accent)) 18%, transparent);
}

.seat.off {
  opacity: 0.5;
}

.seat .badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex: none;
  color: #fff;
  background: var(--seat-color, var(--accent));
}

.seat .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.seat .sc {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.status-line {
  min-height: 28px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.status-line.win {
  color: var(--good);
}

.status-line.lose {
  color: var(--bad);
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.conn {
  font-size: 13px;
  color: var(--warn);
  font-weight: 600;
}

@media (max-width: 520px) {
  .page {
    padding-top: 14px;
  }
  .lobby .code {
    font-size: 36px;
  }
  .menu .intro h2 {
    font-size: 24px;
  }
}

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

/* ---------- Règles ---------- */

dialog.rules {
  width: min(92vw, 520px);
  max-height: 85dvh;
  padding: 24px;
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog.rules::backdrop {
  background: rgb(0 0 0 / 0.5);
}

dialog.rules h2 {
  margin-bottom: 12px;
}

.rules-body {
  color: var(--muted);
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.rules-body ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

.rules-body b {
  color: var(--text);
}
