* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  height: 100vh;
  overflow: hidden;
  background: #000;
  font-family: Georgia, serif;
  color: #e8cf8a;
}

#bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #2a2410 0%, #000 70%);
  background-size: cover;
  background-position: center;
  filter: brightness(0.75);
  transform: scale(1.05);
  transition: transform 0.2s ease-out;
}

#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  box-shadow: inset 0 0 220px 90px rgba(0,0,0,0.9);
}

#fog {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(216,180,92,0.08), transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translateX(-2%) translateY(0); }
  to   { transform: translateX(2%) translateY(-1%); }
}

#overlayLayer {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
#overlayLayer > * {
  position: absolute;
  pointer-events: none;
}

#logo {
  position: fixed;
  top: 24px;
  right: 32px;
  height: 56px;
  cursor: pointer;
  filter: drop-shadow(0 0 6px rgba(216,180,92,0.5));
  transition: filter 0.3s ease, transform 0.3s ease;
  z-index: 10;
}
#logo:hover {
  filter: drop-shadow(0 0 18px rgba(216,180,92,0.9));
  transform: scale(1.05);
}

#settingsGear {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 10;
  font-size: 1.3rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 8px;
}
#settingsGear:hover,
#settingsGear:focus {
  opacity: 0.7;
}

#stage {
  position: relative;
  z-index: 5;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

.reveal {
  opacity: 0;
  animation: fadeUp 1.2s ease forwards;
}
#tagline.reveal { animation-delay: 0.4s; }

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

#title {
  font-size: clamp(1.5rem, 5vw, 3.5rem);
  letter-spacing: 0.12em;
  color: #d8b45c;
  text-shadow: 0 0 30px rgba(216,180,92,0.35);
  transition: opacity 0.4s ease, height 0.4s ease, margin 0.4s ease;
}

#tagline {
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #cbb37a;
  opacity: 0.85;
  min-height: 1.2em;
  transition: opacity 0.4s ease, height 0.4s ease, margin 0.4s ease;
}

#countdown {
  display: flex;
  gap: clamp(16px, 4vw, 48px);
  margin-top: 12px;
  transition: transform 0.6s ease;
  transform-origin: center;
  justify-content: center;
}
.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}
.unit.hidden { display: none !important; }
.unit span {
  font-size: clamp(3.5rem, 13vw, 10rem);
  font-weight: 900;
  color: #f5e3a8;
  text-shadow: 0 0 30px rgba(216,180,92,0.6);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.unit label {
  font-size: clamp(0.8rem, 1.5vw, 1.1rem);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #a8905a;
  margin-top: 8px;
}

#countdown[data-count="1"] .unit span { font-size: clamp(7rem, 48vw, 24rem); }
#countdown[data-count="2"] .unit span { font-size: clamp(5.5rem, 30vw, 17rem); }
#countdown[data-count="3"] .unit span { font-size: clamp(4.5rem, 20vw, 13rem); }
#countdown[data-count="4"] .unit span { font-size: clamp(3.5rem, 13vw, 10rem); }

#stage-label {
  margin-top: 6px;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #cbb37a;
  transition: opacity 0.3s ease;
}

#stage.zoom-mode #countdown { transform: scale(1.35); }
#stage.zoom-mode #title,
#stage.zoom-mode #tagline { opacity: 0; height: 0; overflow: hidden; margin: 0; }

#stage.wobble-mode #countdown { animation: wobble 0.5s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: scale(1.35) rotate(0deg); }
  25%      { transform: scale(1.4) rotate(-2.5deg); }
  75%      { transform: scale(1.4) rotate(2.5deg); }
}

#finalNumber {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8;
  align-items: center;
  justify-content: center;
  font-size: min(62vw, 72vh);
  font-weight: 900;
  color: #f5e3a8;
  text-shadow: 0 0 80px rgba(216,180,92,0.85);
  background: radial-gradient(ellipse at center, rgba(40,30,10,0.5), #000 75%);
}
#finalNumber.active { display: flex; animation: pulseNum 1s ease-in-out infinite; }
@keyframes pulseNum {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.1) rotate(1.5deg); }
}

#transitionOverlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: radial-gradient(circle, #fff6dd, #d8b45c 40%, #000 75%);
  opacity: 0;
  pointer-events: none;
}
#transitionOverlay.active { animation: flashZoom 1.2s ease forwards; }
@keyframes flashZoom {
  0%   { opacity: 0; transform: scale(0.2); }
  35%  { opacity: 1; transform: scale(1.3); }
  100% { opacity: 1; transform: scale(8); }
}

#trailerContainer { position: fixed; inset: 0; z-index: 25; background: #000; }
#trailerContainer iframe, #trailerContainer video {
  width: 100%; height: 100%; border: none; object-fit: cover;
}

#soundToggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(216,180,92,0.4);
  color: #e8cf8a;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.hidden { display: none !important; }

.admin-body { overflow-y: auto; height: auto; min-height: 100vh; }

