/* The Gate — prototipo frontend. Token derivati dai mock (mockups/*.png). */
:root {
  --bg: #F4ECDF;
  --surface: #FFF9F2;
  --surface-2: #EDE3D3;
  --border: #E4D6C1;
  --ink: #2A1F1A;
  --muted: #6B5A4E;
  --primary: #B5421F;
  --primary-ink: #fff;
  --primary-soft: #F6DCCF;
  --primary-deep: #8E3316;
  --teal-soft: #D6E6DF;
  --teal-ink: #1F4A3C;
  --sand-soft: #F7E5BF;
  --sand-ink: #5C3F0A;
  --plum-soft: #EBD9E4;
  --plum-ink: #5A2F4E;
  --sky-soft: #D9E4F0;
  --sky-ink: #1F3F66;
  --green: #2E5B4C;

  --c-rust: #8E3316;
  --c-forest: #2E5B4C;
  --c-blue: #2F5E8C;
  --c-plum: #6B3D5E;
  --c-olive: #4F6B2B;
  --c-coal: #2A1F1A;
  --c-bronze: #7A5A1F;
  --c-mustard: #A87412;
  --c-gold: #E2A631;
  --c-orange: #C2461E;

  --serif: Georgia, "DejaVu Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", "DejaVu Sans", Roboto, sans-serif;
  --r-lg: 22px;
  --r-md: 16px;
  --r-pill: 999px;
  --tabbar-h: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #E8DCC8;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 2px; border-radius: 6px; }

/* Frame: full screen su mobile, "telefono" centrato su desktop */
.device {
  position: relative;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow-x: hidden;
}
@media (min-width: 600px) {
  body { padding: 24px 0 8px; }
  .device {
    min-height: 0;
    height: min(900px, calc(100dvh - 72px));
    border-radius: 36px;
    box-shadow: 0 30px 80px rgba(60, 35, 15, .25), 0 0 0 10px #2A1F1A;
    overflow: hidden;
  }
  #app { height: 100%; overflow-y: auto; }
}
.proto-note { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 16px; }
@media (max-width: 599px) { .proto-note { display: none; } }

#app { padding-bottom: calc(var(--tabbar-h) + 24px); outline: none; }
#app.no-tabbar { padding-bottom: 110px; }
.page { padding: 20px 16px 0; }

/* Tipografia */
.h-display { font-family: var(--serif); font-weight: 700; font-size: 34px; line-height: 1.1; letter-spacing: -.5px; margin: 0; }
.h-title { font-family: var(--serif); font-weight: 700; font-size: 26px; line-height: 1.15; margin: 0; }
.h-section { font-size: 19px; font-weight: 800; margin: 26px 0 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.h-section a, .link { color: var(--primary); font-weight: 700; text-decoration: none; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 13px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.lead { color: var(--muted); font-size: 17px; margin: 10px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Superfici */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.list-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.list-card > * + * { border-top: 1.5px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; }
.row-top { display: flex; align-items: flex-start; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.hr { border: 0; border-top: 1.5px solid var(--border); margin: 16px 0; }

/* Bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border-radius: 14px; border: 2px solid transparent;
  font-weight: 800; font-size: 16px; text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-outline { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-dark { background: var(--ink); color: #fff; border-radius: var(--r-pill); }
.btn-soft { background: var(--teal-soft); color: var(--teal-ink); border-radius: var(--r-pill); }
.btn-block { width: 100%; min-height: 56px; font-size: 18px; border-radius: 16px; }
.btn-sm { min-height: 40px; padding: 6px 16px; font-size: 15px; }
.btn.is-on.btn-primary { background: var(--green); }
.btn.is-on.btn-outline { background: var(--primary-soft); }
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--border);
  flex: none; position: relative; color: var(--ink);
}
.icon-btn.plain { background: none; border: 0; }
.icon-btn.square { border-radius: 14px; }
.badge {
  position: absolute; top: 2px; right: 0;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--primary); color: #fff; border-radius: 10px;
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
  border: 2px solid var(--bg);
}

/* Chip e tag */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: var(--r-pill);
  background: var(--surface); border: 2px solid var(--border);
  font-weight: 800; font-size: 16px; color: var(--ink);
}
.chip[aria-pressed="true"], .chip.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-deep); }
.chip.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: var(--r-pill); font-weight: 800; font-size: 14px; }
.tag.teal { background: var(--teal-soft); color: var(--teal-ink); }
.tag.sand { background: var(--sand-soft); color: var(--sand-ink); }
.tag.peach { background: var(--primary-soft); color: var(--primary-deep); }
.tag.plum { background: var(--plum-soft); color: var(--plum-ink); }
.tag.sky { background: var(--sky-soft); color: var(--sky-ink); }
.tag.stone { background: var(--surface-2); color: var(--ink); }
.tag.outline { background: var(--surface); border: 1.5px solid var(--border); color: var(--ink); }
.tag.solid-green { background: var(--green); color: #fff; }
.tag.caps { text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }

/* Avatar & copertine gioco */
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .3px;
}
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 64px; height: 64px; font-size: 20px; }
.avatar.seat-free { background: transparent; border: 2.5px dashed var(--primary); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2.5px solid var(--surface); margin-left: -12px; width: 38px; height: 38px; font-size: 13px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.cover {
  flex: none; display: grid; place-items: center;
  color: #fff; font-family: var(--serif); font-weight: 700;
  border-radius: 14px; width: 64px; height: 64px; font-size: 26px;
}
.cover.xl { width: 72px; height: 72px; font-size: 32px; border-radius: 16px; }
.cover.sm { width: 48px; height: 48px; font-size: 20px; border-radius: 12px; }

/* Header app */
.topbar { display: flex; align-items: center; gap: 6px; padding: 16px 16px 8px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 28px; margin-right: auto; }
.brand svg { color: var(--primary); }

/* Segmented control */
.segmented { display: flex; background: var(--surface-2); border-radius: 18px; padding: 5px; gap: 4px; }
.segmented button { flex: 1; min-height: 44px; border: 0; background: none; border-radius: 13px; font-weight: 800; font-size: 16px; color: var(--muted); padding: 8px 6px; }
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(60,35,15,.12); }

