:root {
  --purple-dark: #1a0d2e;
  --purple: #2d1b4e;
  --purple-light: #4a2f7a;
  --orange: #ff7518;
  --orange-light: #ffa34d;
  --orange-glow: #ff9500;
  --cream: #fff3e0;
  --text: #f5ecff;
  --text-dim: #c9b8e8;
  --danger: #ff4d4d;
  --green: #2ecc71;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse at top, var(--purple) 0%, var(--purple-dark) 65%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  width: 100%;
  flex: 1;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

header.top a.brand {
  color: var(--orange-light);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 1.9rem;
  margin: 0.5rem 0 0.25rem;
  text-align: center;
  text-shadow: 0 0 18px rgba(255, 149, 0, 0.45);
}

h1 .glow {
  color: var(--orange-light);
}

.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin: 0 0 1.75rem;
  font-size: 1rem;
}

.big-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.big-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: linear-gradient(160deg, var(--orange) 0%, #cc4e00 100%);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 1.75rem 1rem;
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(255, 117, 24, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  cursor: pointer;
  min-height: 96px;
}

.big-btn:active {
  transform: scale(0.97);
}

.big-btn.secondary {
  background: linear-gradient(160deg, var(--purple-light) 0%, #241242 100%);
  box-shadow: 0 10px 24px rgba(74, 47, 122, 0.5);
}

.big-btn .emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.card {
  background: rgba(45, 27, 78, 0.55);
  border: 1px solid rgba(255, 165, 77, 0.18);
  border-radius: 18px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(4px);
}

label {
  display: block;
  font-weight: 700;
  margin: 1rem 0 0.4rem;
  color: var(--orange-light);
}

input[type='text'],
textarea,
input[type='password'] {
  width: 100%;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

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

input::placeholder,
textarea::placeholder {
  color: rgba(245, 236, 255, 0.4);
}

.file-input-wrap {
  margin-top: 0.4rem;
}

input[type='file'] {
  width: 100%;
  color: var(--text-dim);
}

input[type='file']::file-selector-button {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 52px;
  margin-right: 0.8rem;
}

input[type='file']::file-selector-button:active {
  transform: scale(0.97);
}

.preview {
  margin-top: 0.75rem;
  border-radius: 14px;
  overflow: hidden;
  max-width: 260px;
  display: none;
}

.preview img {
  width: 100%;
  display: block;
}

.btn {
  display: inline-block;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  min-width: 52px;
}

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

.btn.full {
  width: 100%;
  margin-top: 1.5rem;
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(255, 165, 77, 0.5);
  color: var(--orange-light);
}

.btn.danger {
  background: var(--danger);
}

.btn.small {
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  min-height: 40px;
}

.msg {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.msg.error {
  background: rgba(255, 77, 77, 0.18);
  border: 1px solid rgba(255, 77, 77, 0.4);
  color: #ffd0d0;
}

.msg.success {
  background: rgba(46, 204, 113, 0.18);
  border: 1px solid rgba(46, 204, 113, 0.4);
  color: #d0ffe4;
}

.msg.info {
  background: rgba(255, 165, 77, 0.14);
  border: 1px solid rgba(255, 165, 77, 0.35);
  color: var(--text-dim);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}

@media (min-width: 480px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

.trunk-card {
  background: rgba(45, 27, 78, 0.6);
  border: 2px solid rgba(255, 165, 77, 0.15);
  border-radius: 16px;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
}

.trunk-card:active {
  transform: scale(0.98);
}

.trunk-card.selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 117, 24, 0.35);
}

.trunk-card .photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
  display: block;
}

.trunk-card .info {
  padding: 0.65rem 0.75rem 0.85rem;
}

.trunk-card .name {
  font-weight: 800;
  font-size: 1rem;
  margin: 0 0 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.trunk-card .desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.3;
}

.vote-badge {
  display: none;
  color: var(--orange-light);
}

.trunk-card.selected .vote-badge {
  display: inline;
}

/* Category chip bar (vote page) */

.category-bar {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding: 0.25rem 0.1rem 0.75rem;
  margin: -0.25rem -0.1rem 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.category-chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(45, 27, 78, 0.6);
  border: 2px solid rgba(255, 165, 77, 0.2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
}

.category-chip .chip-emoji {
  font-size: 1.1rem;
}

.category-chip .chip-check {
  display: none;
  color: var(--green);
  font-weight: 900;
}

.category-chip.voted .chip-check {
  display: inline;
}

.category-chip.active {
  border-color: var(--orange);
  background: linear-gradient(160deg, var(--orange) 0%, #cc4e00 100%);
  box-shadow: 0 6px 18px rgba(255, 117, 24, 0.35);
}

.category-chip:active {
  transform: scale(0.97);
}

.cat-badges {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.cat-badge {
  background: rgba(255, 165, 77, 0.18);
  border: 1px solid rgba(255, 165, 77, 0.35);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem 1rem;
}

.spinner {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}

/* Admin */

.status-pill {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.status-pill.active {
  background: rgba(46, 204, 113, 0.2);
  color: #7dffb0;
}

.status-pill.closed {
  background: rgba(255, 77, 77, 0.2);
  color: #ffb0b0;
}

.status-btn.current {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.status-pill.complete {
  background: rgba(255, 117, 24, 0.25);
  color: var(--orange-light);
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

table.tally {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.tally th,
table.tally td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}

table.tally img.thumb {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

table.tally .cat-count {
  text-align: center;
  color: var(--text-dim);
}

table.tally .actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.hidden-row {
  opacity: 0.45;
}

.editable-field {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  color: var(--text);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font-size: 0.9rem;
  width: 100%;
}

/* Share-this-page QR */

.qr-btn {
  background: transparent;
  border: 1px solid rgba(255, 165, 77, 0.5);
  color: var(--orange-light);
  border-radius: 12px;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
}

.qr-overlay {
  cursor: pointer;
}

.qr-card {
  background: #fff;
  border-radius: 20px;
  padding: 1.25rem;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.qr-card img {
  width: 100%;
  display: block;
  border-radius: 8px;
}

.qr-card .qr-url {
  color: #1a0d2e;
  font-weight: 800;
  margin-top: 0.6rem;
  word-break: break-all;
}

.qr-card .qr-hint {
  color: #6b5b8a;
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* Modal / dialog */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.overlay[hidden] {
  display: none !important;
}

.dialog {
  background: var(--purple);
  border: 1px solid rgba(255, 165, 77, 0.3);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
}

.dialog h2 {
  margin-top: 0;
  color: var(--orange-light);
}

.dialog .actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Reveal */

.reveal-stage {
  text-align: center;
  padding: 2rem 0;
}

.reveal-medal {
  font-size: 4rem;
  line-height: 1;
}

.reveal-photo {
  width: 100%;
  max-width: 360px;
  border-radius: 20px;
  margin: 1.25rem auto;
  display: block;
  box-shadow: 0 12px 40px rgba(255, 117, 24, 0.35);
}

.reveal-name {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0.5rem 0 0.25rem;
}

.reveal-desc {
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}

.reveal-fade {
  animation: reveal-fade-in 1s ease both;
}

.reveal-fade.dramatic {
  animation-duration: 2.4s;
  animation-delay: 0.5s;
}

@keyframes reveal-fade-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.btn.full.reveal-back {
  margin-top: 0.75rem;
}

.reveal-tapnote {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2rem;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

footer.foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 1rem;
}

.pin-gate {
  max-width: 320px;
  margin: 3rem auto;
  text-align: center;
}
