:root {
  color-scheme: dark;
  --bg: #070916;
  --glass: rgba(12, 16, 30, 0.54);
  --glass-strong: rgba(17, 23, 39, 0.68);
  --text: #f3efe8;
  --muted: #c6bdca;
  --line: rgba(255, 255, 255, 0.18);
  --line-strong: rgba(248, 215, 146, 0.34);
  --primary: #d8b56b;
  --primary-dark: #f0d99c;
  --primary-soft: rgba(216, 181, 107, 0.17);
  --accent: #9dc7ff;
  --accent-soft: rgba(157, 199, 255, 0.18);
  --danger: #b42318;
  --danger-dark: #e15c50;
  --danger-soft: rgba(180, 35, 24, 0.14);
  --success-bg: rgba(25, 76, 63, 0.62);
  --success-line: rgba(154, 231, 195, 0.34);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 24px 58px rgba(0, 0, 0, 0.38);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(5, 7, 18, 0.92), rgba(9, 11, 24, 0.65) 42%, rgba(7, 8, 18, 0.86)),
    linear-gradient(180deg, rgba(7, 8, 16, 0.25), rgba(5, 7, 16, 0.84)),
    url("./assets/doremy-dream-bg.svg") center / cover fixed,
    var(--bg);
  color: var(--text);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 230, 167, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 230, 167, 0.04) 1px, transparent 1px);
  background-size: 96px 96px;
  mix-blend-mode: screen;
  pointer-events: none;
}

.shell {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  position: sticky;
  top: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
  width: max-content;
  max-width: 100%;
  margin-bottom: 28px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 16, 30, 0.52);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(22px) saturate(1.25);
}

.tab {
  min-width: 88px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.tab:hover,
.tab.active {
  background: rgba(15, 122, 107, 0.1);
  color: var(--primary-dark);
}

.tab.active {
  border-color: rgba(15, 122, 107, 0.22);
  box-shadow: 0 0 0 1px rgba(15, 122, 107, 0.08), 0 8px 22px rgba(15, 122, 107, 0.14);
}

.tab:hover {
  transform: translateY(-1px);
}

.heading {
  margin-bottom: 20px;
}

.compact-heading {
  margin-top: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 14em;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.06;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.muted,
.message {
  color: var(--muted);
}

.panel,
.notice,
.election-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.18);
}

.panel,
.notice {
  padding: 22px;
}

.panel {
  margin-bottom: 18px;
}

.notice {
  display: grid;
  gap: 6px;
  margin-bottom: 20px;
}

.notice code {
  font-size: 13px;
}

form {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 8px;
  color: #eee5d8;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 11, 22, 0.58);
  color: var(--text);
  font: inherit;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select,
input {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

select:focus,
input:focus,
textarea:focus {
  outline: 0;
  border-color: rgba(216, 181, 107, 0.74);
  background: rgba(12, 16, 30, 0.74);
  box-shadow: 0 0 0 4px var(--primary-soft), 0 8px 22px rgba(216, 181, 107, 0.12);
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: rgba(10, 14, 26, 0.58);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(20, 26, 42, 0.78);
  box-shadow: 0 10px 24px rgba(24, 40, 57, 0.12);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
  box-shadow: none;
}

.primary {
  border-color: rgba(15, 122, 107, 0.72);
  background: rgba(216, 181, 107, 0.92);
  color: #17110a;
}

.primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 0 0 4px var(--primary-soft), 0 14px 30px rgba(216, 181, 107, 0.22);
}

.danger {
  border-color: rgba(180, 35, 24, 0.68);
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: var(--danger-dark);
  box-shadow: 0 0 0 4px var(--danger-soft), 0 14px 30px rgba(180, 35, 24, 0.2);
}

.message {
  min-height: 22px;
  margin: 0;
}

.success {
  border-color: var(--success-line);
  background: var(--success-bg);
}

.admin-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.election-card {
  position: relative;
  display: grid;
  gap: 18px;
  align-content: space-between;
  min-height: 182px;
  padding: 20px;
  overflow: hidden;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, background 220ms ease;
}

.election-card::before,
.panel::before {
  position: absolute;
  inset: 0;
  content: "";
  border-radius: inherit;
  pointer-events: none;
}

.election-card::before {
  border: 1px solid transparent;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.52), transparent 42%, rgba(15, 122, 107, 0.1)) border-box;
  mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.election-card:hover,
.admin-election:hover {
  animation: breatheGlow 1.6s ease-in-out infinite;
  transform: translateY(-4px);
  border-color: rgba(15, 122, 107, 0.36);
  background: var(--glass-strong);
  box-shadow: var(--shadow-hover);
}

.election-card h2 {
  margin-bottom: 8px;
}

.election-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--primary);
}

.admin-election-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-election {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 62px;
  text-align: left;
  background: rgba(255, 255, 255, 0.64);
}

.admin-election span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
}

.admin-election.selected {
  border-color: rgba(15, 122, 107, 0.42);
  background: rgba(75, 56, 90, 0.56);
  box-shadow: 0 0 0 4px var(--primary-soft), 0 14px 34px rgba(216, 181, 107, 0.14);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 26, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: #e8d8b4;
  font-size: 13px;
  background: rgba(216, 181, 107, 0.1);
}

td:not(:first-child),
th:not(:first-child) {
  text-align: right;
}

tbody tr {
  transition: background 160ms ease;
}

tbody tr:hover {
  background: rgba(216, 181, 107, 0.08);
}

tr:last-child td {
  border-bottom: 0;
}

.hidden {
  display: none !important;
}

@keyframes breatheGlow {
  0%,
  100% {
    box-shadow: var(--shadow-hover), 0 0 0 0 rgba(15, 122, 107, 0.12);
  }
  50% {
    box-shadow: var(--shadow-hover), 0 0 0 6px rgba(15, 122, 107, 0.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 24px, 1040px);
    padding-top: 18px;
  }

  .topbar {
    top: 8px;
    width: 100%;
  }

  .tab {
    flex: 1 1 0;
  }

  .panel,
  .notice,
  .election-card {
    padding: 18px;
  }

  .admin-actions {
    display: grid;
  }

  .rules-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    justify-content: stretch;
  }

  .button-row button {
    flex: 1 1 auto;
  }
}