/* Tab di pagina (profilo/community) */
.tabs { display: flex; gap: 26px; border-bottom: 1.5px solid var(--border); overflow-x: auto; scrollbar-width: none; margin: 22px 0 16px; }
.tabs button { flex: none; background: none; border: 0; padding: 8px 0 12px; font-weight: 800; font-size: 17px; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -1.5px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--primary); }

/* Toggle */
.switch { position: relative; width: 64px; height: 36px; flex: none; border: 0; border-radius: var(--r-pill); background: #A8988A; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(28px); }

/* Tab bar */
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 440px; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface); border-top: 1.5px solid var(--border); z-index: 20;
}
@media (min-width: 600px) { .tabbar { position: absolute; } }
.tabbar[hidden] { display: none; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: 13px; font-weight: 800; color: var(--muted); padding: 6px 0; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar .fab {
  justify-self: center; width: 66px; height: 66px; margin-top: -34px;
  border-radius: 50%; background: var(--primary); color: #fff;
  box-shadow: 0 0 0 7px var(--bg); display: grid; place-items: center; padding: 0;
}

/* Barra CTA in basso */
.cta-bar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 440px; z-index: 20;
  background: var(--surface); border-top: 1.5px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) { .cta-bar { position: absolute; } }
.cta-bar .row { gap: 16px; }

