:root {
  --bg: #070a12;
  --bg-2: #0d1424;
  --ink: #f2ecdd;
  --ink-dim: #a9a292;
  --gold: #d9b45f;
  --gold-soft: #f1dfae;
  --line: rgba(217, 180, 95, 0.22);
  --card: rgba(16, 22, 38, 0.72);

  --gryffindor: #b3232c;
  --slytherin: #1f8a5b;
  --ravenclaw: #34539b;
  --hufflepuff: #e0b423;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 82% -12%, rgba(52, 83, 155, 0.34), transparent 62%),
    radial-gradient(900px 560px at 6% 4%, rgba(179, 35, 44, 0.16), transparent 60%),
    radial-gradient(760px 500px at 50% 108%, rgba(217, 180, 95, 0.12), transparent 65%),
    linear-gradient(180deg, var(--bg), var(--bg-2) 55%, #060810);
  color: var(--ink);
  font-family: "Kanit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* slow drifting aurora glows */
.aurora {
  position: fixed;
  inset: -14vmax;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.75;
}

.aurora::before,
.aurora::after {
  content: "";
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  will-change: transform;
}

.aurora::before {
  top: -14vmax;
  left: -8vmax;
  background: radial-gradient(circle, rgba(217, 180, 95, 0.4), rgba(217, 180, 95, 0) 66%);
  animation: drift-a 34s ease-in-out infinite alternate;
}

.aurora::after {
  right: -12vmax;
  bottom: -20vmax;
  background: radial-gradient(circle, rgba(52, 83, 155, 0.5), rgba(52, 83, 155, 0) 66%);
  animation: drift-b 44s ease-in-out infinite alternate;
}

@keyframes drift-a {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(16vw, 9vh, 0) scale(1.28);
  }
}

@keyframes drift-b {
  from {
    transform: translate3d(0, 0, 0) scale(1.12);
  }
  to {
    transform: translate3d(-15vw, -11vh, 0) scale(0.88);
  }
}

/* animated particle layer: stars, floating motes, shooting stars */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100% - 2.4rem));
  margin: 0 auto;
  padding: 3.2rem 0 4rem;
}

/* ---------- hero ---------- */

.hero {
  text-align: center;
  margin-bottom: 2.4rem;
}

.crest {
  width: 72px;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 0 18px rgba(217, 180, 95, 0.35));
  animation: crest-float 7s ease-in-out infinite;
}

.crest svg {
  width: 100%;
  height: auto;
  display: block;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold);
}

h1 {
  margin: 0;
  font-family: "Cinzel", "Kanit", serif;
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.2;
  background: linear-gradient(180deg, #fffaf0, #d9b45f 78%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(217, 180, 95, 0.18);
}

.lede {
  margin: 0.85rem auto 0;
  max-width: 46ch;
  color: var(--ink-dim);
  font-size: 0.95rem;
}

/* ---------- card ---------- */

.card {
  position: relative;
  background:
    radial-gradient(380px circle at var(--mx, 50%) var(--my, 0%), rgba(217, 180, 95, 0.14), transparent 72%),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.9rem;
  backdrop-filter: blur(9px);
  box-shadow:
    0 22px 60px -30px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  margin-bottom: 1.6rem;
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border: 1px solid var(--gold);
  opacity: 0.55;
}

.card::before {
  top: 10px;
  left: 10px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 10px;
}

.card::after {
  right: 10px;
  bottom: 10px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 10px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(217, 180, 95, 0.16);
}

h2 {
  margin: 0;
  font-family: "Cinzel", "Kanit", serif;
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold-soft);
}

.pill,
.count {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.72rem;
  white-space: nowrap;
}

.pill[data-mode="server"] {
  color: #9fe0bf;
  border-color: rgba(31, 138, 91, 0.45);
}

.pill[data-mode="local"] {
  color: #f0d79b;
  border-color: rgba(217, 180, 95, 0.4);
}

/* ---------- form ---------- */

.field {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
}

label,
legend {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.86rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #ded7c6;
  padding: 0;
}

