:root {
  --bg: #07101f;
  --bg-2: #0c1830;
  --surface: rgba(255, 255, 255, .055);
  --surface-2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .10);
  --text: #eef3ff;
  --muted: #93a3c4;
  --lime: #d4f53c;
  --lime-ink: #10200a;
  --blue: #3b74ff;
  --red: #ff6b6b;
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Space Grotesk', var(--font);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% -10%, #12306e 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

.glow { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(90px); opacity: .35; pointer-events: none; z-index: -1; }
.glow-a { background: #2a5cff; top: -160px; left: -140px; }
.glow-b { background: #b7e21a; bottom: -220px; right: -180px; opacity: .14; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: linear-gradient(to bottom, rgba(7, 16, 31, .92), rgba(7, 16, 31, .55) 70%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; letter-spacing: .02em; font-size: 17px; }
.ball-dot { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f4ff9a, #b8d80f); box-shadow: 0 0 16px rgba(212, 245, 60, .6); }
.topbar-actions { display: flex; gap: 8px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip-btn:active { transform: scale(.96); }

/* ---------- layout ---------- */
main { max-width: 560px; margin: 0 auto; padding: 0 18px calc(40px + var(--safe-b)); }
.screen { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.display { font-family: var(--display); font-weight: 700; font-size: clamp(30px, 8.5vw, 40px); line-height: 1.05; letter-spacing: -.02em; margin: 6px 0 10px; }
.lead { color: var(--muted); margin: 0 0 22px; font-size: 16px; }
.lead strong { color: var(--text); font-weight: 600; word-break: break-all; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 700; color: var(--lime); margin: 0; }
.fine { color: var(--muted); font-size: 13px; margin: 14px 2px 0; text-align: center; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .035));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .55);
}

/* ---------- hero ---------- */
.hero { padding-top: 4px; }
.hero-court { margin: 0 -18px 6px; display: flex; justify-content: center; }
.hero-court.small { height: 120px; }
.court-svg { width: min(100%, 420px); height: auto; filter: drop-shadow(0 30px 40px rgba(20, 60, 200, .45)); }
.ball { animation: bounce 1.6s cubic-bezier(.5, 0, .5, 1) infinite; transform-origin: 160px 150px; }
.ball-shadow { animation: shadow 1.6s cubic-bezier(.5, 0, .5, 1) infinite; transform-origin: 160px 160px; }
@keyframes bounce { 0%, 100% { transform: translate(-70px, 0); } 25% { transform: translate(-35px, -95px); } 50% { transform: translate(0, 0) scale(1.08, .92); } 75% { transform: translate(35px, -95px); } }
@keyframes shadow { 0%, 100% { transform: translateX(-70px) scale(1); opacity: .9; } 25% { transform: translateX(-35px) scale(.45); opacity: .35; } 50% { transform: translateX(0) scale(1); opacity: .9; } 75% { transform: translateX(35px) scale(.45); opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ball, .ball-shadow, .screen { animation: none; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.field input {
  height: 56px; border-radius: 16px; border: 1px solid var(--line); background: rgba(3, 8, 18, .55);
  color: var(--text); font-size: 17px; padding: 0 16px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--lime); box-shadow: 0 0 0 4px rgba(212, 245, 60, .15); }

.btn {
  height: 56px; border-radius: 16px; border: 0; cursor: pointer; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 20px;
  transition: transform .15s, filter .2s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-lime { background: var(--lime); color: var(--lime-ink); box-shadow: 0 12px 30px -10px rgba(212, 245, 60, .6); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .35); color: #ffb3b3; }
.btn.loading::after { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.back-link { background: none; border: 0; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; padding: 8px 0; cursor: pointer; font-size: 14px; }
.mail-orb, .check-orb {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 8px 0 14px;
  background: linear-gradient(140deg, var(--lime), #9cc412); box-shadow: 0 16px 40px -12px rgba(212, 245, 60, .7);
}
.mail-orb svg, .check-orb svg { width: 30px; height: 30px; fill: none; stroke: var(--lime-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp input {
  width: 100%; aspect-ratio: 3 / 4; max-height: 64px; text-align: center; font-family: var(--display); font-size: 26px; font-weight: 700;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(3, 8, 18, .55); color: var(--text); outline: none; padding: 0;
  transition: border-color .2s, transform .15s;
}
.otp input:focus { border-color: var(--lime); transform: translateY(-2px); }
.otp.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- home ---------- */
.greeting { margin: 4px 0 18px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 28px 0 12px; gap: 12px; }
.section-head h2 { font-family: var(--display); font-size: 22px; margin: 0; }
.meter { font-size: 13px; color: var(--muted); white-space: nowrap; }

.ticket {
  position: relative; border-radius: var(--radius); overflow: hidden; padding: 18px 18px 16px;
  background: linear-gradient(135deg, #1f4fe0 0%, #1534a1 60%, #0f2577 100%);
  box-shadow: 0 24px 60px -24px rgba(40, 90, 255, .8); border: 1px solid rgba(255, 255, 255, .14);
}
.ticket::before { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 18px solid rgba(212, 245, 60, .12); }
.ticket + .ticket { margin-top: 12px; }
.ticket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: relative; }
.ticket-when { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.15; }
.ticket-sub { color: rgba(238, 243, 255, .75); font-size: 14px; margin-top: 2px; }
.ticket-badge { font-size: 12px; font-weight: 700; background: rgba(212, 245, 60, .16); color: var(--lime); border-radius: 999px; padding: 5px 10px; white-space: nowrap; }
.ticket-cut { position: relative; height: 1px; margin: 16px -18px 14px; border-top: 2px dashed rgba(255, 255, 255, .22); }
.ticket-cut::before, .ticket-cut::after { content: ''; position: absolute; top: -12px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); }
.ticket-cut::before { left: -11px; } .ticket-cut::after { right: -11px; }
.code-label { font-size: 12px; text-transform: uppercase; letter-spacing: .16em; color: rgba(238, 243, 255, .7); font-weight: 600; }
.code { display: flex; gap: 6px; margin: 8px 0 6px; }
.code span {
  flex: 1; max-width: 52px; aspect-ratio: 4 / 5; display: grid; place-items: center; border-radius: 12px;
  background: rgba(3, 8, 18, .35); border: 1px solid rgba(255, 255, 255, .16);
  font-family: var(--display); font-weight: 700; font-size: 28px; color: #fff;
}
.success .code span { animation: flip .5s cubic-bezier(.2, .8, .2, 1) both; }
.success .code span:nth-child(2) { animation-delay: .08s; } .success .code span:nth-child(3) { animation-delay: .16s; }
.success .code span:nth-child(4) { animation-delay: .24s; } .success .code span:nth-child(5) { animation-delay: .32s; }
.success .code span:nth-child(6) { animation-delay: .40s; }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }
.code-note { font-size: 13px; color: rgba(238, 243, 255, .75); }
.ticket-actions { display: flex; gap: 8px; margin-top: 14px; }
.ticket-actions .btn { height: 44px; font-size: 14px; flex: 1; border-radius: 12px; white-space: nowrap; padding: 0 12px; gap: 8px; }

.days { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -18px; padding: 4px 18px 8px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day {
  scroll-snap-align: start; flex: 0 0 auto; min-width: 62px; padding: 10px 12px; border-radius: 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; transition: background .2s, transform .15s;
}
.day:active { transform: scale(.96); }
.day .dw { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.day .dn { font-family: var(--display); font-size: 22px; font-weight: 700; margin-top: 2px; }
.day.active { background: var(--lime); color: var(--lime-ink); border-color: transparent; box-shadow: 0 10px 24px -10px rgba(212, 245, 60, .7); }
.day.active .dw { color: rgba(16, 32, 10, .7); }
.day.closed { opacity: .4; }

.courts { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin: 10px 0 2px; }
.courts button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.courts button.active { background: var(--surface-2); color: var(--text); }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin-top: 14px; min-height: 120px; }
.slot {
  position: relative; border-radius: 16px; padding: 12px 12px 11px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); transition: transform .15s, border-color .2s, background .2s;
}
.slot .t { font-family: var(--display); font-size: 20px; font-weight: 700; }
.slot .s { font-size: 12px; color: var(--muted); margin-top: 1px; }
.slot.free:hover { border-color: rgba(212, 245, 60, .6); }
.slot.free:active { transform: scale(.97); }
.slot.mine { background: linear-gradient(140deg, var(--lime), #a8cf14); color: var(--lime-ink); border-color: transparent; }
.slot.mine .s { color: rgba(16, 32, 10, .75); }
.slot.taken, .slot.blocked { cursor: default; opacity: .45; background: repeating-linear-gradient(135deg, rgba(255,255,255,.04) 0 8px, transparent 8px 16px); }
.slot.past { display: none; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 34px 10px; border: 1px dashed var(--line); border-radius: 18px; }
.skeleton { border-radius: 16px; height: 62px; background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted); margin: 16px 0 0; }
.lg { width: 12px; height: 12px; border-radius: 4px; display: inline-block; margin-left: 6px; }
.lg:first-child { margin-left: 0; }
.lg-free { background: var(--surface-2); border: 1px solid var(--line); } .lg-mine { background: var(--lime); } .lg-taken { background: rgba(255, 255, 255, .12); }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 14, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 40; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: linear-gradient(180deg, #13244a, #0c1830); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(22px + var(--safe-b));
  transform: translateY(110%); visibility: hidden; transition: transform .35s cubic-bezier(.2, .8, .2, 1), visibility 0s .35s;
  box-shadow: 0 -30px 60px -20px rgba(0, 0, 0, .6);
}
.sheet.open { transform: none; visibility: visible; transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.grabber { width: 42px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .22); margin: 0 auto 16px; }
.sheet h3 { font-family: var(--display); font-size: 24px; margin: 0 0 4px; }
.sheet .sheet-sub { color: var(--muted); margin: 0 0 18px; }
.sheet-rows { display: grid; gap: 10px; margin-bottom: 20px; }
.sheet-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.sheet-row .ic { color: var(--lime); flex: 0 0 auto; }
.sheet-row b { display: block; font-size: 15px; } .sheet-row small { color: var(--muted); font-size: 13px; }
.sheet-actions { display: grid; gap: 10px; }

/* ---------- success ---------- */
.success { position: fixed; inset: 0; z-index: 50; background: radial-gradient(100% 70% at 50% 0%, #17398c, var(--bg) 70%); overflow-y: auto; animation: fade .25s both; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.success-inner { position: relative; max-width: 480px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top, 0px)) 20px calc(30px + var(--safe-b)); text-align: center; }
.success-inner .check-orb { margin: 0 auto 16px; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.success .ticket { text-align: left; margin: 8px 0 22px; }
.success-actions { display: grid; gap: 10px; }

/* ---------- toast & loader ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 140%); z-index: 60;
  background: #f3f6ff; color: #0b1424; font-weight: 600; font-size: 14px; padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6); transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s; max-width: calc(100% - 32px); text-align: center;
  visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
.toast.error { background: #ffdede; color: #5a0d0d; }
.loader { display: flex; gap: 8px; justify-content: center; padding: 30vh 0; }
.loader span { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); animation: dot 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; } .loader span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-12px); opacity: 1; } }

@media (min-width: 700px) {
  main { padding-top: 12px; }
  .slots { grid-template-columns: repeat(4, 1fr); }
}
