/* ════════════════ BASE — Tracx brand palette ════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy: #183050;        /* Tracx Dark Blue */
  --deep-navy: #0d1e33;   /* Deeper Navy */
  --blue: #468ad4;        /* Tracx Light Blue */
  --pale-blue: #c2daf2;   /* Pale Blue */
  --cool-white: #f4f6f9;  /* Cool White */
  --blue-grey: #7a8a9a;   /* Blue-Grey */
  --green: #2dc47a;       /* Accent Green */
  --gold: #fbbf24;
  --ink: #0d1e33;
  --card: rgba(255, 255, 255, 0.94);
  --shadow: 0 10px 34px rgba(13, 30, 51, 0.18);
  --radius: 22px;
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, .tab, .btn-primary, .ms-btn { font-family: 'Fredoka', 'Nunito', sans-serif; }

.hidden { display: none !important; }

/* animated gradient background — cool blues with a hint of green */
#bg-gradient {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(-45deg, #eaf1f9, #c2daf2, #d7f3e6, #f4f6f9, #cfe2f6, #eaf1f9);
  background-size: 400% 400%;
  animation: gradient-drift 20s ease infinite;
}
@keyframes gradient-drift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* floating emoji */
#floaties { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.floaty {
  position: absolute; bottom: -12vh;
  font-size: 2rem; opacity: 0.3;
  animation: float-up linear infinite;
}
@keyframes float-up {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(-120vh) rotate(360deg); }
}

/* ════════════════ LOGIN ════════════════ */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: var(--card); border-radius: 32px; box-shadow: var(--shadow);
  border-top: 6px solid var(--blue);
  padding: 44px 48px 48px; text-align: center; max-width: 540px; width: 100%;
  position: relative;
  animation: pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.login-logo { height: 44px; margin-bottom: 14px; }
.login-trucky {
  width: 170px; margin: 10px auto 0; display: block;
  animation: trucky-bounce 3s ease-in-out infinite;
}
@keyframes trucky-bounce {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
.login-emoji-ring { position: absolute; inset: 0; pointer-events: none; }
.login-emoji-ring span {
  position: absolute; font-size: 1.9rem;
  animation: bob 3s ease-in-out infinite;
}
.login-emoji-ring span:nth-child(1) { top: -18px; left: 8%; animation-delay: 0s; }
.login-emoji-ring span:nth-child(2) { top: -22px; right: 12%; animation-delay: 0.4s; }
.login-emoji-ring span:nth-child(3) { top: 30%; left: -20px; animation-delay: 0.8s; }
.login-emoji-ring span:nth-child(4) { top: 34%; right: -20px; animation-delay: 1.2s; }
.login-emoji-ring span:nth-child(5) { bottom: 22%; left: -16px; animation-delay: 1.6s; }
.login-emoji-ring span:nth-child(6) { bottom: 20%; right: -16px; animation-delay: 2s; }
.login-emoji-ring span:nth-child(7) { bottom: -20px; left: 18%; animation-delay: 2.4s; }
.login-emoji-ring span:nth-child(8) { bottom: -18px; right: 20%; animation-delay: 2.8s; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-12px) rotate(8deg); }
}
.login-title { font-size: 2.5rem; line-height: 1.1; font-weight: 700; color: var(--navy); }
.rainbow-text {
  background: linear-gradient(90deg, var(--blue), var(--green), var(--navy), var(--blue));
  background-size: 300% auto;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbow-slide 5s linear infinite;
}
@keyframes rainbow-slide { to { background-position: 300% center; } }
.login-tagline { margin: 16px 0 28px; font-size: 1.06rem; color: var(--blue-grey); font-weight: 700; }

.ms-btn {
  display: inline-flex; align-items: center; gap: 12px;
  background: #fff; color: var(--navy); border: 2px solid var(--pale-blue);
  font-size: 1.1rem; font-weight: 600; padding: 14px 28px; border-radius: 14px;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.ms-btn:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 8px 20px rgba(13,30,51,0.18); border-color: var(--blue); }