.req {
  color: var(--gold);
}

input[type="text"],
input[type="search"] {
  width: 100%;
  padding: 0.72rem 0.9rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(7, 10, 18, 0.72);
  border: 1px solid rgba(217, 180, 95, 0.22);
  border-radius: 10px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

input::placeholder {
  color: rgba(169, 162, 146, 0.62);
}

input[type="text"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(7, 10, 18, 0.92);
  box-shadow: 0 0 0 3px rgba(217, 180, 95, 0.14);
}

input.invalid {
  border-color: #d9534f;
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.12);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.err {
  margin: 0.35rem 0 0;
  min-height: 1rem;
  font-size: 0.76rem;
  color: #ef8c88;
}

.houses {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.house {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.9rem 0.4rem 0.8rem;
  text-align: center;
  cursor: pointer;
  border: 1px solid rgba(217, 180, 95, 0.18);
  border-radius: 12px;
  background: rgba(7, 10, 18, 0.5);
  transition: transform 0.18s, border-color 0.18s, background 0.18s;
}

.house input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.house .sigil {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0a0d15;
  border-radius: 50%;
  background: var(--house-color, #888);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 18px -8px var(--house-color, #888);
  transition: transform 0.18s;
}

.house-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #e6dfcf;
}

.house-en {
  font-family: "Cinzel", serif;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.house[data-house="gryffindor"] {
  --house-color: var(--gryffindor);
}
.house[data-house="slytherin"] {
  --house-color: var(--slytherin);
}
.house[data-house="ravenclaw"] {
  --house-color: var(--ravenclaw);
}
.house[data-house="hufflepuff"] {
  --house-color: var(--hufflepuff);
}

.house:hover {
  transform: translateY(-2px);
  border-color: rgba(217, 180, 95, 0.45);
}

.house:hover .sigil {
  transform: scale(1.06);
}

.house:has(input:checked) {
  border-color: var(--house-color);
  background: color-mix(in srgb, var(--house-color) 16%, rgba(7, 10, 18, 0.75));
  box-shadow: 0 0 0 1px var(--house-color), 0 14px 34px -22px var(--house-color);
}

.house:has(input:checked) .house-name {
  color: #fff;
}

.house:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.houses.invalid .house {
  border-color: rgba(217, 83, 79, 0.5);
}

.form-err {
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  font-size: 0.84rem;
  color: #ffb4b0;
  background: rgba(217, 83, 79, 0.12);
  border: 1px solid rgba(217, 83, 79, 0.4);
  border-radius: 9px;
}

.submit {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.88rem 1rem;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #1a1305;
  cursor: pointer;
  border: 1px solid rgba(255, 246, 214, 0.5);
  border-radius: 11px;
  background: linear-gradient(180deg, #f6e3a8, #d9b45f 55%, #b98f3c);
  box-shadow: 0 14px 34px -18px rgba(217, 180, 95, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.16s, filter 0.16s, box-shadow 0.16s;
}

.submit:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.submit:active:not(:disabled) {
  transform: translateY(0);
}

.submit:disabled {
  cursor: progress;
  filter: saturate(0.55) brightness(0.82);
}

/* ---------- roster ---------- */

.house-tally {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tally-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.6rem;
  font-size: 0.74rem;
  color: #ded7c6;
  border: 1px solid rgba(217, 180, 95, 0.18);
  border-radius: 999px;
  background: rgba(7, 10, 18, 0.45);
}

.tally-item i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--house-color);
  box-shadow: 0 0 8px var(--house-color);
}

.tools {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tools input[type="search"] {
  flex: 1 1 220px;
  font-size: 0.86rem;
  padding: 0.52rem 0.8rem;
}

.tool-btns {
  display: flex;
  gap: 0.45rem;
}

.ghost {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  color: var(--gold-soft);
  cursor: pointer;
  background: rgba(217, 180, 95, 0.07);
  border: 1px solid rgba(217, 180, 95, 0.3);
  border-radius: 9px;
  transition: background 0.16s, border-color 0.16s;
}

.ghost:hover {
  background: rgba(217, 180, 95, 0.15);
  border-color: rgba(217, 180, 95, 0.55);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th {
  text-align: left;
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0 0.7rem 0.55rem;
  border-bottom: 1px solid rgba(217, 180, 95, 0.22);
  white-space: nowrap;
}

td {
  padding: 0.68rem 0.7rem;
  border-bottom: 1px solid rgba(217, 180, 95, 0.09);
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(217, 180, 95, 0.05);
}

td.idx {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  width: 2.5rem;
}

td.time {
  color: var(--ink-dim);
  font-size: 0.78rem;
  white-space: nowrap;
}

.cell-strong {
  font-weight: 400;
  color: #f6f0e2;
}

.house-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  white-space: nowrap;
  color: #e8e1d0;
}

.house-tag i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--house-color);
  box-shadow: 0 0 8px var(--house-color);
}

.del {
  padding: 0.28rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  color: #e39b97;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(227, 155, 151, 0.28);
  border-radius: 7px;
  transition: background 0.16s, color 0.16s;
}

.del:hover {
  color: #fff;
  background: rgba(217, 83, 79, 0.35);
}

.empty {
  margin: 1.6rem 0 0.4rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-dim);
}

.empty[hidden] {
  display: none;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- footer + toast ---------- */

.foot {
  margin-top: 1.4rem;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: rgba(169, 162, 146, 0.75);
}

.foot .dot {
  margin: 0 0.5rem;
  color: var(--gold);
}

.foot-line {
  margin: 0.2rem 0;
}

.foot-link {
  padding: 0;
  font: inherit;
  color: var(--gold-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  background: none;
  border: 0;
}

.foot-link:hover {
  color: #fff;
}

#dev-signout {
  display: inline;
  margin: 0 0 0 0.6rem;
}

#dev-signout[hidden],
.foot-user[hidden] {
  display: none;
}

.foot-user {
  color: rgba(241, 223, 174, 0.9);
}

.mine-row {
  margin: 1.1rem 0 0;
  text-align: center;
}

.mine-row[hidden] {
  display: none;
}

.roster[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.8rem;
  transform: translate(-50%, 20px);
  z-index: 20;
  max-width: min(90vw, 460px);
  padding: 0.8rem 1.25rem;
  font-size: 0.86rem;
  color: #1a1305;
  background: linear-gradient(180deg, #f6e3a8, #dcb96b);
  border-radius: 11px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.toast[hidden] {
  display: block;
  visibility: hidden;
}

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

.toast.is-error {
  color: #fff2f1;
  background: linear-gradient(180deg, #b3463f, #8d2d27);
}

/* ---------- little touches ---------- */

.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(217, 180, 95, 0.18),
    rgba(217, 180, 95, 0.06) 42%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.6s ease;
  will-change: transform;
}

.cursor-glow.on {
  opacity: 1;
}

.sparkle-layer {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(246, 227, 168, 0.95) 45%, rgba(246, 227, 168, 0) 72%);
  animation: spark-fly var(--dur, 800ms) cubic-bezier(0.18, 0.62, 0.32, 1) forwards;
}

.hero,
.card,
.foot {
  animation: rise-in 0.8s cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

main > .card:nth-of-type(1) {
  animation-delay: 0.14s;
}

main > .card:nth-of-type(2) {
  animation-delay: 0.26s;
}

.foot {
  animation-delay: 0.38s;
}

.submit::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -70%;
  width: 45%;
  height: 220%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: rotate(14deg);
}

.submit:hover:not(:disabled)::after {
  animation: sheen 0.9s ease;
}

.house:has(input:checked) .sigil {
  animation: crest-pulse 2.6s ease-in-out infinite;
}

tr.flash {
  animation: row-flash 1.9s ease-out;
}

@keyframes crest-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spark-fly {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -60px))) scale(0.15);
    opacity: 0;
  }
}

