:root {
  --bg: #070b14;
  --card: rgba(18, 24, 40, 0.72);
  --card-border: rgba(129, 140, 248, 0.25);
  --text: #edf2ff;
  --muted: #a6b3d1;
  --accent: #7c9bff;
  --accent-2: #5eead4;
  --danger: #f43f5e;
  --success: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 20%, #18213a 0%, #070b14 40%),
    radial-gradient(circle at 90% 10%, #1f2542 0%, #070b14 45%),
    #070b14;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
}
.bg-glow-1 { background: rgba(124, 155, 255, 0.35); top: -40px; left: -40px; }
.bg-glow-2 { background: rgba(94, 234, 212, 0.28); bottom: -40px; right: -40px; }

.container {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: 10px;
}

.glass {
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.32);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  margin-bottom: 8px;
  gap: 8px;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.topbar h1 { margin: 0; font-size: 20px; line-height: 1.1; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { width: auto; display:flex; gap:8px; }
.top-actions button { width: auto; white-space: nowrap; margin: 0; }

.card {
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
}

h2, h3 { margin: 0 0 6px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

input, select, button {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  margin: 4px 0;
  font-size: 14px;
}

input, select {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
}

button {
  border: none;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #95aafc);
  color: #08122f;
}

button.ghost {
  background: rgba(30, 41, 59, 0.9);
  color: #dbe7ff;
}

button.danger { background: linear-gradient(135deg, #f43f5e, #fb7185); color: #fff; }
button.success { background: linear-gradient(135deg, #22c55e, #4ade80); color: #0b2f17; }

.row { display: flex; gap: 6px; }
.row > * { flex: 1; }

.bottom-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
}

.bottom-nav button {
  margin: 0;
  padding: 10px 8px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  min-height: 44px;
  white-space: normal;
}

.bottom-nav button.active-tab {
  background: linear-gradient(135deg, var(--accent), #95aafc);
  color: #08122f;
}

#parentView {
  padding-bottom: 92px;
}

.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0; }
.big { font-size: 28px; margin: 6px 0; }

.child-list { margin-top: 6px; }
.child-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(124, 155, 255, 0.18);
  color: #d8e4ff;
  font-size: 12px;
}
.active-tag {
  background: rgba(34, 197, 94, 0.25);
  color: #b9ffd0;
}
.selectable-row {
  cursor: pointer;
}

.swipe-card-wrap {
  margin-top: 10px;
}

.swipe-card {
  margin-top: 0;
  padding: 24px 18px;
  text-align: center;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.3);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  user-select: none;
  touch-action: pan-y;
  position: relative;
  overflow: hidden;
}
.swipe-card::before,
.swipe-card::after {
  content: '';
  position: absolute;
  top: 0;
  width: 28%;
  height: 100%;
  pointer-events: none;
}
.swipe-card::before {
  left: 0;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.42), rgba(239, 68, 68, 0));
}
.swipe-card::after {
  right: 0;
  background: linear-gradient(270deg, rgba(34, 197, 94, 0.42), rgba(34, 197, 94, 0));
}
.swipe-side-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  user-select: none;
  pointer-events: none;
}
.swipe-side-label.left { left: 10px; color: #fecaca; }
.swipe-side-label.right { right: 10px; color: #bbf7d0; }

.swipe-card.active { box-shadow: 0 15px 35px rgba(124, 155, 255, 0.25); }
.swipe-card.vote-plus { transform: translateX(24px) rotate(2deg); }
.swipe-card.vote-minus { transform: translateX(-24px) rotate(-2deg); }

.avatar { font-size: 52px; margin-bottom: 4px; }
.swipe-name { font-size: 18px; font-weight: 700; }
.points { font-size: 24px; margin: 8px 0; }

/* Keep swipe section full-size */
#swipePanel {
  padding: 14px;
  margin-bottom: 12px;
  border-radius: 16px;
}
#swipePanel h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
#swipePanel button {
  padding: 12px;
  font-size: 15px;
  border-radius: 12px;
  margin: 6px 0;
}
#swipePanel .hint {
  font-size: 13px;
  margin-top: 6px;
}
#swipePanel .row {
  gap: 8px;
}

.swipe-history {
  margin-top: 8px;
}
.compact-inner {
  padding: 8px;
  margin-bottom: 0;
}
.date-group {
  margin: 8px 0 4px;
}
.date-label {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px;
}
.history-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 6px;
}
.history-time {
  font-size: 11px;
  color: var(--muted);
}
.history-meta {
  font-size: 12px;
}
.history-delta {
  font-weight: 800;
  font-size: 13px;
}
.history-delta.plus { color: #4ade80; }
.history-delta.minus { color: #fb7185; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 12px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 160ms ease;
}
.modal.modal-open { opacity: 1; }
.modal-content {
  width: min(520px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  border-radius: 14px;
  padding: 12px;
  box-sizing: border-box;
  margin: 0 auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.modal-head button { width: auto; margin: 0; padding: 6px 10px; }
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.tile {
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}
.tile-emoji {
  font-size: 22px;
  line-height: 1;
}
.tile:hover { border-color: var(--accent); }
.small-btn {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
}

@media (max-width: 460px) {
  .row { flex-direction: column; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
