:root {
  --bg: #e8edf2;
  --bg-deep: #d5dde6;
  --fg: #142033;
  --muted: #5a6a7e;
  --border: rgba(20, 32, 51, 0.12);
  --border-strong: rgba(20, 32, 51, 0.22);
  --primary: #1b3a5c;
  --primary-hover: #122a44;
  --primary-soft: rgba(27, 58, 92, 0.08);
  --accent: #c4783a;
  --accent-soft: rgba(196, 120, 58, 0.14);
  --success: #1f7a5c;
  --warning: #b86a1c;
  --danger: #b42318;
  --surface: #f4f7fa;
  --card: #fbfcfd;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(20, 32, 51, 0.08);
  --font: "Anuphan", system-ui, sans-serif;
  --display: "Bricolage Grotesque", "Anuphan", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  position: relative;
  overflow-x: hidden;
}

.admin-body {
  background: var(--bg);
}

/* ——— Atmosphere ——— */
.atmosphere {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.atm-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(196, 120, 58, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 5%, rgba(27, 58, 92, 0.16), transparent 50%),
    linear-gradient(165deg, #eef2f6 0%, #e2e8ef 45%, #d9e1ea 100%);
}

.atm-grid {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(20, 32, 51, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 32, 51, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 75%);
}

.atm-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  animation: orbDrift 14s ease-in-out infinite;
}

.atm-orb-a {
  width: 22rem;
  height: 22rem;
  left: -6rem;
  top: -4rem;
  background: rgba(196, 120, 58, 0.22);
}

.atm-orb-b {
  width: 18rem;
  height: 18rem;
  right: -4rem;
  top: 28%;
  background: rgba(27, 58, 92, 0.18);
  animation-delay: -5s;
}

.atmosphere-dark .atm-wash {
  background:
    radial-gradient(ellipse 70% 50% at 20% 0%, rgba(196, 120, 58, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 20%, rgba(80, 130, 180, 0.12), transparent 50%),
    linear-gradient(165deg, #0c1018 0%, #111722 50%, #0a0e14 100%);
}

.atmosphere-dark .atm-grid {
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

@keyframes orbDrift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translate(12px, 18px) scale(1.06);
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-up {
  animation: fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.delay {
  animation-delay: 0.1s;
}

/* ——— Shell / Tabs ——— */
.shell-header,
.wrap,
.shell-footer,
.admin-header,
.login-wrap,
#app {
  position: relative;
  z-index: 1;
}

.shell-header {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.shell-header .brand {
  justify-self: start;
}

.shell-header .page-tabs {
  justify-self: center;
}

.shell-header .shell-admin {
  justify-self: end;
}

.brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary) 0%, #243f5f 100%);
  color: #f8fafc;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 20px rgba(27, 58, 92, 0.28);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.brand-sub,
.hint,
.lead {
  margin: 0;
  color: var(--muted);
}

.brand-sub,
.hint {
  font-size: 0.75rem;
  font-weight: 500;
}

.shell-admin {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.shell-admin:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--border);
}

.page-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.28rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(20, 32, 51, 0.06);
  backdrop-filter: blur(12px);
}

.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8125rem;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.page-tab:hover {
  color: var(--fg);
}

.page-tab.is-active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 22px rgba(27, 58, 92, 0.28);
}

.page-tab-num {
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.7;
  letter-spacing: 0.04em;
}

.page-tab.is-active .page-tab-num {
  opacity: 1;
  color: #f0c9a0;
}

.page-tab-label {
  white-space: nowrap;
}

.shell-footer {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2rem;
}

/* ——— Hero ——— */
.hero {
  display: grid;
  gap: 1.5rem;
  align-items: end;
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: 1.15fr 0.85fr;
    gap: 2.5rem;
    min-height: 280px;
    align-items: center;
  }

  .hero-aside {
    order: 2;
  }

  .hero-copy {
    order: 1;
  }
}

