:root {
  --bg-gradient: linear-gradient(145deg, #090d16 0%, #151733 50%, #0a0d18 100%);
  --card-bg: rgba(18, 24, 43, 0.75);
  --card-border: rgba(255, 255, 255, 0.12);
  --table-bg: rgba(15, 20, 36, 0.9);
  --table-border: #242c47;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-purple: #a855f7;
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 50%, #a855f7 100%);
  --btn-green: #10b981;
  --btn-green-hover: #059669;
  --btn-orange: #f59e0b;
  --btn-orange-hover: #d97706;
  --btn-red: #ef4444;
  --btn-red-hover: #dc2626;
  --font-family: 'Plus Jakarta Sans', 'Battambang', sans-serif;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px 12px 32px 12px;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

/* Glow Decoration */
.glow-orb {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 120px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.25) 0%, rgba(6, 182, 212, 0.15) 50%, transparent 80%);
  filter: blur(40px);
  pointer-events: none;
  z-index: 0;
}

/* Header */
.app-header {
  text-align: center;
  position: relative;
  z-index: 1;
  padding: 6px 0 2px 0;
}

.app-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  text-shadow: 0 2px 15px rgba(255, 255, 255, 0.25);
}

.app-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Card */
.settings-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 1;
}

.card-header {
  margin-bottom: 12px;
}

.card-legend {
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--table-border);
  padding-bottom: 4px;
}

.tab-btn {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--table-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  background: #1e293b;
  color: var(--accent-cyan);
  border-color: #38bdf8;
  border-bottom-color: transparent;
  box-shadow: 0 -3px 12px rgba(56, 189, 248, 0.15);
}

.tab-btn:hover:not(.active) {
  background: rgba(30, 41, 59, 0.7);
  color: #e2e8f0;
}

/* Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

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

/* Table Wrapper */
.table-wrapper {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--table-border);
  border-radius: var(--radius-md);
  background: var(--table-bg);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
}

.table-wrapper::-webkit-scrollbar {
  width: 6px;
}
.table-wrapper::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.rules-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.rules-table th {
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 700;
  padding: 10px 8px;
  border-bottom: 1px solid var(--table-border);
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: center;
}

.rules-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rules-table tr:hover {
  background: rgba(56, 189, 248, 0.04);
}

.table-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  text-align: center;
}

.table-input:focus {
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.btn-del-row {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-del-row:hover {
  color: var(--btn-red);
  background: rgba(239, 68, 68, 0.15);
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.action-mini-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px dashed var(--accent-cyan);
  color: var(--accent-cyan);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.action-mini-btn:hover {
  background: rgba(56, 189, 248, 0.15);
  transform: translateY(-1px);
}

/* Toolbar Buttons */
.toolbar-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.btn-green {
  background: var(--btn-green);
}
.btn-green:hover {
  background: var(--btn-green-hover);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.btn-orange {
  background: var(--btn-orange);
}
.btn-orange:hover {
  background: var(--btn-orange-hover);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}

.btn-red {
  background: var(--btn-red);
}
.btn-red:hover {
  background: var(--btn-red-hover);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.35);
}

/* Save Glow Button */
.save-section {
  margin-top: 4px;
}

.btn-save-glow {
  width: 100%;
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4), 0 0 15px rgba(168, 85, 247, 0.3);
  position: relative;
  overflow: hidden;
}

.btn-save-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.55), 0 0 20px rgba(168, 85, 247, 0.45);
}

.btn-save-glow:active {
  transform: scale(0.98);
}

/* Tip & Footer */
.app-footer {
  margin-top: 4px;
}

.tip-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tip-icon {
  font-size: 18px;
}

.tip-text {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--accent-cyan);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
