:root {
  --sand: #f6efe3;
  --sea: #2a7f8f;
  --sea-dark: #1d5c68;
  --coral: #e07856;
  --ink: #233;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--sand);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  text-align: center;
  width: 320px;
}

.login-card h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.subtitle { color: #668; margin-bottom: 1.5rem; }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card label { text-align: left; font-size: 0.85rem; color: #557; }

input[type="password"], input[type="file"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid #ccd;
  border-radius: 8px;
  font-size: 1rem;
}

button, .btn {
  background: var(--sea);
  color: white;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

button:hover, .btn:hover { background: var(--sea-dark); }

.error { color: var(--coral); margin-top: 1rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.topbar h1 { font-size: 1.2rem; margin: 0; }
.back { text-decoration: none; color: var(--sea); margin-right: 0.5rem; }

.link-btn {
  background: none;
  color: #778;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}
.link-btn:hover { background: #eee; color: var(--ink); }

.container { max-width: 760px; margin: 0 auto; padding: 1.5rem; }
.container.wide { max-width: 980px; }
.intro { color: #557; }

.countdown-card {
  background: linear-gradient(135deg, var(--sea), var(--sea-dark));
  color: white;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
  box-shadow: 0 6px 20px rgba(29,92,104,0.3);
}

.countdown-label {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.countdown-timer[hidden] {
  display: none;
}

.countdown-timer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

.cd-unit { display: flex; flex-direction: column; align-items: center; min-width: 2.5rem; }
.cd-num { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cd-unit-label { font-size: 0.7rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }

.countdown-date {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  opacity: 0.8;
}

.countdown-done {
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.5rem 0;
}

.gallery-cta {
  display: block;
  background: linear-gradient(135deg, var(--coral), #f0a46a);
  color: white;
  text-decoration: none;
  text-align: center;
  font-weight: 600;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 14px rgba(224,120,86,0.3);
}
.gallery-cta:hover { filter: brightness(1.05); }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.folder-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.folder-card:hover { transform: translateY(-2px); transition: 0.15s; }
.folder-icon { font-size: 1.8rem; }
.folder-name { font-weight: 600; }
.folder-count { font-size: 0.8rem; color: #789; }

.upload-form {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.folder-actions { margin-bottom: 1rem; }

.file-list { list-style: none; padding: 0; margin: 0; }

.file-list li {
  background: white;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.file-name { flex: 1; word-break: break-all; }
.file-size { color: #789; font-size: 0.8rem; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.btn.outline {
  background: transparent;
  color: var(--sea);
  border: 1px solid var(--sea);
}
.btn.outline:hover { background: var(--sea); color: white; }

.empty { color: #789; margin-top: 2rem; text-align: center; }

/* --- Leaderboard --- */

.leaderboard {
  background: white;
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.leaderboard h2 { margin-top: 0; font-size: 1.1rem; }

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  counter-reset: none;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.leaderboard-list li:last-child { border-bottom: none; }

.leaderboard-list li.is-leader { background: #fff8ef; border-radius: 8px; padding-left: 0.5rem; }

.lb-rank {
  width: 1.5rem;
  font-weight: 700;
  color: #99a;
  text-align: center;
}

.lb-name { flex: 1; font-weight: 600; }
.trophy { margin-left: 0.25rem; }
.lb-count { color: #789; font-size: 0.9rem; }

.prize-note {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  background: #fff8ef;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--ink);
}

/* --- Gallery grid --- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.gallery-tile {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.gallery-tile img,
.gallery-tile video,
.gallery-tile .file-tile {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #e5ded0;
}

.gallery-tile .file-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.gallery-tile a { position: relative; display: block; }

.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.55);
  color: white;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.gallery-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  gap: 0.5rem;
}

.gallery-uploader {
  font-size: 0.8rem;
  font-weight: 600;
  color: #557;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.gallery-header h2 { margin: 0; }

/* --- Slideshow overlay --- */

.slideshow-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.95);
  z-index: 1000;
  display: none; /* overridden below when not [hidden] — an unconditional
                     display:flex here would beat the browser's built-in
                     [hidden]{display:none} rule and show it by default */
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.slideshow-overlay:not([hidden]) {
  display: flex;
}

.ss-stage {
  max-width: 92vw;
  max-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ss-stage img,
.ss-stage video {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.ss-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: white;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.ss-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.ss-nav:hover { background: rgba(255,255,255,0.25); }
.ss-prev { left: 1rem; }
.ss-next { right: 1rem; }

.ss-footer {
  position: absolute;
  bottom: 1.25rem;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  color: #ddd;
  font-size: 0.9rem;
}

.ss-play {
  background: rgba(255,255,255,0.12);
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
}

.ss-play:hover { background: rgba(255,255,255,0.25); }