.eyebrow {
  margin: 0 0 0.85rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.15rem, 5vw, 3.4rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h1 em {
  font-style: normal;
  color: var(--accent);
}

.lead {
  margin-top: 1rem;
  max-width: 34rem;
  font-size: 1.05rem;
  line-height: 1.65;
}

.step-rail {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.step span {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-deep);
  font-family: var(--display);
  font-size: 0.7rem;
}

.step.is-current {
  color: var(--fg);
  border-color: rgba(196, 120, 58, 0.35);
  background: var(--accent-soft);
}

.step.is-current span {
  background: var(--accent);
  color: #fff;
}

.hero-aside {
  position: relative;
  display: block;
  width: 100%;
  max-width: 22rem;
  margin: 0 auto;
  min-height: 11.5rem;
}

@media (min-width: 900px) {
  .hero-aside {
    max-width: none;
    margin: 0;
    min-height: 240px;
  }
}

.polaroid {
  position: absolute;
  width: 6.4rem;
  padding: 0.4rem 0.4rem 1.05rem;
  background: #fff;
  border-radius: 4px;
  box-shadow: var(--shadow);
  animation: floatCard 7s ease-in-out infinite;
  will-change: transform;
}

@media (min-width: 900px) {
  .polaroid {
    width: 9.5rem;
    padding: 0.55rem 0.55rem 1.4rem;
  }
}

.polaroid-frame {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 2px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(27, 58, 92, 0.15), rgba(196, 120, 58, 0.2)),
    repeating-linear-gradient(
      -12deg,
      transparent,
      transparent 6px,
      rgba(20, 32, 51, 0.04) 6px,
      rgba(20, 32, 51, 0.04) 7px
    );
}

.polaroid-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.55s ease;
}

.polaroid-img.is-on {
  opacity: 1;
}

.polaroid-caption {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
}

@media (min-width: 900px) {
  .polaroid-caption {
    margin: 0.45rem 0 0;
    font-size: 0.7rem;
  }
}

.polaroid p {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
}

.polaroid.p1 {
  left: 6%;
  top: 18%;
  transform: rotate(-8deg);
}

.polaroid.p2 {
  right: 8%;
  top: 4%;
  transform: rotate(7deg);
  animation-delay: -2.2s;
}

.polaroid.p3 {
  left: 32%;
  bottom: 2%;
  transform: rotate(2deg);
  animation-delay: -4s;
  width: 5.8rem;
}

@media (min-width: 900px) {
  .polaroid.p1 {
    left: 8%;
    top: 12%;
  }

  .polaroid.p2 {
    right: 10%;
    top: 0;
  }

  .polaroid.p3 {
    left: 34%;
    bottom: 0;
    width: 8.5rem;
  }
}

@keyframes floatCard {
  0%,
  100% {
    transform: translateY(0) rotate(var(--polaroid-rot, 0deg));
  }
  50% {
    transform: translateY(-8px) rotate(var(--polaroid-rot, 0deg));
  }
}

.polaroid.p1 {
  --polaroid-rot: -8deg;
}

.polaroid.p2 {
  --polaroid-rot: 7deg;
}

.polaroid.p3 {
  --polaroid-rot: 2deg;
}

/* ——— Forms / cards ——— */
.card {
  margin-top: 2rem;
  max-width: 28rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: rgba(251, 252, 253, 0.92);
  padding: 1.45rem 1.45rem 1.55rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.id-card {
  position: relative;
}

.card-kicker {
  position: absolute;
  top: -0.7rem;
  left: 1.1rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
}

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

input {
  width: 100%;
  margin-top: 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.9rem 1rem;
  font: inherit;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.14);
}

button {
  font: inherit;
  cursor: pointer;
}

button[type="submit"],
#id-submit {
  width: 100%;
  margin-top: 1.25rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

button[type="submit"]:hover,
#id-submit:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

button[type="submit"]:focus-visible,
#id-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.2);
}

button[type="submit"]:active:not(:disabled),
#id-submit:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.error {
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-size: 0.875rem;
}

.error-box,
.success {
  margin: 0 0 1rem;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.error-box {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.15);
}

.success {
  background: rgba(31, 122, 92, 0.1);
  color: var(--success);
  border: 1px solid rgba(31, 122, 92, 0.15);
}

