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

:root {
  --bg: #0b0b0f;
  --surface: #0f1015;
  --card: #13141b;
  --card-soft: #171922;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f2f7;
  --muted: rgba(242, 242, 247, 0.62);
  --primary: #7c3aed;
  --primary-strong: #5b21b6;
  --primary-soft: rgba(124, 58, 237, 0.18);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
}

body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: radial-gradient(circle at top, rgba(124, 58, 237, 0.18), transparent 45%),
    linear-gradient(135deg, #0a0a0d 0%, #10121a 55%, #0a0a0d 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 28px 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(19, 20, 27, 0.95), rgba(14, 15, 20, 0.95));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  height: 54px;
  width: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5b21b6, #7c3aed);
  color: #f5f3ff;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.brand-text p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  height: 36px;
  width: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.clock {
  text-align: right;
}

.clock-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.clock-time {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.content {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 18px;
}

.primary {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.group-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.card {
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(19, 20, 27, 0.95), rgba(14, 15, 20, 0.95));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 18px 20px 0;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.card-header p {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.ocr-card .ocr-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ocr-actions {
  display: flex;
  gap: 12px;
}

.ocr-dropzone {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  padding: 18px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  align-items: center;
  gap: 14px;
}

.ocr-dropzone.dragover {
  border-color: rgba(124, 58, 237, 0.7);
  background: rgba(124, 58, 237, 0.08);
}

.ocr-dropzone .icon {
  height: 36px;
  width: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--muted);
}

.ocr-dropzone .text h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.ocr-dropzone .text p {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.btn {
  border: none;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  color: #f5f3ff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 6px 0;
  text-align: left;
  border: none;
}

.btn-ghost:hover {
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.section-header p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.section-card {
  padding: 14px 16px 16px;
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.section-toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  margin-bottom: 12px;
}

.section-toggle .chevron {
  font-size: 1rem;
  margin-top: 2px;
  color: var(--muted);
}

.section-toggle > span:not(.chevron):not(.section-count) {
  display: flex;
  flex-direction: column;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.section-count {
  margin-left: auto;
  background: rgba(124, 58, 237, 0.2);
  color: #ddd6fe;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.boss-btn small,
.fixed-boss-btn small {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.boss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.boss-btn,
.fixed-boss-btn {
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.boss-btn::before,
.fixed-boss-btn::before {
  content: "⏱";
  height: 34px;
  width: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--muted);
  margin-right: 10px;
}

.boss-btn span,
.fixed-boss-btn span {
  flex: 1;
  text-align: left;
}

.boss-btn::after,
.fixed-boss-btn::after {
  content: "+";
  height: 32px;
  width: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--muted);
}

.boss-btn:hover,
.fixed-boss-btn:hover {
  border-color: rgba(124, 58, 237, 0.55);
  transform: translateY(-1px);
  background: rgba(124, 58, 237, 0.1);
}

.boss-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  background: rgba(255, 255, 255, 0.02);
}

.fixed-boss-btn.active {
  background: var(--primary-soft);
  border-color: rgba(124, 58, 237, 0.6);
  color: #ddd6fe;
}

.fixed-boss-btn.active::after {
  content: "✓";
  background: rgba(34, 197, 94, 0.25);
  color: #86efac;
  font-size: 16px;
}

.settings-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-modal-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  max-height: 60vh;
  overflow-y: auto;
}

.settings-section {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-section h3 {
  font-size: 0.95rem;
}

.input {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.shortcut-input {
  cursor: pointer;
}

.shortcut-input.capturing {
  border-color: rgba(124, 58, 237, 0.6);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.hidden {
  display: none;
}

.setting-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.setting-value {
  font-weight: 700;
  color: var(--text);
}

.select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.9rem;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.position-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.position-btn.active {
  background: rgba(124, 58, 237, 0.2);
  color: #ddd6fe;
  border-color: rgba(124, 58, 237, 0.6);
}

.range {
  width: 100%;
  accent-color: var(--primary);
}

.toggle-block {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.switch input:checked + .slider {
  background: rgba(45, 212, 191, 0.6);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

.tracking-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tracking-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
}

.tracking-item {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(18, 20, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.tracking-item.alert {
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.tracking-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tracking-name {
  font-weight: 700;
  font-size: 1rem;
}

.tracking-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

.tracking-meta {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.tracking-countdown {
  margin-top: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  text-align: center;
  background: rgba(124, 58, 237, 0.18);
  color: #ddd6fe;
}

.tracking-countdown.warning {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.tracking-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.action-btn {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
}

.action-btn.danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.action-btn.primary {
  border-color: rgba(45, 212, 191, 0.4);
  color: #99f6e4;
}

.action-btn.warning {
  border-color: rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #121a24;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow);
  max-height: 85vh;
  overflow: hidden;
}

.modal-wide {
  width: min(700px, 92vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.1rem;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-group input {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.form-group input[readonly] {
  opacity: 0.6;
}

.ocr-status .loading,
.ocr-status .success,
.ocr-status .error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.ocr-status .loading {
  background: rgba(124, 58, 237, 0.18);
  color: #ddd6fe;
}

.ocr-status .success {
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

.ocr-status .error {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.ocr-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
}

.ocr-item-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

.ocr-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ocr-detail-row .label {
  min-width: 70px;
  color: var(--muted);
}

.ocr-detail-row .value {
  color: var(--text);
  opacity: 0.8;
}

.ocr-result-item {
  background: rgba(15, 20, 28, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 12px;
}

.ocr-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ocr-index {
  background: rgba(45, 212, 191, 0.2);
  color: #99f6e4;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.ocr-boss-name,
.ocr-death-time,
.ocr-respawn-time {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 8px 10px;
}

.topbar-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.status-label {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.status-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 0.8rem;
  color: var(--muted);
}

.input {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  gap: 8px;
}

.helper-text {
  font-size: 0.8rem;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-item {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
  color: var(--text);
}

.group-item:hover {
  border-color: rgba(124, 58, 237, 0.6);
  transform: translateY(-1px);
}

.group-item.active {
  border-color: rgba(124, 58, 237, 0.9);
  background: rgba(124, 58, 237, 0.18);
}

.group-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.group-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.invite-display {
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.ad-card .ad-slot {
  margin: 16px 20px 20px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  min-height: 160px;
}

.ad-top {
  margin-top: 18px;
}

.ad-card-top .ad-slot {
  min-height: 90px;
}

.ad-card-left .ad-slot,
.ad-card-right .ad-slot {
  min-height: 250px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hidden-input {
  display: none;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.6);
  border-radius: 999px;
}

@media (max-width: 1080px) {
  .content {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .group-sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .tracking-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
