:root {
  --bg: #0d0b1a;
  --bg2: #151129;
  --panel: #1a1730;
  --panel2: #221d3d;
  --line: #2c2650;
  --text: #ece8f6;
  --muted: #9b94b8;
  --gold: #d4af37;
  --gold-soft: #e6c85c;
  --violet: #a78bfa;
  --violet-2: #7c5cff;
  --green: #57c785;
  --red: #ff7b7b;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, rgba(13,11,26,.98) 60%, rgba(13,11,26,0));
  display: flex;
  align-items: center;
  gap: 10px;
}

#topbar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .3px;
  color: var(--text);
}
#topbar .brand .star { color: var(--gold); }

#topbar .spacer { flex: 1; }

.balance {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  color: var(--gold-soft);
}
.balance .sym { color: var(--gold); }

#content { flex: 1; padding: 4px 16px 24px; }

#bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: rgba(21,17,41,.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
#bottomnav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 4px 12px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
#bottomnav button .ic { font-size: 20px; }
#bottomnav button.active { color: var(--gold-soft); }

h1, h2, h3 { margin: 0 0 8px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #14101f;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn.ghost {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.violet { background: linear-gradient(135deg, var(--violet), var(--violet-2)); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

.chip {
  display: inline-block;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
}

.grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}
.grid .cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.grid .cell .ic { font-size: 24px; }
.grid .cell .t { font-size: 12px; color: var(--text); }
.grid .cell .p { font-size: 11px; color: var(--muted); }

.card-of-day {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.card-of-day img {
  width: 92px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.card-of-day .flip { filter: brightness(.9); }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item .lead { font-weight: 600; font-size: 14.5px; }
.list-item .sub { color: var(--muted); font-size: 12.5px; }
.list-item .price { color: var(--gold-soft); font-weight: 700; white-space: nowrap; }

.badge-lock { font-size: 11px; color: var(--gold-soft); }

.spread-card {
  width: 92px;
  height: 150px;
  margin: 6px;
  border-radius: 12px;
  position: relative;
  perspective: 800px;
  cursor: pointer;
}
.spread-card .inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .6s;
  transform-style: preserve-3d;
}
.spread-card.flipped .inner { transform: rotateY(180deg); }
.spread-card .face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.spread-card .face img { width: 100%; height: 100%; object-fit: cover; }
.spread-card .face.back { background: #241d44; }
.spread-card .face.front { transform: rotateY(180deg); }
.spread-card .pos {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.72); color: #fff;
  font-size: 10.5px; padding: 4px 6px; text-align: center;
}
.spread-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }

.chat-log { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--violet-2); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }

.chat-input { position: sticky; bottom: 72px; display: flex; gap: 8px; margin-top: 12px; }
.chat-input input {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; color: var(--text); font-size: 15px;
}
.chat-input input:focus { outline: none; border-color: var(--violet-2); }
.chat-input button { width: 52px; border-radius: 14px; border: none; background: linear-gradient(135deg, var(--violet), var(--violet-2)); color: #fff; font-size: 20px; cursor: pointer; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: 15px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--violet-2); }

.switch { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.switch input { width: 20px; height: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #241d44; border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 99;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 90%;
}

.astro-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.astro-row:last-child { border-bottom: none; }
.astro-row .v { color: var(--gold-soft); font-weight: 600; }

.hero-title { font-size: 26px; font-weight: 800; line-height: 1.15; }
.hero-sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.stars { color: var(--gold-soft); letter-spacing: 1px; }

.loading { text-align: center; color: var(--muted); padding: 40px 0; }

@media (max-width: 360px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