@keyframes sheen {
  from {
    left: -70%;
  }
  to {
    left: 130%;
  }
}

@keyframes crest-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 18px -8px var(--house-color);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 22px 2px var(--house-color);
  }
}

@keyframes row-flash {
  0% {
    background: rgba(217, 180, 95, 0.28);
    box-shadow: inset 0 0 0 1px rgba(217, 180, 95, 0.4);
  }
  100% {
    background: transparent;
    box-shadow: inset 0 0 0 1px transparent;
  }
}

/* ---------- entry badge ---------- */

body.badge-open {
  overflow: hidden;
}

.badge-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.badge-modal[hidden] {
  display: none;
}

.badge-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.8);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.badge-modal.open .badge-backdrop {
  opacity: 1;
}

.badge-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.22, 0.8, 0.3, 1);
}

.badge-modal.open .badge-wrap {
  opacity: 1;
  transform: none;
}

.badge {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: min(540px, 90vw);
  aspect-ratio: 1.58;
  padding: 1.3rem 1.45rem;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid rgba(217, 180, 95, 0.55);
  border-radius: 16px;
  background:
    radial-gradient(130% 130% at 0% 0%, rgba(255, 255, 255, 0.07), transparent 55%),
    linear-gradient(160deg, #16203a 0%, #0b1120 55%, #070a12 100%);
  box-shadow:
    0 34px 80px -34px #000,
    inset 0 0 60px -26px var(--house-color, #d9b45f);
}

.badge::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(217, 180, 95, 0.26);
  border-radius: 11px;
  pointer-events: none;
}

.badge::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(1.3px 1.3px at 14% 24%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1.1px 1.1px at 78% 16%, rgba(246, 227, 168, 0.9), transparent),
    radial-gradient(1.4px 1.4px at 62% 78%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.1px 1.1px at 30% 84%, rgba(214, 226, 255, 0.8), transparent),
    radial-gradient(0.9px 0.9px at 88% 62%, rgba(255, 255, 255, 0.7), transparent);
}