#dev-login-form { display: flex; flex-direction: column; gap: 14px; }
.dev-banner {
  background: #fff7e0; border: 2px dashed var(--gold); border-radius: 12px;
  padding: 10px; font-size: 0.9rem; font-weight: 700;
}
#dev-name {
  font-family: inherit; font-size: 1.1rem; padding: 14px 18px;
  border: 2px solid var(--pale-blue); border-radius: 14px; outline: none; text-align: center;
}
#dev-name:focus { border-color: var(--blue); }

/* ════════════════ BUTTONS ════════════════ */
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: #fff; border: none; font-size: 1.05rem; font-weight: 600;
  padding: 13px 26px; border-radius: 14px; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 6px 18px rgba(70, 138, 212, 0.45);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-3px) scale(1.04); filter: brightness(1.12); }
.btn-primary:active:not(:disabled) { transform: scale(0.96); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-big { font-size: 1.25rem; padding: 16px 34px; }
.btn-ghost {
  background: transparent; border: 2px solid var(--pale-blue); color: var(--navy);
  padding: 9px 18px; border-radius: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.icon-btn {
  background: var(--card); border: none; font-size: 1.25rem; width: 44px; height: 44px;
  border-radius: 50%; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.15s;
}
.icon-btn:hover { transform: scale(1.15) rotate(-8deg); }

/* ════════════════ HEADER / TABS ════════════════ */
#app { max-width: 1200px; margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 80px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 22px;
  background: linear-gradient(120deg, var(--deep-navy), var(--navy) 55%, #1e4470);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px clamp(16px, 2.5vw, 26px);
  position: relative; overflow: hidden;
}
header::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 45%, rgba(70, 138, 212, 0.25) 50%, transparent 55%);
  animation: header-shine 6s linear infinite;
}
@keyframes header-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.header-brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.header-logo { height: 30px; flex-shrink: 0; }
.app-title {
  font-size: clamp(1.1rem, 2.8vw, 1.7rem); font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-right { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(194, 218, 242, 0.35);
  border-radius: 999px; padding: 5px 8px 5px 5px;
}
.avatar-img, .avatar-fallback {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: #fff; font-weight: 900; font-size: 0.92rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
}
.avatar-sm.avatar-img, .avatar-sm.avatar-fallback {
  width: 26px; height: 26px; font-size: 0.68rem; border-width: 1.5px;
}
#user-name { font-weight: 800; font-size: 0.95rem; color: #fff; }
.logout-btn {
  background: none; border: none; color: var(--pale-blue); font-weight: 800;
  cursor: pointer; font-size: 0.85rem; font-family: inherit; padding: 4px 8px;
}
.logout-btn:hover { text-decoration: underline; color: #fff; }

.tabs {
  display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap;
}
.tab {
  background: rgba(255,255,255,0.7); border: none; font-size: 1.02rem; font-weight: 600;
  padding: 12px 22px; border-radius: 999px; cursor: pointer; color: var(--navy);
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.tab:hover { transform: translateY(-2px); }
.tab.active {
  background: linear-gradient(135deg, var(--blue), var(--navy));
  color: #fff; box-shadow: 0 6px 18px rgba(24, 48, 80, 0.4);
  animation: tab-bounce 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes tab-bounce { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }

/* ════════════════ GALLERY ════════════════ */
.vote-status {
  text-align: center; font-weight: 800; margin-bottom: 20px; font-size: 1.05rem;
  min-height: 1.4em; color: var(--navy);
}
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px;
}
.pic-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; position: relative;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s;
  animation: card-enter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.pic-card:nth-child(2n) { animation-delay: 0.06s; }
.pic-card:nth-child(3n) { animation-delay: 0.12s; }
@keyframes card-enter {
  from { transform: translateY(30px) scale(0.9); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.pic-card:hover {
  transform: translateY(-8px) rotate(-1.2deg) scale(1.02);
  box-shadow: 0 18px 44px rgba(13, 30, 51, 0.28);
  z-index: 2;
}
.pic-card.voted-card { outline: 4px solid var(--green); outline-offset: -4px; }
.pic-img-wrap { aspect-ratio: 1; overflow: hidden; background: var(--cool-white); position: relative; }
.pic-img-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.4s ease;
}
.pic-card:hover .pic-img-wrap img { transform: scale(1.08) rotate(1deg); }
.mine-badge {
  position: absolute; top: 12px; left: 12px;
  background: var(--gold); color: var(--deep-navy); font-weight: 900; font-size: 0.78rem;
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  transform: rotate(-4deg);
}
.leader-badge {
  position: absolute; top: 10px; right: 10px; font-size: 1.7rem;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
  animation: badge-wiggle 2.2s ease-in-out infinite;
}
@keyframes badge-wiggle {
  0%, 100% { transform: rotate(-10deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.15); }
}
.pic-info { padding: 14px 16px 16px; }
.pic-caption { font-weight: 800; font-size: 1.02rem; min-height: 1.3em; word-wrap: break-word; }
.pic-owner {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.88rem; color: var(--blue-grey); font-weight: 700; margin-top: 6px;
}
.pic-actions {
  display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px;
}
.vote-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--cool-white);
  border: 2px solid var(--pale-blue); color: var(--navy);
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1rem;
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.vote-btn:hover:not(:disabled) { transform: scale(1.1); border-color: var(--green); }
.vote-btn:active:not(:disabled) { transform: scale(0.92); }
.vote-btn.voted {
  background: linear-gradient(135deg, var(--green), #1da463); color: #fff; border-color: transparent;
  animation: heart-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes heart-pop {
  0% { transform: scale(0.6); } 55% { transform: scale(1.25); } 100% { transform: scale(1); }
}
.vote-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.vote-count {
  font-weight: 900; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 5px;
  color: var(--navy);
}
.vote-count.bump { animation: count-bump 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes count-bump {
  0% { transform: scale(1); } 40% { transform: scale(1.6) rotate(6deg); color: var(--green); } 100% { transform: scale(1); }
}
.delete-btn {
  background: none; border: none; font-size: 1.05rem; cursor: pointer; opacity: 0.45;
  transition: opacity 0.15s, transform 0.15s;
}
.delete-btn:hover { opacity: 1; transform: scale(1.2); }

/* ════════════════ PODIUM ════════════════ */
.podium-heading {
  text-align: center; font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 700; margin-bottom: 6px;
  color: var(--navy);
}
.podium-sub { text-align: center; font-weight: 700; color: var(--blue-grey); margin-bottom: 34px; }
.podium {
  display: flex; align-items: flex-end; justify-content: center;
  gap: clamp(10px, 3vw, 28px); flex-wrap: wrap;
}
.podium-spot { display: flex; flex-direction: column; align-items: center; width: clamp(150px, 26vw, 230px); }
.podium-spot.place-1 { order: 2; }
.podium-spot.place-2 { order: 1; }
.podium-spot.place-3 { order: 3; }
.podium-pic {
  width: clamp(110px, 20vw, 170px); height: clamp(110px, 20vw, 170px);
  border-radius: 50%; object-fit: cover; border: 6px solid #fff;
  box-shadow: 0 10px 30px rgba(13,30,51,0.32);
  animation: podium-drop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.place-1 .podium-pic { border-color: var(--gold); animation-delay: 0.5s; }
.place-2 .podium-pic { border-color: #c0c7d6; animation-delay: 0.2s; }
.place-3 .podium-pic { border-color: #d9975c; animation-delay: 0.35s; }
@keyframes podium-drop {
  from { transform: translateY(-60px) scale(0.5); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.podium-crown {
  font-size: 2.6rem; margin-bottom: -14px; z-index: 2;
  animation: crown-float 2.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}
@keyframes crown-float {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-9px) rotate(6deg); }
}
.podium-medal { font-size: 2rem; margin: 8px 0 2px; }
.podium-name {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-weight: 900; font-size: 1.08rem; text-align: center; word-break: break-word;
  color: var(--navy);
}
.podium-caption { font-size: 0.85rem; color: var(--blue-grey); font-weight: 700; text-align: center; margin-bottom: 4px; word-break: break-word; }
.podium-votes { font-weight: 900; color: var(--blue); margin-bottom: 12px; }
.podium-block {
  width: 100%; border-radius: 16px 16px 0 0;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900; color: rgba(255,255,255,0.9);
  font-family: 'Fredoka', sans-serif;
  animation: block-rise 0.8s cubic-bezier(0.25, 1, 0.5, 1) backwards;
  transform-origin: bottom;
}
@keyframes block-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.place-1 .podium-block {
  height: 190px; background: linear-gradient(180deg, #ffd76e, #f5a623);
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.6); animation-delay: 0.4s;
}
.place-2 .podium-block { height: 140px; background: linear-gradient(180deg, #dde3ee, #9aa5bc); animation-delay: 0.1s; }
.place-3 .podium-block { height: 105px; background: linear-gradient(180deg, #e8b184, #b26f3d); animation-delay: 0.25s; }
.place-1 .podium-block { position: relative; overflow: hidden; }
.place-1 .podium-block::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.55) 50%, transparent 60%);
  animation: shimmer 2.8s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ════════════════ UPLOAD ════════════════ */
.upload-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 6px solid var(--green);
  max-width: 560px; margin: 0 auto; padding: 34px; display: flex; flex-direction: column; gap: 18px;
  position: relative;
}
.upload-trucky {
  position: absolute; top: -34px; right: -26px; width: 110px;
  transform: rotate(8deg);
  animation: trucky-bounce 3.5s ease-in-out infinite;
  pointer-events: none;
}
.upload-card h2 { text-align: center; font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.dropzone {
  border: 3px dashed rgba(70, 138, 212, 0.55); border-radius: 18px;
  padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--green); background: rgba(45, 196, 122, 0.07); transform: scale(1.015);
}
.dropzone.dragover { animation: drop-pulse 0.8s ease infinite; }
@keyframes drop-pulse {
  0%, 100% { transform: scale(1.015); } 50% { transform: scale(1.045); }
}
.drop-emoji { font-size: 3.2rem; margin-bottom: 8px; animation: bob 2.5s ease-in-out infinite; }
.drop-or { color: var(--blue-grey); margin: 10px 0; font-weight: 700; }
#drop-preview img {
  max-width: 100%; max-height: 300px; border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px;
}
#caption-input {
  font-family: inherit; font-size: 1.05rem; font-weight: 700; padding: 14px 18px;
  border: 2px solid var(--pale-blue); border-radius: 14px; outline: none;
}
#caption-input:focus { border-color: var(--blue); }
.upload-hint { text-align: center; font-size: 0.85rem; color: var(--blue-grey); font-weight: 700; }

/* ════════════════ EMPTY STATES / TOASTS ════════════════ */
.empty-state { text-align: center; padding: 50px 20px; font-weight: 800; font-size: 1.1rem; color: var(--navy); }
.empty-img {
  width: 180px; margin-bottom: 14px;
  animation: trucky-bounce 3s ease-in-out infinite;
}

#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px; z-index: 100; align-items: center;
}
.toast {
  background: var(--navy); color: #fff; font-weight: 800; padding: 13px 24px;
  border-radius: 999px; box-shadow: 0 10px 30px rgba(13,30,51,0.4);
  border: 1px solid rgba(70, 138, 212, 0.5);
  animation: toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 90vw; text-align: center;
}
.toast.error { background: #c22f4e; border-color: transparent; }
@keyframes toast-in {
  from { transform: translateY(30px) scale(0.8); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.toast.bye { animation: toast-out 0.35s ease forwards; }
@keyframes toast-out { to { transform: translateY(20px); opacity: 0; } }

@media (max-width: 560px) {
  .login-card { padding: 40px 24px; }
  .podium-spot { width: 30vw; }
  .upload-trucky { width: 80px; top: -26px; right: -10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}
