:root {
  --bg-midnight: #120224;
  --bg-card: rgba(28, 10, 48, 0.85);
  --bg-card-hover: rgba(42, 16, 72, 0.9);
  --neon-magenta: #FF007F;
  --volt-lime: #76FF03;
  --sun-yellow: #FFE600;
  --electric-aqua: #00E5FF;
  --pure-white: #FFFFFF;
  --text-muted: #9E8BB5;
  --font-title: 'Cinzel', serif;
  --font-mono: 'Space Grotesk', monospace;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --header-height: 64px;
  --dock-height: 68px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-midnight);
  color: var(--pure-white);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  touch-action: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 50% 20%, #29084e 0%, #120224 85%);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

/* TOP HEADER */
.top-header {
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-bottom: 8px;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 0, 127, 0.25);
  z-index: 20;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-symbol {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  border: 1.5px solid var(--neon-magenta);
  box-shadow: 0 0 14px rgba(255, 0, 127, 0.6), inset 0 0 6px rgba(118, 255, 3, 0.3);
  transition: transform 0.25s ease;
}

.brand-symbol:hover {
  transform: scale(1.05) rotate(3deg);
}

.brand-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--neon-magenta), var(--sun-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--volt-lime);
  text-shadow: 0 0 8px rgba(118, 255, 3, 0.5);
}

.stat-balls {
  color: var(--sun-yellow);
  text-shadow: 0 0 8px rgba(255, 230, 0, 0.5);
}

.header-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--pure-white);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.header-action-btn:active {
  transform: scale(0.95);
  background: rgba(255, 0, 127, 0.2);
  border-color: var(--neon-magenta);
}

/* MAIN CONTENT VIEWPORT */
.viewport-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 10;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  z-index: 15;
}

/* BOTTOM NAVIGATION DOCK */
.bottom-dock {
  height: calc(var(--dock-height) + env(safe-area-inset-bottom, 0px));
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px)) 8px;
  z-index: 20;
}

.dock-tab {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.dock-tab .dock-glyph {
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.dock-tab .dock-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-family: var(--font-body);
}

.dock-tab.active {
  color: var(--volt-lime);
}

.dock-tab.active .dock-glyph {
  transform: translateY(-2px) scale(1.15);
  filter: drop-shadow(0 0 6px var(--volt-lime));
}

.dock-tab.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 24px;
  height: 3px;
  border-radius: 2px;
  background: var(--volt-lime);
  box-shadow: 0 0 8px var(--volt-lime);
}

/* TAB PANELS: RECORDS & SUNDAY FIESTA */
.scroll-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.panel-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--pure-white);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.panel-title span {
  color: var(--neon-magenta);
}

/* RECORDS LIST */
.record-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.record-row.rank-1 {
  border-color: rgba(255, 230, 0, 0.4);
  background: rgba(255, 230, 0, 0.06);
}

.record-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-rank {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
}

.rank-1 .record-rank {
  background: var(--sun-yellow);
  color: var(--bg-midnight);
}

.record-details {
  display: flex;
  flex-direction: column;
}

.record-name {
  font-weight: 600;
  color: var(--pure-white);
}

.record-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.record-score {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--volt-lime);
}

/* SUNDAY ALLOCATION MODULE */
.countdown-box {
  display: flex;
  justify-content: space-around;
  margin: 16px 0;
  background: rgba(18, 2, 36, 0.6);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(118, 255, 3, 0.2);
}

.countdown-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.countdown-digits {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--volt-lime);
}

.countdown-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ticket-ledger {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 14px 0;
}

.ticket-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.ticket-item.collected {
  background: rgba(255, 0, 127, 0.2);
  border: 1px solid var(--neon-magenta);
  color: var(--sun-yellow);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
}

.ticket-item .ticket-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
}

.claim-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(18, 2, 36, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--pure-white);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-input:focus {
  border-color: var(--electric-aqua);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--neon-magenta), #c40062);
  border: none;
  border-radius: 8px;
  color: var(--pure-white);
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(255, 0, 127, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(255, 0, 127, 0.6);
}

.status-alert {
  padding: 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  text-align: center;
  display: none;
}

.status-alert.success {
  display: block;
  background: rgba(118, 255, 3, 0.15);
  border: 1px solid var(--volt-lime);
  color: var(--volt-lime);
}

.status-alert.error {
  display: block;
  background: rgba(255, 0, 127, 0.15);
  border: 1px solid var(--neon-magenta);
  color: #ff80bf;
}
