/* ============================================================
   UNO Scores — feuille de style
   Thème inspiré des cartes UNO. Mobile-first & responsive.
   ============================================================ */

:root {
  --uno-red: #c8102e;
  --uno-red-dark: #9d0c23;
  --uno-yellow: #fdd000;
  --uno-green: #1ea54c;
  --uno-blue: #0072bc;
  --ink: #15171c;
  --ink-soft: #2a2d36;

  --bg: #0f1116;
  --bg-grad-1: #1a1d27;
  --bg-grad-2: #11131a;
  --surface: #1c1f29;
  --surface-2: #232733;
  --surface-3: #2c3140;
  --border: #333949;
  --text: #f4f5f8;
  --text-muted: #a3a9bb;
  --text-dim: #6f7689;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(200, 16, 46, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0, 114, 188, 0.16), transparent 60%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
}

/* ----------------------------------------------------------- Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(15, 17, 22, 0.82);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.brand-badge {
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--uno-red);
  padding: 5px 10px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px #fff, var(--shadow-sm);
  transform: rotate(-6deg);
  font-size: 18px;
}

.brand-text {
  font-weight: 700;
  font-size: 18px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  max-width: 22vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover {
  background: var(--surface-3);
}
.icon-btn:active {
  transform: scale(0.94);
}

.bell-wrap {
  position: relative;
}

.bell-dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 11px;
  height: 11px;
  background: var(--uno-red);
  border: 2px solid var(--surface-2);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(200, 16, 46, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0);
  }
}

/* Panneau des invitations */
.bell-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: min(340px, 86vw);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 50;
}

.bell-panel h3 {
  margin: 6px 8px 10px;
  font-size: 15px;
}

.invite-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: 8px;
}
.invite-item:last-child {
  margin-bottom: 0;
}
.invite-text {
  font-size: 14px;
}
.invite-text strong {
  color: #fff;
}
.invite-actions {
  display: flex;
  gap: 8px;
}

/* ----------------------------------------------------------- Layout */

.view {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px calc(40px + var(--safe-bottom));
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 18px;
}
.page-head h1 {
  font-size: 22px;
  margin: 0;
}
.page-head .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 2px 0 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 0;
  margin-bottom: 4px;
}
.back-link:hover {
  color: var(--text);
}

/* ----------------------------------------------------------- Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin: 22px 4px 10px;
}

/* Carte de session (dashboard) */
.session-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border-left: 5px solid var(--uno-red);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
  display: block;
}
.session-card:hover {
  transform: translateY(-2px);
  background: var(--surface-2);
}
.session-card.status-closed {
  border-left-color: var(--text-dim);
  opacity: 0.9;
}
.session-card .sc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.session-card h3 {
  margin: 0;
  font-size: 17px;
}
.session-card .sc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
}
.session-card .sc-leader {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text);
}

/* ----------------------------------------------------------- Badges */

.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-open {
  background: rgba(30, 165, 76, 0.16);
  color: #4cd17e;
}
.badge-closed {
  background: rgba(111, 118, 137, 0.18);
  color: var(--text-muted);
}
.badge-creator {
  background: rgba(253, 208, 0, 0.16);
  color: var(--uno-yellow);
}
.badge-guest {
  background: rgba(0, 114, 188, 0.18);
  color: #4ea8e6;
}

/* ----------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
  color: #fff;
  background: var(--surface-3);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(180deg, var(--uno-red), var(--uno-red-dark));
  box-shadow: 0 6px 16px rgba(200, 16, 46, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(200, 16, 46, 0.45);
}
.btn-green {
  background: linear-gradient(180deg, #25b257, #178a3f);
  box-shadow: 0 6px 16px rgba(30, 165, 76, 0.3);
}
.btn-blue {
  background: linear-gradient(180deg, #1a86d0, #0063a6);
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  background: var(--surface-2);
}
.btn-danger {
  background: transparent;
  border-color: rgba(200, 16, 46, 0.5);
  color: #ff7186;
}
.btn-danger:hover {
  background: rgba(200, 16, 46, 0.12);
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 10px;
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ----------------------------------------------------------- Forms */

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.input,
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px; /* >=16px : évite le zoom auto sur iOS */
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus,
input:focus,
select:focus {
  border-color: var(--uno-red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.18);
}
.input::placeholder {
  color: var(--text-dim);
}
.field-hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 6px;
}
.field-error {
  font-size: 13px;
  color: #ff7186;
  margin-top: 6px;
  min-height: 0;
}