.hidden {
  display: none !important;
}

.member-bar {
  margin: 2rem 0 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.75);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.member-id {
  margin: 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.member-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.pill {
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--warning);
}

.pill.ok {
  background: rgba(31, 122, 92, 0.12);
  color: var(--success);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-btn:hover {
  color: var(--fg);
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.done-actions {
  margin-top: 1.5rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid rgba(31, 122, 92, 0.22);
  border-radius: var(--radius);
  background: rgba(31, 122, 92, 0.08);
  text-align: center;
  animation: fadeUp 0.45s ease both;
}

.done-hint {
  margin: 0 0 0.9rem;
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-home {
  min-width: 12rem;
  height: 44px;
  font-size: 0.95rem;
}

.slot {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
}

.slot:hover {
  transform: translateY(-2px);
  border-color: rgba(196, 120, 58, 0.35);
}

.slot-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.slot h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.slot .hint {
  margin-top: 0.2rem;
}

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(31, 122, 92, 0.12);
  color: var(--success);
  white-space: nowrap;
  height: fit-content;
}

.drop {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  border: 1.5px dashed rgba(20, 32, 51, 0.2);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, #f7f9fb, #eef2f6);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drop-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.plus {
  width: 2.6rem;
  height: 2.6rem;
  margin: 0 auto 0.55rem;
  border-radius: 999px;
  background: rgba(27, 58, 92, 0.1);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 700;
}

.busy-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.78);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.875rem;
}

.link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
}

.link:hover {
  color: var(--primary);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition:
    background-color 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease,
    transform 0.12s ease;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.18);
}

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

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--fg);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface);
  border-color: #8a97a8;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.5);
  color: var(--fg);
}

.btn-danger-outline {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--fg);
}

.btn-danger-outline:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.btn-soft {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: rgba(27, 58, 92, 0.14);
}

/* ——— Login ——— */
.login-wrap {
  min-height: calc(100vh - 5.5rem);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  margin: 0;
  width: 100%;
  max-width: 24rem;
}

.login-title {
  font-size: 1.75rem;
}

.back {
  display: block;
  margin-top: 1rem;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
}

.back:hover {
  color: var(--fg);
}

/* ——— Admin ——— */
.admin-header {
  background: rgba(251, 252, 253, 0.9);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  backdrop-filter: blur(10px);
}

.admin-header h1 {
  font-size: 1.35rem;
}

.admin-main {
  padding-top: 2rem;
}

.stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat p {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat .ok {
  color: var(--success);
}
.stat .warn {
  color: var(--warning);
}
.stat .mute {
  color: var(--muted);
}

.filters {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.chip-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.chip {
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 0;
  padding: 0.55rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.chip:last-child {
  border-right: 0;
}

.chip:hover:not(.active) {
  color: var(--fg);
  background: var(--surface);
}

.chip.active {
  background: var(--primary);
  color: #fff;
}

#search {
  margin: 0 0 0 auto;
  width: min(100%, 14rem);
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  margin-top: 0;
}

.table-wrap {
  margin-top: 1rem;
  overflow: auto;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  background: var(--surface);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.7rem 1rem;
}

td {
  border-top: 1px solid var(--border);
  padding: 0.7rem 1rem;
}

.view-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--fg);
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.view-btn:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.photo-actions {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
}

.del-btn,
.del-all-btn {
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--danger);
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.del-btn:hover,
.del-all-btn:hover {
  background: #fef2f2;
  border-color: #f87171;
}

.del-all-btn {
  white-space: nowrap;
}

.modal-head-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(12, 16, 24, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-card {
  width: min(100%, 28rem);
  max-height: 90vh;
  overflow: hidden;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-head p {
  margin: 0;
  font-weight: 700;
  font-size: 0.875rem;
}

.modal-card img {
  display: block;
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.admin-tabs {
  padding: 0 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.tab-track {
  display: flex;
  gap: 0;
}

.tab-btn {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.9rem 1rem;
}

.tab-btn::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

.tab-btn.active {
  color: var(--fg);
}

.tab-btn.active::after {
  background: var(--accent);
}

.tab-btn:hover:not(.active) {
  color: var(--fg);
}

/* ——— Buddy leftovers (compat) ——— */
.buddy-layout {
  display: grid;
  gap: 1.25rem;
}

.buddy-card {
  margin: 0;
  max-width: none;
}

.buddy-h2 {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.buddy-setup textarea,
.buddy-setup-inner textarea {
  width: 100%;
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.75rem 0.85rem;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}

.buddy-setup textarea:focus,
.buddy-setup-inner textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.12);
}

.buddy-setup code,
.buddy-setup-inner code {
  font-size: 0.8em;
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.buddy-unpaired {
  margin-top: 0.85rem;
  line-height: 1.5;
}

.reveal-counter {
  margin: 0 0.25rem;
  min-width: 3.75rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.reveal-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.875rem;
  padding: 1rem;
  text-align: center;
}

.pulse-wait {
  animation: softPulse 1.4s ease-in-out infinite;
}

@keyframes softPulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.reveal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fade-in-photo {
  animation: photoFade 0.7s ease both;
}

@keyframes photoFade {
  from {
    opacity: 0;
    transform: scale(1.02);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.blurred-id {
  filter: blur(6px);
  opacity: 0.55;
  letter-spacing: 0.2em;
}

/* Jigsaw */
.jigsaw-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: 100%;
  height: 100%;
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.jigsaw-tile {
  background-repeat: no-repeat;
  opacity: 1;
  transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.82);
  filter: brightness(0.55) saturate(0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.jigsaw-tile.is-scattered {
  transition: transform 0.4s ease;
}

.jigsaw-tile.assemble {
  animation: jigsawIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes jigsawIn {
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
    filter: brightness(1) saturate(1);
    box-shadow: none;
  }
}

/* ——— Buddy dark stage ——— */
.buddy-page {
  min-height: 100vh;
  background: #0c1018;
  color: #eef2f6;
}

.shell-header-dark {
  color: #eef2f6;
}

.shell-header-dark .logo {
  background: linear-gradient(145deg, #c4783a, #9a5a28);
  box-shadow: 0 8px 22px rgba(196, 120, 58, 0.3);
}

.shell-header-dark .brand-sub,
.shell-header-dark .shell-admin {
  color: rgba(238, 242, 246, 0.55);
}

.shell-header-dark .shell-admin:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.shell-header-dark .page-tabs {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.shell-header-dark .page-tab {
  color: rgba(238, 242, 246, 0.55);
}

.shell-header-dark .page-tab:hover {
  color: #fff;
}

.shell-header-dark .page-tab.is-active {
  color: #142033;
  background: linear-gradient(135deg, #e8b86d, #c4783a);
  box-shadow: 0 8px 22px rgba(196, 120, 58, 0.35);
}

.shell-header-dark .page-tab.is-active .page-tab-num {
  color: rgba(20, 32, 51, 0.7);
}

.buddy-page .login-wrap {
  min-height: calc(100vh - 5.5rem);
}

.buddy-page .login-card {
  background: rgba(18, 22, 32, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
  color: #eef2f6;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.buddy-page .login-card .hint,
.buddy-page .login-card .back,
.buddy-page .login-card label {
  color: rgba(238, 242, 246, 0.65);
}

.buddy-page .login-card input {
  background: #0c1018;
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.buddy-page .login-card input:focus {
  border-color: #c4783a;
  box-shadow: 0 0 0 3px rgba(196, 120, 58, 0.2);
}

.buddy-page .login-card button[type="submit"] {
  background: linear-gradient(135deg, #e8b86d, #c4783a);
  border-color: transparent;
  color: #142033;
}

.buddy-page .login-card button[type="submit"]:hover {
  filter: brightness(1.05);
}

.buddy-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  max-width: 72rem;
  margin: 0.75rem auto 0;
  padding: 0.9rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(18, 22, 32, 0.75);
  backdrop-filter: blur(12px);
}

.buddy-top-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.buddy-live-eyebrow {
  margin: 0;
}

.buddy-top h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: #fff;
}

.buddy-top-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.buddy-setup-panel {
  max-width: 72rem;
  margin: 0.75rem auto 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background: rgba(18, 22, 32, 0.9);
}

.buddy-setup-inner {
  padding: 1rem 1.25rem 1.25rem;
}

.buddy-setup-inner h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: #fff;
}

.buddy-setup-inner .hint {
  color: #9aa6b5;
}

.buddy-setup-inner textarea {
  background: #0c1018;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f3f4f6;
}

.buddy-setup-row {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.buddy-stage-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
  min-height: calc(100vh - 12rem);
  display: flex;
  flex-direction: column;
}

.buddy-empty {
  margin: auto;
  padding: 2rem 1.25rem;
  text-align: center;
  color: #9aa6b5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(18, 22, 32, 0.85);
  width: min(100%, 420px);
}

.buddy-duel {
  flex: 1;
  display: grid;
  gap: 1rem;
  align-items: center;
  min-height: 0;
}

@media (min-width: 860px) {
  .buddy-duel {
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
  }
}

.buddy-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.buddy-photo {
  width: 100%;
  max-width: 460px;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: #05070b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.5);
}

.buddy-id {
  margin: 0.85rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.buddy-vs {
  text-align: center;
  padding: 0.5rem;
}

.buddy-vs-mark {
  margin: 0;
  font-family: var(--display);
  font-size: 2.25rem;
  font-weight: 800;
  color: #9aa6b5;
}

.buddy-vs-mark.leaked-on {
  color: #e8b86d;
}

.buddy-vs-text {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #e8b86d;
}

.buddy-toolbar {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

/* ——— Reveal mode picker ——— */
.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0 0 1.25rem;
}

@media (max-width: 720px) {
  .mode-picker {
    grid-template-columns: 1fr;
  }
}

.mode-btn {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(18, 22, 32, 0.75);
  color: #eef2f6;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.mode-btn:hover {
  border-color: rgba(232, 184, 109, 0.45);
  transform: translateY(-1px);
}

.mode-btn.is-active {
  border-color: rgba(232, 184, 109, 0.7);
  background: linear-gradient(145deg, rgba(196, 120, 58, 0.22), rgba(18, 22, 32, 0.9));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.mode-btn-title {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.mode-btn-desc {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: rgba(238, 242, 246, 0.55);
  font-weight: 500;
}

.mode-btn.is-active .mode-btn-desc {
  color: rgba(232, 184, 109, 0.9);
}

.mode-actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.scratch-host,
.shadow-host {
  position: relative;
  touch-action: none;
}

.scratch-host .buddy-image,
.shadow-host .shadow-canvas,
.scratch-host .scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scratch-host .buddy-image {
  object-fit: cover;
  z-index: 1;
  user-select: none;
  -webkit-user-drag: none;
}

.scratch-host .scratch-canvas {
  z-index: 2;
  cursor: crosshair;
}

.shadow-host .shadow-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.shadow-host {
  background: #1a2230;
}

.shadow-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 70% 55% at 50% 40%, #f3ebe0 0%, #9aa8bc 55%, #3d4a5c 100%);
}

.shadow-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.08);
  transition: filter 1.25s ease, transform 1.25s ease;
}

/* mystery: bright enough to see person shape, blurred to hide face */
.shadow-photo.is-mystery {
  filter: blur(18px) brightness(1.05) contrast(1.08) saturate(0.35);
}

.shadow-photo.is-revealing {
  filter: blur(6px) brightness(1.02) contrast(1.05) saturate(0.7);
  transform: scale(1.03);
}

.shadow-photo.is-clear {
  filter: none;
  transform: scale(1);
}

.shadow-fog {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 248, 235, 0.2), transparent 42%),
    linear-gradient(180deg, rgba(30, 40, 55, 0.12), rgba(30, 40, 55, 0.28));
  transition: opacity 1.1s ease;
}

.shadow-fog.is-clearing {
  opacity: 0.35;
}

.shadow-fog.is-gone {
  opacity: 0;
}

.shadow-hints {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.shadow-hint-chip {
  position: absolute;
  left: 105%;
  white-space: nowrap;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 248, 235, 0.92);
  color: #1c2430;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: hintDrift 5s linear forwards;
}

@keyframes hintDrift {
  from {
    transform: translateX(0);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  to {
    transform: translateX(calc(-100vw - 120%));
    opacity: 0;
  }
}

.buddy-page .btn-primary {
  background: linear-gradient(135deg, #e8b86d, #c4783a);
  border-color: transparent;
  color: #142033;
}

.buddy-page .btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.buddy-page .btn-secondary {
  background: #1a2030;
  border-color: rgba(255, 255, 255, 0.14);
  color: #e5e7eb;
}

.buddy-page .btn-secondary:hover:not(:disabled) {
  background: #232a3c;
  border-color: rgba(255, 255, 255, 0.22);
}

.buddy-page .btn-ghost {
  color: #9aa6b5;
}

.buddy-page .btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.buddy-page .reveal-counter {
  color: #9aa6b5;
}

.buddy-page .blurred-id {
  color: #fff;
}

/* ——— Responsive shell ——— */
@media (max-width: 820px) {
  .shell-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand admin"
      "tabs tabs";
  }

  .shell-header .brand {
    grid-area: brand;
  }

  .shell-header .shell-admin {
    grid-area: admin;
  }

  .shell-header .page-tabs {
    grid-area: tabs;
    width: 100%;
    justify-self: stretch;
  }

  .page-tab {
    justify-content: center;
    padding: 0.65rem 0.75rem;
  }

  .page-tab-label {
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .page-tab-num {
    display: none;
  }
}

/* ——— Simple header (upload home, no admin link) ——— */
.shell-header-simple {
  grid-template-columns: 1fr;
}

.shell-header-display {
  grid-template-columns: 1fr auto 1fr;
}

.display-title {
  margin: 0;
  justify-self: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  letter-spacing: -0.02em;
  color: #e8b86d;
}

.buddy-toolbar-display {
  gap: 1rem;
}

.stage-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: #9aa6b5;
  text-transform: lowercase;
}

/* ——— Admin Buddy control panel ——— */
.admin-buddy-panel {
  max-width: 52rem;
  display: grid;
  gap: 1.5rem;
}

.admin-buddy-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.admin-buddy-title {
  margin: 0.15rem 0 0.35rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-stage-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.admin-buddy-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  padding: 1.15rem 1.25rem 1.3rem;
  box-shadow: var(--shadow);
}

.admin-buddy-block h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.admin-buddy-block textarea {
  width: 100%;
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.75rem 0.85rem;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}

.admin-buddy-block textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.12);
}

.admin-buddy-block code {
  font-size: 0.8em;
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.admin-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.65rem;
}

.admin-control-row:first-of-type {
  margin-top: 0;
}

.admin-mode-picker {
  margin: 0;
}

.admin-mode-picker .mode-btn {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
}

.admin-mode-picker .mode-btn:hover {
  border-color: rgba(196, 120, 58, 0.45);
}

.admin-mode-picker .mode-btn.is-active {
  border-color: rgba(196, 120, 58, 0.65);
  background: var(--accent-soft);
  box-shadow: none;
}

.admin-mode-picker .mode-btn-desc {
  color: var(--muted);
}

.admin-mode-picker .mode-btn.is-active .mode-btn-desc {
  color: var(--warning);
}

.admin-pair-list {
  display: grid;
  gap: 0.4rem;
  max-height: 18rem;
  overflow: auto;
}

.admin-pair-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition:
    border-color 0.12s ease,
    background 0.12s ease;
}

.admin-pair-item:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.admin-pair-item.is-active {
  border-color: rgba(196, 120, 58, 0.5);
  background: var(--accent-soft);
}

.admin-pair-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--display);
  font-size: 0.75rem;
  font-weight: 700;
}

.admin-pair-item.is-active .admin-pair-num {
  background: var(--accent);
  color: #fff;
}