.badge[data-house="gryffindor"] {
  --house-color: var(--gryffindor);
}

.badge[data-house="slytherin"] {
  --house-color: var(--slytherin);
}

.badge[data-house="ravenclaw"] {
  --house-color: var(--ravenclaw);
}

.badge[data-house="hufflepuff"] {
  --house-color: var(--hufflepuff);
}

.badge-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(217, 180, 95, 0.2);
}

.badge-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.badge-crest {
  flex: none;
  width: 26px;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(217, 180, 95, 0.45));
}

.badge-event {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.badge-title {
  margin: 0.1rem 0 0;
  font-family: "Kanit", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: #f5ecd8;
}

.badge-no {
  font-family: "Cinzel", serif;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: var(--ink-dim);
  white-space: nowrap;
}

.badge-body {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.badge-kicker {
  margin: 0;
  font-size: 0.54rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(169, 162, 146, 0.85);
}

.badge-name {
  margin: 0.05rem 0 0;
  font-size: clamp(1.45rem, 5vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  color: #fffaf0;
  text-shadow: 0 0 26px rgba(217, 180, 95, 0.3);
  word-break: break-word;
}

.badge-ign {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0.45rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-dim);
}

.badge-ign span {
  font-size: 0.54rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.badge-ign strong {
  font-weight: 400;
  color: #e7dfcd;
}

.badge-house {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  text-align: center;
}

.badge-sigil {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 0.3rem;
  font-family: "Cinzel", serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0a0d15;
  border-radius: 50%;
  background: var(--house-color, #d9b45f);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 26px -4px var(--house-color, #d9b45f);
}

.badge-house-th {
  font-size: 0.72rem;
  color: #efe8d8;
}

.badge-house-en {
  font-family: "Cinzel", serif;
  font-size: 0.48rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.badge-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(217, 180, 95, 0.2);
  font-size: 0.64rem;
  color: var(--ink-dim);
}

.badge-date {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-date::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--house-color, #d9b45f);
}

.badge-fb {
  color: rgba(169, 162, 146, 0.85);
  text-align: right;
  word-break: break-all;
}

.badge-hint {
  margin: 0;
  font-size: 0.67rem;
  color: rgba(169, 162, 146, 0.8);
}

.badge-actions {
  display: flex;
  gap: 0.5rem;
}

.badge-print {
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  color: #1a1305;
  cursor: pointer;
  border: 1px solid rgba(255, 246, 214, 0.5);
  border-radius: 10px;
  background: linear-gradient(180deg, #f6e3a8, #d9b45f 55%, #b98f3c);
  box-shadow: 0 14px 30px -18px rgba(217, 180, 95, 0.9);
}

.badge-print:hover {
  filter: brightness(1.05);
}

.badge-btn {
  padding: 0.28rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  color: var(--gold-soft);
  cursor: pointer;
  background: rgba(217, 180, 95, 0.08);
  border: 1px solid rgba(217, 180, 95, 0.32);
  border-radius: 7px;
  transition: background 0.16s;
}

.badge-btn:hover {
  background: rgba(217, 180, 95, 0.2);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ---------- sound toggle ---------- */

.sound-toggle {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.72rem;
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--gold-soft);
  cursor: pointer;
  background: rgba(11, 17, 31, 0.72);
  border: 1px solid rgba(217, 180, 95, 0.3);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.sound-toggle:hover {
  background: rgba(217, 180, 95, 0.16);
  border-color: rgba(217, 180, 95, 0.55);
}

.sound-toggle svg {
  display: block;
  width: 15px;
  height: 15px;
}

.sound-toggle .speaker {
  fill: currentColor;
}

.sound-toggle .wave,
.sound-toggle .slash {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.sound-toggle .slash {
  display: none;
}

.sound-toggle.off {
  color: var(--ink-dim);
}

.sound-toggle.off .wave {
  display: none;
}

.sound-toggle.off .slash {
  display: inline;
}

@media (max-width: 720px) {
  .wrap {
    width: calc(100% - 1.6rem);
    padding-top: 2.2rem;
  }

  .card {
    padding: 1.35rem;
    border-radius: 15px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .houses {
    grid-template-columns: 1fr 1fr;
  }

  .tools {
    flex-direction: column;
  }

  .tool-btns {
    flex: 1 1 auto;
  }

  .ghost {
    flex: 1 1 0;
    justify-content: center;
  }

  .badge {
    padding: 1rem 1.05rem;
    border-radius: 14px;
  }

  .badge-sigil {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .badge-name {
    font-size: 1.35rem;
  }

  .badge-actions {
    width: 100%;
  }

  .badge-print,
  .badge-actions .ghost {
    flex: 1 1 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aurora::before,
  .aurora::after {
    animation: none;
  }

  .hero,
  .card,
  .foot,
  .crest,
  .house:has(input:checked) .sigil,
  tr.flash {
    animation: none;
  }

  .submit::after {
    display: none;
  }

  .cursor-glow {
    display: none;
  }

  .badge-wrap,
  .badge-backdrop {
    transition: none;
  }

  .toast,
  .house,
  .submit,
  .ghost,
  .del {
    transition: none;
  }
}

/* ---------- print the badge only ---------- */

@media print {
  @page {
    margin: 14mm;
  }

  body.badge-open {
    background: #fff !important;
    overflow: visible;
  }

  body.badge-open .wrap,
  body.badge-open .aurora,
  body.badge-open .bg,
  body.badge-open .cursor-glow,
  body.badge-open .sparkle-layer,
  body.badge-open .toast,
  body.badge-open .badge-backdrop,
  body.badge-open .badge-actions,
  body.badge-open .sound-toggle,
  body.badge-open .badge-hint {
    display: none !important;
  }

  body.badge-open .badge-modal {
    position: static;
    display: block;
    padding: 0;
    background: none;
  }

  body.badge-open .badge-wrap {
    max-height: none;
    overflow: visible;
    opacity: 1 !important;
    transform: none !important;
  }

  body.badge-open .badge {
    width: 132mm;
    height: 84mm;
    margin: 0 auto;
    aspect-ratio: auto;
    border-radius: 5mm;
    box-shadow: none;
    break-inside: avoid;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
