:root {
  font-family: "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
  line-height: 1.5;
  color: #e2e8f0;
  background-color: #0b1220;
  --background-gradient: linear-gradient(180deg, #050816 0%, #0b1220 35%, #111c2f 100%);
  --bg-surface: rgba(19, 29, 48, 0.95);
  --bg-surface-strong: rgba(22, 32, 53, 1);
  --border-soft: rgba(103, 130, 172, 0.35);
  --border-strong: rgba(96, 165, 250, 0.45);
  --shadow-soft: rgba(8, 19, 40, 0.55);
  --shadow-strong: rgba(99, 102, 241, 0.4);
  --text-primary: #e7ecff;
  --text-muted: #b6c2e5;
  --accent: linear-gradient(135deg, #8576ff 0%, #60a5fa 100%);
  --accent-secondary: rgba(30, 41, 59, 0.9);
  --accent-hover: #0f172a;
  --input-bg: rgba(13, 23, 39, 0.95);
  --input-border: rgba(99, 102, 241, 0.35);
  --input-focus-ring: rgba(99, 102, 241, 0.45);
  --notice-bg: rgba(79, 70, 229, 0.15);
  --notice-text: #c7d2fe;
  --error-bg: rgba(239, 68, 68, 0.18);
  --error-text: #fecaca;
  --success-bg: rgba(34, 197, 94, 0.18);
  --success-text: #bbf7d0;
  --table-head-bg: rgba(38, 51, 80, 0.9);
  --table-hover-bg: rgba(42, 56, 88, 0.55);
  --badge-bg: rgba(99, 102, 241, 0.22);
  --badge-text: #dbeafe;
  --badge-icon-bg: rgba(15, 23, 42, 0.65);
  --shop-item-bg: rgba(17, 24, 39, 0.65);
  --shop-item-enabled-bg: rgba(59, 130, 246, 0.22);
  --shop-item-enabled-border: rgba(129, 140, 248, 0.55);
}

:root[data-theme="light"] {
  color: #1f2933;
  background-color: #f7fafc;
  --background-gradient: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 40%, #e2e8f0 100%);
  --bg-surface: #ffffff;
  --bg-surface-strong: #ffffff;
  --border-soft: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(96, 165, 250, 0.45);
  --shadow-soft: rgba(15, 23, 42, 0.08);
  --shadow-strong: rgba(99, 102, 241, 0.22);
  --text-primary: #0f172a;
  --text-muted: #475569;
  --accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-secondary: #e2e8f0;
  --accent-hover: #cbd5e1;
  --input-bg: #ffffff;
  --input-border: rgba(148, 163, 184, 0.5);
  --input-focus-ring: rgba(99, 102, 241, 0.25);
  --notice-bg: rgba(129, 140, 248, 0.15);
  --notice-text: #312e81;
  --error-bg: rgba(248, 113, 113, 0.12);
  --error-text: #991b1b;
  --success-bg: rgba(74, 222, 128, 0.12);
  --success-text: #166534;
  --table-head-bg: #e2e8f0;
  --table-hover-bg: #f1f5f9;
  --badge-bg: rgba(99, 102, 241, 0.18);
  --badge-text: #4338ca;
  --badge-icon-bg: #eef2ff;
  --shop-item-bg: rgba(248, 250, 252, 0.95);
  --shop-item-enabled-bg: rgba(219, 234, 254, 0.85);
  --shop-item-enabled-border: rgba(59, 130, 246, 0.45);
}

body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  background: var(--background-gradient);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

main {
  max-width: 1200px;
  width: 100%;
  padding: 36px 24px 120px 24px;
  box-sizing: border-box;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--accent-secondary);
  color: var(--text-primary);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.theme-toggle span {
  font-size: 0.9rem;
  font-weight: 600;
}

details.section-card {
  background: var(--bg-surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px var(--shadow-soft);
  margin-bottom: 28px;
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.3s ease;
}

details.section-card[open] {
  border-color: var(--border-strong);
  box-shadow: 0 26px 70px var(--shadow-strong);
}

details.section-card summary {
  list-style: none;
  cursor: pointer;
  padding: 22px 28px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

details.section-card summary:hover {
  color: #fafcff;
}

details.section-card summary::-webkit-details-marker {
  display: none;
}

details.section-card summary::after {
  content: '';
  width: 12px;
  height: 12px;
  border-right: 2px solid #99a9ff;
  border-bottom: 2px solid #99a9ff;
  transform: rotate(45deg);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

details.section-card[open] summary::after {
  transform: rotate(-135deg);
  border-color: #c7d2fe;
}

.section-body {
  padding: 0 28px 28px 28px;
}

details.section-card[open] .section-body {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  margin-top: 10px;
}

summary h2 {
  margin: 0;
}

label {
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 10px 14px;
  box-sizing: border-box;
  font-size: 0.95rem;
  background-color: var(--input-bg);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px var(--input-focus-ring);
  background-color: rgba(21, 32, 53, 0.95);
}

textarea {
  min-height: 160px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
  color: #f8fafc;
  background: var(--accent);
  box-shadow: 0 16px 36px var(--shadow-strong);
}

button:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

button.secondary {
  background: var(--accent-secondary);
  color: var(--text-primary);
  box-shadow: none;
}

button.secondary:hover {
  background: var(--accent-hover);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.field-group {
  display: grid;
  gap: 16px;
}

.field-group.columns {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.notice {
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background-color: var(--notice-bg);
  color: var(--notice-text);
  border: 1px solid rgba(129, 140, 248, 0.4);
}

.error {
  background-color: var(--error-bg);
  color: var(--error-text);
  border-color: rgba(248, 113, 113, 0.4);
}

.success {
  background-color: var(--success-bg);
  color: var(--success-text);
  border-color: rgba(74, 222, 128, 0.4);
}

#item-list,
#stage-list,
#shop-panel,
#solution-panel,
#record-panel {
  margin-top: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.item-card,
.stage-card,
.solution-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  padding: 18px;
  background: var(--bg-surface-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 14px 32px rgba(10, 20, 40, 0.35);
}

.item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-header img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  background-color: var(--badge-icon-bg);
}

.item-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  color: var(--text-primary);
}

thead tr {
  background: var(--table-head-bg);
}

td,
th {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  text-align: left;
}

tbody tr:hover {
  background: var(--table-hover-bg);
}

.stage-drops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--badge-bg);
  color: var(--badge-text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.badge img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--badge-icon-bg);
}

table input[type="checkbox"] {
  transform: scale(1.1);
}

.shop-items {
  border-top: 1px dashed rgba(148, 163, 184, 0.35);
  padding-top: 14px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shop-items h4 {
  margin: 12px 0 4px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1200px) {
  .shop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.shop-item {
  padding: 12px;
  border-radius: 12px;
  background-color: var(--shop-item-bg);
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.shop-item.enabled {
  border-color: var(--shop-item-enabled-border);
  background: var(--shop-item-enabled-bg);
}

.shop-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.shop-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-total {
  font-size: 0.88rem;
  color: var(--text-primary);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.toggle-clickable {
  cursor: pointer;
  user-select: none;
}

.stage-row {
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.stage-row.active {
  background: rgba(59, 130, 246, 0.18);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.35);
}

.stage-row.active:hover {
  background: rgba(59, 130, 246, 0.26);
}

.log-row {
  display: grid;
  grid-template-columns: 1fr 120px 180px 70px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text-primary);
}

.log-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

#log-entries .log-row {
  grid-template-columns: 1fr 80px 160px 60px;
  padding: 8px 0;
}

#log-entries .log-row span:nth-child(2),
#log-entries .log-row span:nth-child(3) {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#log-entries .log-row button {
  justify-self: end;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.35);
  font-size: 0.85rem;
}

#log-entries .log-row button:hover {
  background: rgba(239, 68, 68, 0.28);
}

@media (max-width: 720px) {
  .log-row {
    grid-template-columns: 1fr;
    padding: 8px 0;
  }

  #log-entries .log-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  #log-entries .log-row button {
    justify-self: flex-start;
  }
}

@media (max-width: 768px) {
  main {
    padding: 28px 16px 80px 16px;
  }

  details.section-card summary {
    padding: 20px;
  }

  .section-body {
    padding: 0 20px 22px 20px;
  }
}
