/* ============================================================
   Greer Farm Pumpkin Party — Halloween theme (phone-first)
   ============================================================ */
:root {
  --bg-0: #0b0712;
  --bg-1: #150d24;
  --pumpkin: #ff7a18;
  --pumpkin-2: #ff9f45;
  --purple: #7b2ff7;
  --purple-2: #b14aed;
  --slime: #8bff5a;
  --bone: #f4ecda;
  --muted: #b9a9d6;
  --card: rgba(28, 18, 46, 0.72);
  --card-border: rgba(177, 74, 237, 0.32);
  --danger: #ff4d5e;
  --ok: #56d364;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--bone);
  background:
    radial-gradient(1200px 700px at 80% -10%, #2a1650 0%, transparent 60%),
    radial-gradient(900px 600px at 0% 10%, #3a1d2b 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

a { color: var(--pumpkin-2); text-decoration: none; }
h1, h2, h3 { line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.display { font-family: "Creepster", cursive; font-weight: 400; letter-spacing: 1.5px; }

/* ---------- decorative sky ---------- */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.moon {
  position: absolute; top: -60px; right: -40px; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7e0, #ffd87a 60%, #e8a93b 100%);
  box-shadow: 0 0 90px 30px rgba(255, 196, 92, 0.35);
  opacity: 0.85;
}
.fog {
  position: absolute; bottom: 0; left: -10%; width: 120%; height: 220px;
  background: radial-gradient(closest-side, rgba(123, 47, 247, 0.18), transparent);
  filter: blur(20px); animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
.bat {
  position: absolute; font-size: 26px; opacity: 0.8;
  animation: fly 16s linear infinite;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}
.bat1 { top: 12%; animation-duration: 19s; }
.bat2 { top: 26%; font-size: 18px; animation-duration: 24s; animation-delay: -6s; opacity: 0.6; }
.bat3 { top: 40%; font-size: 32px; animation-duration: 28s; animation-delay: -12s; opacity: 0.5; }
@keyframes fly {
  0%   { transform: translateX(-12vw) translateY(0) scaleX(1); }
  50%  { transform: translateX(60vw) translateY(-24px) scaleX(1); }
  100% { transform: translateX(118vw) translateY(10px) scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .bat, .fog { animation: none; }
}

/* ---------- layout ---------- */
.wrap { max-width: 820px; margin: 0 auto; padding: 14px 16px 24px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px calc(10px); padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(11, 7, 18, 0.92), rgba(11, 7, 18, 0.55));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--bone); min-width: 0; }
.brand-pumpkin { font-size: 26px; filter: drop-shadow(0 0 10px rgba(255, 122, 24, 0.7)); animation: flicker 4s infinite; }
.brand-text {
  font-family: "Creepster", cursive; font-size: 1.45rem; letter-spacing: 1px;
  color: var(--pumpkin-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 12px rgba(255, 122, 24, 0.5);
}
@keyframes flicker { 0%,100%{opacity:1} 45%{opacity:.85} 50%{opacity:.55} 55%{opacity:.9} }
.host-link {
  flex: none; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 0.9rem;
  border: 1px solid var(--card-border); color: var(--muted); background: rgba(255,255,255,0.03);
}
.host-link.is-on { color: #111; background: var(--slime); border-color: var(--slime); }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(11,7,18,0.98), rgba(11,7,18,0.82));
  backdrop-filter: blur(10px); border-top: 1px solid var(--card-border);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-weight: 700; padding: 4px 0; border-radius: 12px;
}
.bottomnav a span { font-size: 22px; }
.bottomnav a small { font-size: 0.7rem; }
.bottomnav a.active { color: var(--pumpkin-2); background: rgba(255, 122, 24, 0.12); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-family: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
  color: var(--bone); background: rgba(255,255,255,0.06); transition: transform .06s ease, filter .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { color: #2a1500; background: linear-gradient(180deg, var(--pumpkin-2), var(--pumpkin)); box-shadow: 0 6px 18px rgba(255,122,24,0.35); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: rgba(177, 74, 237, 0.12); border-color: var(--card-border); color: var(--bone); }
.btn-danger { background: linear-gradient(180deg, #ff6b78, var(--danger)); color: #2a0006; }
.btn-voted { background: rgba(86, 211, 100, 0.18); border-color: rgba(86,211,100,0.5); color: var(--slime); }
.btn-block { width: 100%; }
.btn-tiny { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }
.btn[disabled] { opacity: 0.85; cursor: default; }

/* ---------- inputs ---------- */
.input {
  width: 100%; min-height: 50px; padding: 12px 14px; font-family: inherit; font-size: 1rem;
  color: var(--bone); background: rgba(0,0,0,0.3); border: 1px solid var(--card-border);
  border-radius: 12px; outline: none;
}
.input:focus { border-color: var(--pumpkin); box-shadow: 0 0 0 3px rgba(255,122,24,0.2); }
select.input { appearance: none; background-image: linear-gradient(180deg, rgba(0,0,0,0.3), rgba(0,0,0,0.3)); }
.input-tiny { min-height: 38px; width: 80px; padding: 6px 8px; }
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 800; margin-bottom: 6px; color: var(--bone); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
  backdrop-filter: blur(4px);
}
.section-title { font-family: "Creepster", cursive; font-weight: 400; font-size: 1.9rem; color: var(--pumpkin-2); margin: 8px 0 14px; letter-spacing: 1px; text-shadow: 0 0 14px rgba(255,122,24,0.35); }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 14px; display: grid; gap: 8px; }
.flash { padding: 12px 14px; border-radius: 12px; font-weight: 700; border: 1px solid; }
.flash-error { background: rgba(255,77,94,0.14); border-color: rgba(255,77,94,0.5); color: #ffc2c8; }
.flash-ok { background: rgba(86,211,100,0.14); border-color: rgba(86,211,100,0.5); color: #c7f5cd; }

/* ---------- hero / home ---------- */
.hero { text-align: center; padding: 14px 6px 6px; }
.hero-title { font-size: 2.6rem; color: var(--pumpkin-2); text-shadow: 0 0 18px rgba(255,122,24,0.5); margin: 0 0 10px; }
.lead { font-size: 1.08rem; color: var(--bone); max-width: 520px; margin: 0 auto 18px; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 0 auto 8px; }

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.cat-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 18px 12px; border-radius: var(--radius); color: var(--bone);
  background: var(--card); border: 1px solid var(--card-border); box-shadow: var(--shadow);
}
.cat-card:hover { border-color: var(--pumpkin); }
.cat-emoji { font-size: 40px; filter: drop-shadow(0 0 10px rgba(177,74,237,0.5)); }
.cat-label { font-weight: 800; }
.cat-count { font-size: 0.82rem; color: var(--muted); }

.howto ol { padding-left: 1.1rem; margin: 8px 0; }
.howto li { margin: 8px 0; }

/* ---------- category sections / grid ---------- */
.cat-section { scroll-margin-top: 70px; margin-bottom: 26px; }
.cat-heading { font-size: 1.25rem; margin: 6px 0 12px; border-left: 4px solid var(--pumpkin); padding-left: 10px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.entry {
  display: flex; flex-direction: column; gap: 8px; padding: 8px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 14px;
}
.entry-img { position: relative; border-radius: 10px; overflow: hidden; background: #0c0a14; }
.entry-img img { width: 100%; height: auto; display: block; }
.entry-name { font-weight: 800; font-size: 0.95rem; text-align: center; word-break: break-word; }
.entry.is-voted { border-color: var(--slime); box-shadow: 0 0 0 2px rgba(139,255,90,0.25); }
.entry.is-winner { border-color: #ffd24a; box-shadow: 0 0 0 2px rgba(255,210,74,0.4), 0 8px 26px rgba(255,184,0,0.25); }
.ribbon, .crown {
  position: absolute; top: 8px; left: 8px; padding: 4px 8px; border-radius: 8px;
  font-size: 0.74rem; font-weight: 800;
}
.ribbon { background: var(--slime); color: #06310a; }
.crown { background: #ffd24a; color: #3a2a00; }
.vote-count { text-align: center; font-weight: 800; color: var(--pumpkin-2); }

.owner-tools { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.owner-tools form { margin: 0; }
.admin-tools .adjust { display: flex; gap: 4px; align-items: center; }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: 12px; margin: 6px 0 12px; font-weight: 700;
}
.banner form { margin: 0; }
.banner-voted { background: rgba(139,255,90,0.1); border: 1px solid rgba(139,255,90,0.4); }
.banner-closed { background: rgba(255,210,74,0.12); border: 1px solid rgba(255,210,74,0.5); }
.empty { color: var(--muted); padding: 6px 2px 14px; }

/* ---------- gate page ---------- */
.gate-page { display: grid; place-items: center; padding: 20px; }
.gate-page .wrap { display: grid; place-items: center; min-height: 80vh; }
.gate-card {
  width: 100%; max-width: 420px; text-align: center; padding: 28px 22px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 20px; box-shadow: var(--shadow);
}
.gate-jack { font-size: 64px; filter: drop-shadow(0 0 18px rgba(255,122,24,0.7)); animation: flicker 3s infinite; }
.gate-card .display { font-size: 2.1rem; color: var(--pumpkin-2); margin: 6px 0; text-shadow: 0 0 16px rgba(255,122,24,0.5); }
.gate-form { display: grid; gap: 12px; margin-top: 14px; }

/* ---------- results locked / voting control ---------- */
.locked-card { text-align: center; }
.locked-emoji { font-size: 56px; margin-bottom: 6px; }
.locked-card .btn { margin-top: 12px; }
.voting-control { display: grid; gap: 12px; }
.voting-control.open { border-color: rgba(86,211,100,0.5); }
.voting-control.closed { border-color: rgba(255,210,74,0.6); }
.vc-status { font-family: "Creepster", cursive; font-size: 1.5rem; letter-spacing: 1px; }
.admin-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-bar form { margin: 0; }

/* ---------- upload form: file picker + rotate preview ---------- */
.upload-form { display: grid; }
.filepick {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 70px; padding: 14px; border-radius: 12px; cursor: pointer; font-weight: 800;
  color: var(--pumpkin-2); background: rgba(255,122,24,0.08);
  border: 2px dashed var(--card-border);
}
.filepick.has-file { color: var(--slime); border-color: rgba(139,255,90,0.5); background: rgba(139,255,90,0.08); }
.preview-wrap { margin: 4px 0 16px; display: grid; gap: 10px; }
.preview-box {
  aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: #0c0a14;
  display: grid; place-items: center; border: 1px solid var(--card-border);
}
/* Square box + contain = the whole photo is always visible, and a 90° rotation
   always fits (no clipping), so the preview matches what voters will see. */
#preview { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .2s ease; }
.rotate-row { display: flex; gap: 10px; }
.rotate-row .btn { flex: 1; }
