:root {
  --bg: #0b0b10;
  --card: #141421;
  --card-2: #1a1a2a;
  --muted: #a0a3ad;
  --text: #f3f4f8;
  --accent: #8a8fff;
  --accent-2: #34c759;
  --warn: #ffcc00;
  --bad: #ff3b30;
  --border: rgba(255,255,255,.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 50% -160px, rgba(138,143,255,.22), transparent),
    radial-gradient(700px 420px at 110% 15%, rgba(52,199,89,.12), transparent),
    #0a0a12;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: rgba(10,10,18,.72);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: saturate(180%) blur(14px);
}

.wrap {
  width: min(940px, 100%);
  margin: 0 auto;
  padding: 12px 16px;
}

.title {
  font-weight: 850;
  font-size: 22px;
  letter-spacing: .2px;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.01)), var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 22px 70px rgba(0,0,0,.18);
}

.hero-card {
  padding: 18px;
  margin-top: 12px;
  overflow: hidden;
}

.bocard-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.bocard-button {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 1.62 / 1;
  padding: 24px;
  border: 0;
  border-radius: 28px;
  overflow: hidden;
  color: #fff;
  text-align: left;
  cursor: pointer;
  background:
    linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.02)),
    radial-gradient(260px 160px at 18% 12%, rgba(255,255,255,.24), transparent),
    linear-gradient(135deg, #2c2e78 0%, #4c44b7 42%, #168e73 100%);
  box-shadow: 0 24px 55px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.22);
  transform: translateZ(0);
  transition: transform 360ms ease, box-shadow 360ms ease, filter 220ms ease;
}

.bocard-button:disabled {
  cursor: default;
}

.bocard-button:hover,
.bocard-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 28px 62px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.24);
  outline: none;
}

.wallet-shell.tap-disabled .bocard-button:hover,
.wallet-shell.tap-disabled .bocard-button:focus-visible {
  transform: none;
  box-shadow: 0 24px 55px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.22);
}

.wallet-shell.tap-disabled .tap-status {
  color: var(--muted);
}

.wallet-shell.tap-disabled .tap-icon {
  color: var(--muted);
}

.bocard-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 20%, rgba(255,255,255,.12) 42%, transparent 64%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 28px);
  opacity: .42;
  pointer-events: none;
}

.card-glow {
  position: absolute;
  width: 210px;
  height: 210px;
  right: -70px;
  top: -80px;
  border-radius: 50%;
  background: rgba(52,199,89,.34);
  filter: blur(12px);
}

.card-topline,
.card-brand,
.card-number,
.card-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
}

.card-topline {
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.card-chip {
  width: 44px;
  height: 34px;
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.25), rgba(255,255,255,.04)),
    #d7c178;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}

.card-brand {
  margin-top: 28px;
  font-size: clamp(34px, 9vw, 54px);
  font-weight: 900;
  letter-spacing: -.9px;
}

.card-number {
  margin-top: 16px;
  color: rgba(255,255,255,.82);
  font-weight: 750;
  letter-spacing: 2.2px;
}

.card-bottom {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 22px;
  justify-content: space-between;
  color: rgba(255,255,255,.84);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .45px;
}

.tap-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 750;
  transition: color 180ms ease, transform 240ms ease;
}

.tap-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
}

.tap-status.ok { color: var(--accent-2); }
.tap-status.error { color: var(--bad); }
.tap-status.ok .tap-icon {
  color: #0a1a10;
  background: var(--accent-2);
}
.tap-status.error .tap-icon {
  color: #fff;
  background: rgba(255,59,48,.8);
}

.wallet-details {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  transition: opacity 240ms ease, transform 300ms ease, max-height 360ms ease, margin 300ms ease;
  max-height: 1300px;
}

.wallet-shell.is-tapping .bocard-button {
  transform: scale(1.08);
  box-shadow: 0 36px 86px rgba(0,0,0,.5), 0 0 0 1px rgba(138,143,255,.22);
}

.wallet-shell.is-tapping .wallet-details {
  opacity: 0;
  pointer-events: none;
  transform: translateY(22px);
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
}

.bocard-button.denied {
  animation: shake 420ms ease;
  filter: saturate(.65);
}

