/* ── Reset ──────────────────────────────────────────────────────────────────── */

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

[hidden] { display: none !important; }

/* ── Base ───────────────────────────────────────────────────────────────────── */

html {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(160deg, #fff7ed, #fde8cc);
  background-attachment: fixed;
  color: #1a202c;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Checkpoint view ────────────────────────────────────────────────────────── */

#checkpoint-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  gap: 1.75rem;
  text-align: center;
}

/* ── Puzzle phase ───────────────────────────────────────────────────────────── */

#puzzle-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

#puzzle-title {
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  color: #1a202c;
}

#puzzle-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 480px;
}

#puzzle-text {
  font-size: 1rem;
  color: #4a5568;
  line-height: 1.75;
  max-width: 420px;
}

#puzzle-image {
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 1rem;
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ── Assignment phase ───────────────────────────────────────────────────────── */

#assignment-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 100%;
}

#assignment-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: 480px;
}

#assignment-text {
  font-size: 1rem;
  color: #4a5568;
  line-height: 1.75;
  max-width: 420px;
}

#assignment-image {
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 1rem;
  display: block;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ── Labels ─────────────────────────────────────────────────────────────────── */

.label {
  font-size: 0.85rem;
  color: #f97316;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

/* ── Destination name — the big reveal ──────────────────────────────────────── */

#destination-name {
  font-size: clamp(2.8rem, 14vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  background: linear-gradient(135deg, #f97316, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  word-break: break-word;
  hyphens: auto;
}

/* ── Registration view ──────────────────────────────────────────────────────── */

#registration-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  gap: 1.5rem;
  text-align: center;
}

.reg-title {
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-weight: 800;
  line-height: 1.15;
  color: #1a202c;
}

/* ── Inputs ─────────────────────────────────────────────────────────────────── */

.team-input {
  width: 100%;
  max-width: 420px;
  padding: 0.9rem 1.25rem;
  font-size: 1.1rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.875rem;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background: #fff;
  color: #1a202c;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.team-input:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.team-input::placeholder {
  color: #d1d5db;
}

/* ── Primary button ─────────────────────────────────────────────────────────── */

.primary-btn,
#next-btn {
  width: 100%;
  max-width: 420px;
  padding: 1.1rem 1.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  border: none;
  border-radius: 0.875rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
  transition: opacity 0.12s, transform 0.1s;
}

.primary-btn:disabled,
#next-btn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  box-shadow: none;
  cursor: not-allowed;
}

.primary-btn:not(:disabled):hover,
#next-btn:not(:disabled):hover {
  opacity: 0.9;
}

.primary-btn:not(:disabled):active,
#next-btn:not(:disabled):active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* ── Status message ─────────────────────────────────────────────────────────── */

.status {
  font-size: 1.05rem;
  color: #718096;
  min-height: 1.5em;
}

.status.reached {
  color: #059669;
  font-weight: 600;
}

.status.error {
  color: #dc2626;
}

/* ── Progress / refresh ─────────────────────────────────────────────────────── */

.progress {
  font-size: 0.875rem;
  color: #a0aec0;
}

.refresh-info {
  font-size: 0.8rem;
  color: #d1d5db;
  visibility: hidden;
}

/* ── Final view ─────────────────────────────────────────────────────────────── */

#final-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  gap: 1.25rem;
  text-align: center;
}

.final-complete {
  font-size: 1.75rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f97316, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.final-go-to {
  font-size: 0.85rem;
  color: #f97316;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.final-address {
  font-size: clamp(1.4rem, 7vw, 2.5rem);
  font-weight: 800;
  color: #1a202c;
  line-height: 1.3;
  padding: 1.5rem 2rem;
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 0 0 2px #f97316, 0 4px 24px rgba(249, 115, 22, 0.15);
  max-width: 480px;
  width: 100%;
}

/* ── Secondary and link buttons ─────────────────────────────────────────────── */

.secondary-btn {
  width: calc(100% - 3rem);
  max-width: 420px;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  background: transparent;
  color: #f97316;
  border: 2px solid #f97316;
  border-radius: 0.75rem;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: background 0.12s;
}

.secondary-btn:hover {
  background: #fff7ed;
}

.link-btn {
  background: none;
  border: none;
  color: #f97316;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.25rem;
  touch-action: manipulation;
}

#leaderboard-btn {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(249, 115, 22, 0.35);
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  transition: opacity 0.12s;
}

#leaderboard-btn:hover {
  opacity: 0.9;
}

/* ── Answer section ─────────────────────────────────────────────────────────── */

#answer-section {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.answer-input {
  width: 100%;
  padding: 0.9rem 1.25rem;
  font-size: 1.1rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.875rem;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background: #fff;
  color: #1a202c;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.answer-input:focus {
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.answer-input::placeholder {
  color: #d1d5db;
}

.answer-feedback {
  font-size: 0.9rem;
  color: #dc2626;
  text-align: center;
}

/* ── Leaderboard panel ──────────────────────────────────────────────────────── */

#leaderboard-panel {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

.panel-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1a202c;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #9ca3af;
  padding: 0.25rem 0.5rem;
  touch-action: manipulation;
}

.close-btn:hover {
  color: #1a202c;
}

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0.5rem 0;
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid #f9fafb;
}

.lb-entry:last-child {
  border-bottom: none;
}

.lb-self {
  background: #fff7ed;
}

.lb-rank {
  font-size: 0.875rem;
  font-weight: 700;
  color: #d1d5db;
  width: 1.5rem;
  flex-shrink: 0;
  text-align: right;
}

.lb-self .lb-rank {
  color: #f97316;
}

.lb-name {
  flex: 1;
  font-weight: 500;
  color: #1a202c;
}

.lb-self .lb-name {
  font-weight: 700;
  color: #f97316;
}

.lb-step {
  font-size: 0.875rem;
  color: #9ca3af;
  flex-shrink: 0;
}

.leaderboard-msg {
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  color: #9ca3af;
  text-align: center;
  flex-shrink: 0;
}

.panel-footer {
  padding: 0.75rem 1.5rem 1.5rem;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Easter eggs ─────────────────────────────────────────────────────────────── */

#easter-duck {
  position: fixed;
  right: 0;
  top: 40vh;
  width: 80px;
  height: auto;
  z-index: 200;
  pointer-events: none;
  transform: translateX(110%);
  will-change: transform;
}

#easter-clog {
  position: fixed;
  top: 14px;
  left: -110px;
  width: 72px;
  height: auto;
  z-index: 200;
  pointer-events: none;
  will-change: transform;
}

@keyframes duck-peek-right {
  0%   { transform: translateX(110%);               }
  15%  { transform: translateX(20%) rotate(-35deg); }
  85%  { transform: translateX(20%) rotate(-35deg); }
  100% { transform: translateX(110%);               }
}

@keyframes duck-peek-left {
  0%   { transform: translateX(-110%) scaleX(-1);                }
  15%  { transform: translateX(-20%) scaleX(-1) rotate(35deg);   }
  85%  { transform: translateX(-20%) scaleX(-1) rotate(35deg);   }
  100% { transform: translateX(-110%) scaleX(-1);                }
}

@keyframes clog-float {
  0%   { transform: translateX(0)                    translateY(0)    rotate(0deg);  }
  20%  { transform: translateX(20vw)                 translateY(-7px) rotate(3deg);  }
  50%  { transform: translateX(50vw)                 translateY(0)    rotate(0deg);  }
  75%  { transform: translateX(75vw)                 translateY(-7px) rotate(-3deg); }
  100% { transform: translateX(calc(100vw + 110px))  translateY(0)    rotate(0deg);  }
}
