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

html, body {
  height: 100%;
  font-family: 'Nunito', sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Start page ─────────────────────────────────────────────────────────── */

body.start-page {
  background: linear-gradient(135deg, #ff9eb5 0%, #c3b1e1 50%, #ffe0b2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.start-screen {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
}

.start-emojis {
  font-size: 2.8rem;
  letter-spacing: 0.4rem;
  margin-bottom: 1rem;
}

.start-screen h1 {
  font-size: 3.5rem;
  font-weight: 900;
  color: white;
  text-shadow: 0 3px 12px rgba(0,0,0,0.2);
  margin-bottom: 0.5rem;
}

.start-subtitle {
  font-size: 1.15rem;
  color: rgba(255,255,255,0.9);
  margin-bottom: 2.5rem;
  font-weight: 700;
}

.start-btn {
  display: inline-block;
  background: white;
  color: #d63384;
  font-family: 'Nunito', sans-serif;
  font-size: 1.4rem;
  font-weight: 900;
  padding: 1rem 2.5rem;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}

.start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
}

.start-deco {
  font-size: 2rem;
  letter-spacing: 0.4rem;
  margin-top: 2rem;
}

/* ── Game page ──────────────────────────────────────────────────────────── */

body.game-page {
  background: #1a1a2e;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: fixed;
}

/* Loading screen */
#loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ff9eb5, #c3b1e1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  gap: 1.2rem;
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Top bar */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: rgba(20, 20, 40, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: white;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

/* Map */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── Navigation panel (bottom sheet) ───────────────────────────────────── */

.bottom-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(20, 20, 40, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.25rem 1.5rem 1.5rem;
  z-index: 100;
  border-radius: 22px 22px 0 0;
  color: white;
  text-align: center;
}

.distance-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
}

.distance-label {
  font-size: 1rem;
  color: rgba(255,255,255,0.65);
  font-weight: 700;
}

.distance-value {
  font-size: 2.8rem;
  font-weight: 900;
  color: #ff9eb5;
  line-height: 1;
  min-width: 120px;
}

.nav-hint {
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  margin-top: 0.4rem;
  font-weight: 700;
}

/* ── Code entry panel (bottom sheet, map stays visible) ─────────────────── */

.full-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.code-bottom-panel {
  padding: 0.9rem 1.25rem 1.1rem;
}

.code-reached-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.reached-icon {
  font-size: 1.4rem;
}

.reached-label {
  font-size: 0.95rem;
  font-weight: 900;
  color: #ff9eb5;
}

.code-input-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

#code-input {
  flex: 1;
  font-size: 2rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  font-family: 'Nunito', sans-serif;
  color: white;
  background: rgba(255,255,255,0.15);
  text-transform: uppercase;
  transition: border-color 0.2s, background 0.2s;
}

#code-input::placeholder {
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.2em;
}

#code-input:focus {
  outline: none;
  border-color: #ff9eb5;
  background: rgba(255,255,255,0.22);
}

#code-input.shake {
  animation: shake 0.4s ease;
  border-color: #ff6b6b;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-10px); }
  40%       { transform: translateX(10px); }
  60%       { transform: translateX(-8px); }
  80%       { transform: translateX(8px); }
}

.code-error-msg {
  color: #ffb3c6;
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 0.4rem;
  min-height: 1.2em;
  visibility: hidden;
}

.verify-btn-compact {
  padding: 0.45rem 1.1rem;
  font-size: 1.5rem;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #ff9eb5, #c3b1e1);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  user-select: none;
  white-space: nowrap;
  min-width: 54px;
}

.verify-btn-compact:active  { transform: scale(0.93); }
.verify-btn-compact:disabled { opacity: 0.5; }

/* ── Celebration panel ──────────────────────────────────────────────────── */

.celebration-bg {
  background: linear-gradient(135deg, #ff9eb5, #c3b1e1, #ffe0b2, #ff9eb5);
  background-size: 300% 300%;
  animation: gradShift 4s ease infinite;
}

@keyframes gradShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.celebration-content {
  text-align: center;
  padding: 2rem 1.5rem;
  color: white;
  max-width: 420px;
}

.celebration-emoji {
  font-size: 3.5rem;
  letter-spacing: 0.3rem;
  display: block;
  margin-bottom: 1rem;
  animation: bounce 1.1s ease-in-out infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0) rotate(-3deg); }
  to   { transform: translateY(-18px) rotate(3deg); }
}

.celebration-content h1 {
  font-size: 1.9rem;
  font-weight: 900;
  text-shadow: 0 2px 12px rgba(0,0,0,0.2);
  margin-bottom: 1.25rem;
  line-height: 1.25;
}

.final-label {
  font-size: 1.1rem;
  font-weight: 700;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.final-code {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  padding-left: 0.35em; /* compensate last char */
  background: white;
  color: #d63384;
  border-radius: 22px;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  display: inline-block;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  margin: 0.75rem 0 1.25rem;
}

.celebration-deco {
  font-size: 2rem;
  letter-spacing: 0.4rem;
}

/* ── Success flash ──────────────────────────────────────────────────────── */

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 200, 120, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

.success-inner {
  text-align: center;
  color: white;
}

.success-emoji {
  font-size: 6rem;
  display: block;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.success-inner p {
  font-size: 2.2rem;
  font-weight: 900;
  margin-top: 0.5rem;
}

/* ── Leaflet tweaks ─────────────────────────────────────────────────────── */

.leaflet-control-zoom {
  margin-bottom: 110px !important;
}

.target-icon {
  font-size: 30px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
