/* Thème commun de la salle de jeux : fond quasi noir à points, surfaces sobres. */

:root {
  --bg: #111318;
  --dots: rgb(255 255 255 / 0.07);
  --ink: #eceef2;
  --ink-dim: #8b919c;
  --surface: #1a1d23;
  --surface-2: #22262e;
  --line: #2b3039;
  --accent: #5b8cff;
  --danger: #f26b6b;
  --ok: #6fd36f;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--dots) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 16px/1.4 ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body[data-screen='game'] {
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
}

.splash {
  display: grid;
  place-items: center;
  height: 100dvh;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------ éléments de base */

button {
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 0.7em 1.1em;
  min-height: 48px;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform 0.08s, background 0.15s;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
button.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
}
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-dim);
}
button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
button.link {
  background: none;
  border: 0;
  color: var(--ink-dim);
  font-weight: 500;
  text-decoration: underline;
}
button.big {
  width: 100%;
  min-height: 54px;
  font-size: 1.05rem;
}
button.small {
  min-height: 38px;
  padding: 0.35em 0.9em;
  font-size: 0.9rem;
}
button.icon {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
button.icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button.icon svg circle {
  fill: var(--ink);
  stroke: none;
}

input,
select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65em 0.9em;
  min-height: 48px;
  width: 100%;
}
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input.code {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-weight: 700;
  text-align: center;
}
.shake {
  animation: shake 0.35s;
}
@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.row {
  display: flex;
  gap: 8px;
}
.row > input {
  flex: 1;
}
.small {
  font-size: 0.85rem;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------ panneaux */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notice {
  text-align: center;
  color: var(--ink-dim);
  margin: 0;
}

/* ------------------------------------------------------------ calques */

.overlay {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
  animation: fade 0.2s;
}
.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  width: min(520px, 100%);
  max-height: 85dvh;
  overflow: auto;
  padding: 18px 16px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.25s ease-out;
}
.sheet h2 {
  margin: 0;
  font-size: 1.2rem;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.overlay.round {
  align-items: center;
}
.overlay.round .sheet {
  border-radius: 20px;
  margin: 12px;
  text-align: center;
}
.note {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

table.scores {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.scores th,
table.scores td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
table.scores thead th {
  color: var(--ink-dim);
  font-weight: 500;
}
table.scores tfoot th {
  font-size: 1.1rem;
}
td.doubled {
  color: var(--danger);
}
ol.log {
  margin: 0;
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}
ol.log li.old {
  color: var(--ink-dim);
}
ul.rules {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ------------------------------------------------------------ bannière et toasts */

.banner {
  position: fixed;
  top: var(--safe-top);
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 100%);
  z-index: 30;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 2px solid var(--accent);
}
.banner.warn {
  border-color: #f3e04f;
}
.banner.error {
  border-color: var(--danger);
}
.banner button {
  flex: none;
}
#toasts {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.4);
  transition: opacity 0.4s;
}
.toast.error {
  border-color: var(--danger);
}
.toast.out {
  opacity: 0;
}

/* ------------------------------------------------------------ écrans */

.screen {
  padding: calc(18px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