.radio-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.radio-card {
  flex: 1 1 140px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.radio-card input {
  display: none;
}
.radio-card.selected {
  border-color: var(--uno-red);
  background: rgba(200, 16, 46, 0.1);
}
.radio-card .rc-title {
  font-weight: 700;
  font-size: 14px;
}
.radio-card .rc-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ----------------------------------------------------------- Auth */

.auth-wrap {
  max-width: 420px;
  margin: 7vh auto 0;
  padding: 0 16px calc(40px + var(--safe-bottom));
  text-align: center;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 10px;
}
.auth-card-stack {
  position: relative;
  width: 96px;
  height: 130px;
  margin: 0 auto;
}
.uno-card {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-style: italic;
  font-size: 30px;
  color: #fff;
  border: 4px solid #fff;
}
.uno-card span {
  background: rgba(0, 0, 0, 0.18);
  width: 58px;
  height: 88px;
  border-radius: 50%/40%;
  display: grid;
  place-items: center;
  transform: rotate(-18deg);
}
.uno-card.c1 {
  background: var(--uno-blue);
  transform: rotate(-14deg) translateX(-10px);
}
.uno-card.c2 {
  background: var(--uno-green);
  transform: rotate(-2deg);
}
.uno-card.c3 {
  background: var(--uno-yellow);
  color: var(--ink);
  transform: rotate(10deg) translateX(10px);
}
.uno-card.c4 {
  background: var(--uno-red);
  transform: rotate(4deg) translateY(-4px);
  z-index: 2;
}
.auth-wrap h1 {
  font-size: 26px;
  margin: 6px 0 2px;
}
.auth-wrap .tagline {
  color: var(--text-muted);
  margin: 0 0 22px;
}
.tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
}
.tab.active {
  background: var(--uno-red);
  color: #fff;
}
.auth-card {
  text-align: left;
}

/* ----------------------------------------------------------- Empty state */

.empty {
  text-align: center;
  padding: 40px 20px;
}
.empty .emoji {
  font-size: 52px;
}
.empty h2 {
  margin: 14px 0 6px;
  font-size: 20px;
}
.empty p {
  color: var(--text-muted);
  margin: 0 0 22px;
}

/* ----------------------------------------------------------- Leaderboard */

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 12px;
}
.lb-row + .lb-row {
  border-top: 1px solid var(--border);
}
.lb-row.is-leader {
  background: linear-gradient(90deg, rgba(253, 208, 0, 0.14), transparent);
}
.lb-rank {
  width: 34px;
  text-align: center;
  font-weight: 800;
  font-size: 18px;
  flex: none;
}
.lb-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-name .tag-you {
  font-size: 11px;
  color: var(--uno-yellow);
  margin-left: 6px;
}
.lb-total {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 18px;
}
.lb-total small {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  margin-left: 3px;
}

/* ----------------------------------------------------------- History */

.history-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: max-content;
}
table.history th,
table.history td {
  padding: 9px 12px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.history thead th {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  position: sticky;
  top: 0;
  background: var(--surface);
}
table.history th.col-round,
table.history td.col-round {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}
table.history td.num {
  font-variant-numeric: tabular-nums;
}
table.history tr.total-row td {
  font-weight: 800;
  border-top: 2px solid var(--border);
  border-bottom: 0;
  color: #fff;
}
.round-del {
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 6px;
}
.round-del:hover {
  color: #ff7186;
  background: rgba(200, 16, 46, 0.12);
}

/* ----------------------------------------------------------- Participants */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--uno-blue);
}
.chip.is-creator .dot {
  background: var(--uno-yellow);
}

/* ----------------------------------------------------------- Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
  animation: fade 0.18s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: var(--shadow);
  padding: 8px 18px calc(20px + var(--safe-bottom));
  max-height: 92vh;
  overflow-y: auto;
  animation: slideup 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideup {
  from {
    transform: translateY(40px);
    opacity: 0.4;
  }
}
.modal-grabber {
  width: 42px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 6px auto 14px;
}
.modal h2 {
  margin: 0 0 4px;
  font-size: 20px;
}
.modal .modal-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 18px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn {
  flex: 1;
}

/* Saisie des points par joueur */
.score-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.score-input-row:last-child {
  border-bottom: 0;
}
.score-input-row .sir-name {
  font-weight: 600;
}
.score-input-row input {
  width: 110px;
  text-align: center;
  font-weight: 700;
  font-size: 18px;
}

/* ----------------------------------------------------------- Toasts */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  width: min(420px, 92vw);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success {
  border-left: 4px solid var(--uno-green);
}
.toast-error {
  border-left: 4px solid var(--uno-red);
}
.toast-info {
  border-left: 4px solid var(--uno-blue);
}

/* ----------------------------------------------------------- Misc */

/* ----------------------------------------------------------- Footer */

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 18px 16px calc(14px + var(--safe-bottom));
  font-size: 13px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 12px;
  letter-spacing: 0.3px;
}
.app-footer strong {
  color: var(--text-muted);
}
.footer-sep {
  opacity: 0.4;
}

/* ----------------------------------------------------------- Spinner */

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--uno-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.muted {
  color: var(--text-muted);
}
.center {
  text-align: center;
}
.mt-0 {
  margin-top: 0;
}
.readonly-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
}

/* ----------------------------------------------------------- Desktop */

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
  .modal {
    border-radius: 22px;
  }
  .modal-grabber {
    display: none;
  }
}
