:root {
  --brand: #d1223b;
  --brand2: #ff6b5b;
  --brand-dark: #8f1029;
  --gold: #e2a63a;
  --gold-light: #ffd77a;
  --bg1: #fff8ef;
  --bg2: #ffe8d6;
  --card: #fffefc;
  --text: #2c211d;
  --muted: #8a7668;
  --border: #f0ddc7;
  --ok: #1f8f4e;
  --ok-bg: #e7f8ee;
  --err: #c62839;
  --err-bg: #fdecec;
  --shadow: 0 10px 30px -8px rgba(139, 25, 45, 0.18);
  --shadow-sm: 0 4px 14px -6px rgba(139, 25, 45, 0.15);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

::selection { background: var(--brand); color: #fff; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 55%, #ffe0c4 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  padding: 0 16px 40px;
  position: relative;
  overflow-x: hidden;
}

body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
}
body::before {
  width: 420px; height: 420px;
  top: -160px; left: -140px;
  background: radial-gradient(circle, var(--gold-light), transparent 70%);
  animation: float1 16s ease-in-out infinite;
}
body::after {
  width: 480px; height: 480px;
  bottom: -200px; right: -160px;
  background: radial-gradient(circle, var(--brand2), transparent 70%);
  animation: float2 20s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 60px) scale(1.1); }
}
@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -40px) scale(1.08); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes shine {
  to { background-position: 200% center; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(209, 34, 59, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(209, 34, 59, 0); }
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  position: relative;
}

header.page-head {
  padding: 34px 0 18px;
  text-align: center;
  margin-bottom: 26px;
  animation: fadeInUp 0.6s ease both;
}

header.page-head h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--brand2), var(--brand));
  background-size: 300% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 7s linear infinite;
}

header.page-head .sub {
  color: var(--muted);
  font-size: 0.95rem;
  position: relative;
  display: inline-block;
  padding-bottom: 10px;
}
header.page-head .sub::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 3px;
  width: 70px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--gold));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.55s ease both;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--gold), var(--brand2));
  background-size: 200% auto;
  animation: shine 5s linear infinite;
}
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.wrap > .card:nth-of-type(1) { animation-delay: 0.05s; }
.wrap > .card:nth-of-type(2) { animation-delay: 0.15s; }
.wrap > .card:nth-of-type(3) { animation-delay: 0.25s; }
.wrap > .card:nth-of-type(4) { animation-delay: 0.35s; }

.card h2 {
  color: var(--brand-dark);
  font-size: 1.2rem;
  margin-top: 0;
  padding-left: 14px;
  position: relative;
}
.card h2::before {
  content: "";
  position: absolute;
  left: 0; top: 2px; bottom: 2px;
  width: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand), var(--gold));
}

.letter p { margin: 0.6em 0; }
.letter .indent { text-indent: 2em; }

ol.agenda { padding-left: 1.4em; }
ol.agenda li { margin: 8px 0; transition: transform 0.2s ease, color 0.2s ease; }
ol.agenda li:hover { transform: translateX(4px); color: var(--brand-dark); }

table.info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}
table.info-table td {
  padding: 6px 4px;
  vertical-align: top;
}
table.info-table td.label {
  width: 110px;
  color: var(--muted);
  white-space: nowrap;
}

form .field {
  margin-bottom: 18px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 7px;
  color: var(--brand-dark);
}

select, input[type="text"], input[type="tel"], input[type="password"], textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
select:focus, input[type="text"]:focus, input[type="tel"]:focus, input[type="password"]:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(209, 34, 59, 0.12);
  transform: translateY(-1px);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d1223b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 40px;
}

input[name*="english_name"] { text-transform: uppercase; }

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

