:root {
  --bg-color: #0b0f17;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(26, 34, 52, 0.95);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 229, 255, 0.35);
  --primary: #00e5ff;
  --primary-hover: #33ebff;
  --accent: #8b5cf6;
  --success: #10b981;
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 24px 16px;
}

/* Background Ambient Glows */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.16;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: #00e5ff;
  top: -150px;
  right: -100px;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: #7c3aed;
  bottom: -200px;
  left: -150px;
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #00e5ff 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
}

.brand h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffffff 40%, #00e5ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

/* Reset Timer Badge */
.reset-timer-badge {
  background: linear-gradient(145deg, rgba(26, 34, 52, 0.95), rgba(13, 17, 26, 0.95));
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 12px 20px;
  border-radius: 14px;
  text-align: right;
  box-shadow: 0 0 25px rgba(0, 229, 255, 0.12);
}

.timer-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #38bdf8;
  font-weight: 700;
}

.timer-countdown {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.05em;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
  margin: 2px 0;
}

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

/* Rule Banner */
.rule-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.12), rgba(139, 92, 246, 0.12));
  border: 1px solid rgba(14, 165, 233, 0.28);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  color: #e2e8f0;
  line-height: 1.5;
}

.rule-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

/* Daily Progress Section */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.progress-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.progress-stats {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 800;
  color: #38bdf8;
  margin-left: 6px;
}

.total-rubox-pool {
  font-size: 0.9rem;
  color: #94a3b8;
}

.total-rubox-pool strong {
  color: #facc15;
  font-family: var(--font-mono);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00e5ff 0%, #10b981 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Actions Row */
.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-buttons {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  color: #fff;
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: var(--font-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff 0%, #0099ff 100%);
  color: #04111d;
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #33ebff 0%, #1aa3ff 100%);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.45);
  transform: translateY(-1px);
}

/* Codes Grid */
.codes-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
}

.hint-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.codes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

/* Code Card */
.code-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.code-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  opacity: 0.8;
}

.code-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 229, 255, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.code-card.card-used {
  opacity: 0.6;
  background: rgba(15, 20, 30, 0.7);
}

.code-card.card-used::before {
  background: #64748b;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-index {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-available {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-used {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.code-value-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: #facc15;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
}

.code-value.max-reward {
  color: #f43f5e;
  text-shadow: 0 0 15px rgba(244, 63, 94, 0.5);
}

.max-tag {
  font-size: 0.65rem;
  background: #f43f5e;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  margin-left: 6px;
  letter-spacing: 0.05em;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #070a10;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
}

.code-box:hover {
  border-color: var(--primary);
  background: #0c121d;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-card-copy {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00e5ff;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-card-copy:hover {
  background: #00e5ff;
  color: #04111d;
}

.btn-card-toggle {
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-main);
}

.btn-card-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.card-used .btn-card-toggle {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid rgba(0, 229, 255, 0.3);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease, fadeOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* Responsive */
@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .reset-timer-badge {
    text-align: left;
  }
  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-buttons {
    width: 100%;
  }
  .filter-btn {
    flex: 1;
    text-align: center;
  }
  .utility-buttons .btn {
    width: 100%;
  }
  .codes-grid {
    grid-template-columns: 1fr;
  }
}