#adminModal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #16130a;
  border: 1px solid rgba(216,180,92,0.4);
  padding: 32px; border-radius: 8px;
  display: flex; flex-direction: column; gap: 12px;
  width: min(90vw, 320px);
}
.modal-title { color: #d8b45c; text-align: center; letter-spacing: 0.1em; font-size: 1.2rem; }
.modal-sub { text-align: center; color: #a8905a; font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; margin-top: -8px; }
.modal-box input {
  background: #0d0b06; border: 1px solid rgba(216,180,92,0.3);
  color: #f0dfa8; padding: 10px 12px; border-radius: 4px; font-size: 1rem;
}
.modal-box button {
  background: #b8923f; color: #16130a; border: none;
  padding: 10px; border-radius: 4px; font-weight: 600; cursor: pointer;
}
.error { color: #e07a6b; font-size: 0.8rem; min-height: 1em; }

#adminPanel {
  position: relative; min-height: 100vh; z-index: 20;
  background: radial-gradient(ellipse at 50% 20%, #1a1608 0%, #000 75%);
  color: #f0dfa8;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 16px 60px;
}
.admin-card {
  background: #16130a;
  border: 1px solid rgba(216,180,92,0.35);
  border-radius: 12px; padding: 32px;
  width: 100%; max-width: 520px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
.admin-card h2 { color: #d8b45c; letter-spacing: 0.08em; text-align: center; margin-bottom: 20px; font-size: 1.4rem; }
.admin-card h3 {
  color: #d8b45c; letter-spacing: 0.05em; margin-top: 28px; margin-bottom: 8px;
  font-size: 1rem; border-top: 1px solid rgba(216,180,92,0.2); padding-top: 20px;
}
.back-btn {
  display: inline-block; background: none;
  border: 1px solid rgba(216,180,92,0.4); color: #e8cf8a;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; margin-bottom: 10px;
}
.back-btn:hover { border-color: #d8b45c; }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

#adminPanel label {
  display: block; margin: 14px 0 4px; font-size: 0.8rem;
  letter-spacing: 0.05em; color: #cbb37a; text-transform: uppercase;
}
#adminPanel input[type="text"],
#adminPanel input:not([type]),
#adminPanel input[type="datetime-local"],
#adminPanel input[type="number"],
#adminPanel select {
  width: 100%; padding: 10px; background: #0d0b06;
  border: 1px solid rgba(216,180,92,0.3); color: #f0dfa8;
  border-radius: 6px; font-size: 0.95rem;
}
.admin-checkbox {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: 0.85rem; color: #e8cf8a; text-transform: none; letter-spacing: 0;
}
.admin-checkbox input { width: auto; }

#adminPanel button.save {
  margin-top: 22px; width: 100%; padding: 12px;
  background: #b8923f; color: #16130a; border: none;
  border-radius: 6px; cursor: pointer; font-weight: 700; letter-spacing: 0.05em;
}
#saveStatus { text-align: center; margin-top: 10px; font-size: 0.85rem; }
#lastUpdated { text-align: center; margin-top: 4px; font-size: 0.75rem; color: #a8905a; }

.preview-wrap { width: 100%; max-width: 520px; margin-top: 24px; }
.preview-label { font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: #cbb37a; margin-bottom: 8px; text-align: center; }
.preview-frame-holder {
  width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid rgba(216,180,92,0.35); border-radius: 10px;
  overflow: hidden; background: #000;
}
.preview-frame-holder iframe {
  width: 300%; height: 300%; transform: scale(0.3333);
  transform-origin: top left; border: none;
}

/* Audio clip rows */
.clip-row {
  border: 1px solid rgba(216,180,92,0.25);
  border-radius: 8px; padding: 12px; margin-top: 10px; background: #0d0b06;
}
.clip-row .clip-relative { display: flex; gap: 8px; margin-top: 6px; }
.clip-row .clip-relative select,
.clip-row .clip-relative input { margin-top: 0; }

/* Overlay editor */
#overlayEditor {
  position: fixed; inset: 0; z-index: 50;
  background: #000; display: flex; flex-direction: column;
}
.editor-topbar {
  display: flex; gap: 10px; padding: 12px; background: #16130a;
  border-bottom: 1px solid rgba(216,180,92,0.3);
}
.editor-topbar button {
  background: #b8923f; color: #16130a; border: none;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 0.85rem;
}
.editor-topbar button#editorClose { background: none; border: 1px solid rgba(216,180,92,0.4); color: #e8cf8a; }
.editor-body { flex: 1; display: flex; overflow: hidden; }
#editorStage {
  flex: 1; position: relative; background-color: #111;
  background-size: cover; background-position: center;
  margin: 16px; border: 1px dashed rgba(216,180,92,0.4);
}
.editor-el {
  position: absolute; border: 1px dashed rgba(216,180,92,0.5);
  cursor: move; display: flex; align-items: center; justify-content: center;
  color: #f0dfa8; overflow: hidden; user-select: none;
}
.editor-el.selected { border: 2px solid #d8b45c; }
.resize-handle {
  position: absolute; right: -6px; bottom: -6px;
  width: 14px; height: 14px; background: #d8b45c;
  border-radius: 3px; cursor: nwse-resize;
}
#editorSidebar {
  width: 280px; background: #16130a; padding: 16px;
  border-left: 1px solid rgba(216,180,92,0.3); overflow-y: auto; color: #f0dfa8;
}
#editorSidebar label {
  display: block; margin: 10px 0 4px; font-size: 0.75rem;
  color: #cbb37a; text-transform: uppercase; letter-spacing: 0.05em;
}
#editorSidebar input {
  width: 100%; padding: 8px; background: #0d0b06;
  border: 1px solid rgba(216,180,92,0.3); color: #f0dfa8; border-radius: 4px;
}