.delegate-block {
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--gold);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  background: linear-gradient(180deg, #fffdf9, #fffaf2);
  overflow: hidden;
  max-height: 900px;
  opacity: 1;
  transition: max-height 0.45s ease, opacity 0.35s ease, margin 0.4s ease,
              padding 0.4s ease, border-width 0.4s ease;
}
.delegate-block.no-anim { transition: none; }
.delegate-block.is-hidden {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  pointer-events: none;
}
.delegate-block:nth-of-type(5n+1) { border-left-color: var(--brand); }
.delegate-block:nth-of-type(5n+2) { border-left-color: var(--gold); }
.delegate-block:nth-of-type(5n+3) { border-left-color: var(--brand2); }
.delegate-block:nth-of-type(5n+4) { border-left-color: #e2a63a; }
.delegate-block:nth-of-type(5n+5) { border-left-color: #d1223b; }

.delegate-block h3 {
  margin: 0 0 12px;
  font-size: 1.02rem;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 8px;
}
.delegate-block h3::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  display: inline-block;
}

.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0;
  padding: 9px 20px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  transition: all 0.2s ease;
  user-select: none;
}
.radio-group label:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.radio-group label.is-checked {
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(209, 34, 59, 0.5);
}
.radio-group input {
  width: auto;
  accent-color: #fff;
}

button, .btn {
  display: inline-block;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  background-size: 200% auto;
  color: #fff;
  border: none;
  padding: 13px 32px;
  border-radius: 999px;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 20px -8px rgba(209, 34, 59, 0.55);
  transition: background-position 0.5s ease, transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
button:hover, .btn:hover {
  background-position: 100% center;
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -8px rgba(209, 34, 59, 0.6);
}
button:active, .btn:active {
  transform: translateY(0);
}
button[type="submit"] {
  animation: pulseGlow 2.6s ease-in-out infinite;
}
button[type="submit"]:hover { animation: none; }

.btn.secondary {
  background: #fff;
  background-image: none;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  box-shadow: none;
}
.btn.secondary:hover {
  background: var(--brand);
  color: #fff;
}

.msg {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 18px;
  animation: fadeInUp 0.4s ease both;
}
.msg.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6cd; }
.msg.err { background: var(--err-bg); color: var(--err); border: 1px solid #f3c6c9; }

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

table.list-table, table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  overflow: hidden;
  border-radius: 10px;
}
table.list-table th, table.list-table td,
table.admin-table th, table.admin-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}
table.list-table th, table.admin-table th {
  background: linear-gradient(90deg, #fbe9d3, #f7dcc0);
  color: var(--brand-dark);
  font-weight: 700;
}
table.list-table tbody tr, table.admin-table tbody tr {
  transition: background 0.2s ease, transform 0.15s ease;
}
table.list-table tbody tr:hover, table.admin-table tbody tr:hover {
  background: #fff6ea;
}
table.admin-table tr.registration-row { cursor: pointer; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeInUp 0.5s ease both;
}

.summary-badges {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.badge {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  animation: popIn 0.4s ease both;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.badge:hover { transform: translateY(-3px) scale(1.03); box-shadow: var(--shadow); }
.summary-badges .badge:nth-child(1) { animation-delay: 0.05s; }
.summary-badges .badge:nth-child(2) { animation-delay: 0.12s; }
.summary-badges .badge:nth-child(3) { animation-delay: 0.19s; }
.summary-badges .badge:nth-child(4) { animation-delay: 0.26s; }
.summary-badges .badge:nth-child(5) { animation-delay: 0.33s; }
.badge .num {
  font-size: 1.6rem;
  font-weight: 800;
  display: block;
  background: linear-gradient(90deg, var(--brand), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.badge .label { font-size: 0.8rem; color: var(--muted); }

.login-box {
  max-width: 380px;
  margin: 60px auto;
}

nav.admin-nav a {
  margin-left: 14px;
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: border-color 0.2s ease;
}
nav.admin-nav a:hover { border-color: var(--gold); }

@media (max-width: 480px) {
  table.list-table, table.admin-table { font-size: 0.85rem; }
  .radio-group { gap: 10px; }
  header.page-head h1 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  body::before, body::after { display: none; }
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  body::before, body::after { display: none; }
  .card { border: none; padding: 0; box-shadow: none; animation: none; }
  .card::before { display: none; }
}
