:root {
  --bg: #0e1116;
  --bg2: #161b23;
  --panel: #1b222c;
  --panel2: #212a36;
  --line: #2c3644;
  --text: #e7ecf3;
  --muted: #93a1b3;
  --gold: #e5b567;
  --gold2: #caa04a;
  --green: #3fb27f;
  --green-bg: #12351f;
  --red: #e0645e;
  --blue: #5b8def;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2230, var(--bg)) fixed;
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--gold); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

header.top {
  display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--line); padding: 14px 16px; background: rgba(14,17,22,.7);
  position: sticky; top: 0; backdrop-filter: blur(6px); z-index: 10;
}
header.top .crown { font-size: 26px; }
header.top h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
header.top h1 small { color: var(--gold); font-weight: 600; }
header.top .spacer { flex: 1; }
header.top .who { color: var(--muted); font-size: 14px; }
header.top .who b { color: var(--text); }

.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: .12s;
}
.btn:hover { border-color: var(--gold2); }
.btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #2a1e05; border: none; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: #5a2b2b; color: var(--red); }
.btn.danger:hover { background: #2a1414; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.king { background: #3a2d08; color: var(--gold); border: 1px solid var(--gold2); }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.no { background: #2a1414; color: var(--red); }

/* tabs giorni */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }
.tab {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  background: var(--panel); min-width: 120px; text-align: center;
}
.tab.active { border-color: var(--gold); background: var(--panel2); }
.tab .d { font-weight: 800; font-size: 14px; }
.tab .t { font-size: 12px; color: var(--gold); }
.tab.nores .t { color: var(--muted); }

/* griglia slot */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.slot {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg2);
  display: flex; flex-direction: column; gap: 4px; min-height: 58px;
}
.slot .time { font-weight: 800; font-size: 13px; letter-spacing: .5px; }
.slot.free { border-style: dashed; }
.slot.free .who { color: var(--muted); font-size: 12px; }
.slot.taken { background: linear-gradient(180deg, #14261c, var(--bg2)); border-color: #285138; }
.slot.done { background: linear-gradient(180deg, #2a2410, var(--bg2)); border-color: var(--gold2); }
.slot .who { font-size: 12.5px; }
.slot .who b { color: var(--text); }
.slot .sub { font-size: 11px; color: var(--muted); }
.slot .actions { display: flex; gap: 6px; margin-top: 2px; }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.banner.info { background: #10202e; border: 1px solid #1d3a52; color: #bcdcf5; }
.banner.warn { background: #2a2410; border: 1px solid var(--gold2); color: #f2dca0; }

/* modale */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 420px; max-width: 100%; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: rgba(255,255,255,.02); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; opacity: 0; transition: .2s; }
.toast.show { opacity: 1; }
.toast.err { border-color: var(--red); }
.hidden { display: none !important; }
.small { font-size: 12px; }

/* ---- auth ---- */
.auth-wrap { max-width: 440px; margin: 40px auto; }
.auth-tabs { display: flex; gap: 8px; margin: 6px 0 14px; }
.auth-tabs .t { flex: 1; text-align: center; padding: 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--muted); }
.auth-tabs .t.active { border-color: var(--gold); color: var(--text); background: var(--panel2); }
.btn.google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff; color: #202124; border: none; }
.btn.google:hover { filter: brightness(.96); }
.btn.block { width: 100%; justify-content: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.link { background: none; border: none; color: var(--gold); cursor: pointer; font-size: 13px; padding: 0; }
.err-text { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
.ok-text { color: var(--green); font-size: 13px; }
.badge-verified { color: var(--green); font-size: 12px; }
.lock-note { background: #2a2410; border: 1px solid var(--gold2); color: #f2dca0; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.spinner { display:inline-block; width:16px; height:16px; border:2px solid var(--line); border-top-color: var(--gold); border-radius:50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ mobile-first ============ */
.lang { width: auto; min-width: 92px; padding: 6px 8px; font-size: 13px; background: var(--panel2); }
.btn.big { min-height: 50px; font-size: 16px; }
.card.compact { padding: 12px 14px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

/* liste (giocatori/prenotazioni) come schede */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg2); }
.item-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.slot-t { font-size: 15px; letter-spacing: .5px; min-width: 46px; }

/* editor giorni */
.day-row { display: grid; grid-template-columns: 70px 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.day-lbl { font-weight: 700; font-size: 13px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chk input { width: auto; }

/* tab giorni scrollabili in orizzontale */
.tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; scrollbar-width: thin; }
.tab { flex: 0 0 auto; min-width: 104px; }

/* tocco comodo */
.btn { min-height: 40px; }
.btn.sm { min-height: 32px; }
input, select, textarea { font-size: 16px; } /* evita lo zoom automatico iOS */

@media (max-width: 640px) {
  .wrap { padding: 12px 12px 80px; }
  header.top { padding: 10px 12px; gap: 8px; }
  header.top h1 { font-size: 15px; }
  .card { padding: 14px; border-radius: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .slots { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .day-row { grid-template-columns: 1fr 1fr; grid-template-areas: "lbl lbl" "title desc" "chk chk"; }
  .day-row .day-lbl { grid-area: lbl; }
  /* modale come foglio dal basso */
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; }
}
@media (min-width: 641px) {
  header.top h1 { font-size: 18px; }
  .slots { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* dashboard Re */
.king-row { display: flex; align-items: stretch; gap: 8px; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); overflow: hidden; }
.king-row.done { border-color: var(--gold2); background: linear-gradient(180deg, #2a2410, var(--bg2)); }
.king-copy { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex: 1; min-width: 0; }
.king-row.copyable .king-copy { cursor: pointer; }
.king-row.copyable .king-copy:hover, .king-row.copyable .king-copy:active { background: rgba(229,181,103,.10); }
.king-time { font-size: 20px; font-weight: 800; letter-spacing: .5px; min-width: 58px; color: var(--gold); }
.king-pid { font-size: 13px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.king-row.copyable .king-pid { color: var(--text); }
.king-actions { display: flex; gap: 6px; align-items: center; padding: 8px 10px; }

/* RTL (arabo) */
[dir="rtl"] .spacer { }
[dir="rtl"] .item, [dir="rtl"] .row { direction: rtl; }
[dir="rtl"] .ellipsis { text-align: right; }