/* Onboarding */
.progress { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 5px; }
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.cat {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 72px; padding: 12px; border-radius: var(--r-md);
  background: var(--surface); border: 2px solid var(--border);
  font-weight: 800; font-size: 16px; line-height: 1.15; hyphens: auto; overflow-wrap: anywhere;
}
.cat[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.cat.dashed { border-style: dashed; }
.cat .dot { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.game-pick { position: relative; padding: 10px; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border); text-align: left; font-weight: 800; font-size: 14px; }
.game-pick .cover { width: 100%; height: 58px; font-size: 22px; border-radius: 10px; margin-bottom: 8px; }
.game-pick[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.game-pick .check { display: none; position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); color: var(--primary); place-items: center; }
.game-pick[aria-pressed="true"] .check { display: grid; }

/* Input */
.search { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 18px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 18px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; min-width: 0; }
.search input::placeholder { color: var(--muted); opacity: .85; }
textarea.input { width: 100%; min-height: 120px; padding: 14px; border-radius: var(--r-md); border: 1.5px solid var(--border); background: var(--surface); resize: vertical; font-size: 16px; }

/* Feed */
.composer { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: var(--r-lg); background: var(--surface); border: 1.5px solid var(--border); width: 100%; text-align: left; }
.composer .ph { flex: 1; color: var(--muted); font-size: 17px; }
.meta-line { display: flex; align-items: flex-start; gap: 8px; color: var(--ink); font-size: 16px; }
.meta-line svg { flex: none; margin-top: 1px; }
.why { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.why b { color: var(--muted); }
.seats-free { color: var(--primary-deep); font-weight: 800; font-size: 17px; }
.post-body { font-size: 17px; line-height: 1.45; margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.game-ref { display: flex; align-items: center; gap: 12px; padding: 10px; margin-top: 12px; background: var(--bg); border-radius: 14px; }
.post-actions { display: flex; gap: 6px; margin-top: 12px; }
.post-actions button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; min-height: 40px; padding: 4px 10px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.post-actions button[aria-pressed="true"] { color: var(--primary); }

/* Esplora */
.hscroll { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; scroll-padding-inline: 16px; }
.hscroll::-webkit-scrollbar { display: none; }
.event-tile { flex: none; width: 76%; scroll-snap-align: start; border-radius: var(--r-lg); overflow: hidden; background: var(--surface); border: 1.5px solid var(--border); text-decoration: none; }
.event-tile .band { height: 88px; padding: 14px 18px; display: flex; align-items: flex-end; justify-content: space-between; color: #fff; font-family: var(--serif); font-weight: 700; font-size: 24px; }
.event-tile .body { padding: 14px 18px 18px; }
.promo { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r-lg); background: var(--green); color: #fff; text-decoration: none; }
.promo .avatar-stack .avatar { border-color: var(--green); color: var(--ink); }
.hub-row { display: flex; align-items: center; gap: 14px; padding: 16px; }
.hub-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none; }
.verified { color: var(--green); display: inline-flex; vertical-align: -3px; }

/* Giocatori compatibili */
.notice { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--teal-soft); border: 1.5px solid #B9D3C8; }
.reason { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; }
.reason svg { color: var(--green); flex: none; }

/* Hero (dettaglio tavolo, profilo, community) */
.hero { position: relative; height: 240px; overflow: hidden; }
.hero .bg-word { position: absolute; left: 34%; bottom: -46px; font-family: var(--serif); font-weight: 700; font-size: 180px; color: rgba(255,255,255,.12); white-space: nowrap; }
.deco { position: absolute; right: 14px; bottom: 10px; display: flex; gap: 12px; color: rgba(255,255,255,.18); }
.hero-actions { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; gap: 10px; }
.hero-actions .icon-btn { border: 0; }
.hero-actions .spacer { flex: 1; }
.sheet-body { position: relative; margin-top: -32px; background: var(--bg); border-radius: 28px 28px 0 0; padding: 22px 16px 0; }
.hero-tag { position: absolute; left: 16px; bottom: 44px; }
.info-row { display: flex; gap: 14px; align-items: center; padding: 16px; }
.info-row .ic { width: 50px; height: 50px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-deep); display: grid; place-items: center; flex: none; }
.info-row b { font-size: 17px; }
.people-row { display: flex; justify-content: space-between; gap: 6px; margin-top: 10px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; font-weight: 800; text-decoration: none; min-width: 0; }
.person .avatar { width: 58px; height: 58px; font-size: 18px; }
.person.known .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5.5px var(--c-gold); }
.person.free { color: var(--muted); }

.profile-head { position: relative; padding: 0 16px; display: flow-root; min-height: 64px; }
.profile-cover { height: 150px; position: relative; overflow: hidden; }
.profile-avatar { width: 100px; height: 100px; border-radius: 30px; border: 6px solid var(--bg); margin-top: -50px; display: grid; place-items: center; color: #fff; font-family: var(--serif); font-weight: 700; font-size: 40px; position: relative; }
.profile-actions { position: absolute; right: 16px; top: 10px; display: flex; gap: 8px; }
.profile-actions .btn { padding: 10px 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.stat { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 14px 12px; font-size: 14px; color: var(--muted); }
.stat b { display: block; color: var(--ink); font-size: 17px; margin: 8px 0 4px; }
.play-row { display: flex; align-items: center; gap: 14px; }
.date-box { width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; align-content: center; flex: none; }
.date-box small { font-weight: 800; letter-spacing: 1px; font-size: 13px; }
.date-box strong { font-family: var(--serif); font-size: 26px; line-height: 1; }
.pin-card { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--r-lg); background: var(--sand-soft); }

/* Crea tavolo */
.step-label { margin: 24px 0 10px; }
.opt-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; text-align: left; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border); }
.opt-card + .opt-card { margin-top: 10px; }
.opt-card[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }
.opt-card .ic { width: 50px; height: 50px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-deep); display: grid; place-items: center; flex: none; }
.opt-card[aria-pressed="true"] .ic { background: var(--primary); color: #fff; }
.stepper-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stepper { padding: 14px; border-radius: var(--r-md); background: var(--surface); border: 2px solid var(--border); }
.stepper.accent { border-color: var(--primary); }
.stepper.accent .label, .stepper.accent output { color: var(--primary-deep); }
.stepper .label { font-weight: 800; }
.stepper .ctrl { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.stepper .ctrl button { width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--bg); font-size: 24px; display: grid; place-items: center; }
.stepper output { font-family: var(--serif); font-weight: 700; font-size: 30px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1.5px solid var(--border); margin-top: 12px; }

/* Bottom sheet */
.overlay { position: fixed; inset: 0; background: rgba(42,31,26,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
@media (min-width: 600px) { .overlay { position: absolute; } }
.sheet { width: 100%; max-width: 440px; max-height: 85%; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); animation: rise .2s ease; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 22px); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
@media (min-width: 600px) { .toast { position: absolute; } }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { color: var(--primary); margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 380px) {
  .cat { font-size: 15px; gap: 10px; padding: 10px; }
  .cat .dot { width: 38px; height: 38px; }
  .h-display { font-size: 30px; }
}

.actions { display: flex; gap: 8px; }
.actions .btn { white-space: nowrap; padding: 10px 14px; }
.actions .btn.grow { flex: 1; }