.bocard-button.paid {
  animation: paidPulse 640ms ease;
}

.balance-grid {
  display: grid;
  gap: 12px;
}

@media (min-width: 720px) {
  .balance-grid {
    grid-template-columns: 1.15fr .85fr;
  }
}

.balance-card,
.last-card,
.add-value-card,
.history-card {
  padding: 16px;
}

.section-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .45px;
  text-transform: uppercase;
}

.balance-value {
  margin-top: 8px;
  font-size: clamp(42px, 12vw, 60px);
  line-height: .95;
  font-weight: 900;
  letter-spacing: -1.4px;
}

.balance-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meter {
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.08);
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 360ms ease;
}

.last-station {
  margin-top: 10px;
  font-size: 22px;
  font-weight: 850;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-size: 20px;
  letter-spacing: -.2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  background: rgba(255,255,255,.05);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.amount-grid button,
.confirm-button {
  min-height: 48px;
  border-radius: 15px;
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text);
  background: rgba(255,255,255,.06);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.amount-grid button.active {
  border-color: rgba(138,143,255,.72);
  background: linear-gradient(180deg, rgba(138,143,255,.34), rgba(138,143,255,.16));
  box-shadow: 0 0 0 1px rgba(138,143,255,.18);
}

.confirm-button {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--accent), #6f78ff);
  color: #fff;
}

.confirm-button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.inline-alert {
  min-height: 20px;
  margin-top: 10px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 750;
}

.inline-alert.error {
  color: var(--bad);
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  padding: 11px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.035);
}

.station-line {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.station-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.line-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.line-badges img {
  width: 21px;
  height: 21px;
  object-fit: contain;
  display: block;
}

.history-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.history-charge-id {
  margin-top: 3px;
  color: rgba(160,163,173,.78);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .2px;
}

.fare-pill {
  color: var(--accent-2);
  font-weight: 900;
  font-size: 13px;
  white-space: nowrap;
}

.empty-history {
  min-height: 92px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed rgba(255,255,255,.13);
  border-radius: 18px;
}

.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,.52);
  backdrop-filter: blur(12px);
}

.payment-panel {
  width: min(320px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 22px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03)), #151522;
  box-shadow: 0 28px 90px rgba(0,0,0,.46);
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.14);
  border-top-color: var(--accent);
  animation: spin 850ms linear infinite;
}

.payment-check {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent-2);
  position: relative;
  animation: pop 260ms ease;
}

.payment-check::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 13px;
  width: 16px;
  height: 25px;
  border: solid #07130b;
  border-width: 0 5px 5px 0;
  transform: rotate(45deg);
}

.payment-panel strong {
  font-size: 20px;
}

.payment-panel span {
  color: var(--muted);
  font-size: 13px;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 4px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(180,180,180,0.20);
  backdrop-filter: saturate(180%) blur(14px);
}

.tabbar a {
  text-decoration: none;
  color: var(--muted);
  text-align: center;
}

.tabbar .item {
  display: grid;
  gap: 5px;
  justify-items: center;
  font-size: 11px;
  font-weight: 650;
}

.tabbar .item img {
  width: 25px;
  height: 25px;
  display: block;
  opacity: .8;
  filter: grayscale(100%);
}

.tabbar a.active {
  color: var(--accent);
}

.tabbar a.active img {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(61%) sepia(39%) saturate(1470%) hue-rotate(203deg) brightness(101%) contrast(101%);
}

.shake {
  animation: shake 420ms ease;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  from { transform: scale(.72); opacity: .4; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes paidPulse {
  0%, 100% { box-shadow: 0 24px 55px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.22); }
  50% { box-shadow: 0 28px 70px rgba(52,199,89,.30), 0 0 0 5px rgba(52,199,89,.12), inset 0 1px 0 rgba(255,255,255,.24); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 420px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .hero-card { padding: 12px; }
  .bocard-button { border-radius: 24px; padding: 20px; }
  .card-bottom { left: 20px; right: 20px; }
  .amount-grid { grid-template-columns: repeat(2, 1fr); }
  .tabbar .item { font-size: 10px; }
  .tabbar .item img { width: 24px; height: 24px; }
}
