* {
  box-sizing: border-box;
}
:root {
  --color-bg: #e3f2fd;
  --color-frame: #0d47a1;
  --color-popup-bg: #ffffff;
  --color-popup-border: #bbdefb;
  --color-title: #0d47a1;
  --color-text: #333333;
  --color-button-orange: #ff9800;
  --color-button-blue: #0d47a1;
  --color-button-text: #ffffff;
  --color-scorebox: #1a237e;
  --color-success: #4caf50;
  --color-bio-bin: #6a994e;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", system-ui, -apple-system,
    Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background-color: var(--color-bg);
  color: var(--color-text);
}

#app {
  position: relative;
  overflow: hidden;
  height: 100svh;
  height: 100dvh;
}

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  min-height: 60px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: #fff;
  z-index: 10;
  backdrop-filter: blur(10px);
  background-color: rgba(13, 71, 161, 0.05);
}
#topbar .topbar-left { display: flex; align-items: center; gap: 8px; }
#topbar .topbar-center { display: flex; justify-content: center; color: #555; }
#topbar .topbar-right { display: flex; justify-content: flex-end; }
#topbar .club-icon { width: 40px; height: 40px; display: block; }
#topbar .app-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: transparent;
}
#topbar .scores {
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 800;
  padding: 6px 12px;
}
#topbar .scores #uiScore {
  font-size: 20px;
  line-height: 1;
}
#topbar .scores #uiBest {
  font-size: 12px;
  line-height: 1;
  opacity: 0.9;
}
#topbar button {
  background: var(--color-button-blue);
  color: white;
  border: 0;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  font-weight: 700;
  font-size: 14px;
}

#topbar .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}
#topbar .icon-btn img {
  width: 40px;
  height: 40px;
  display: block;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* We'll manage gestures to avoid scroll */
}

/* Desktop centered layout with sensible max size */
@media (min-width: 960px) {
  #app {
    display: grid;
    place-items: center;
  }
  #game {
    width: min(480px, 90vw);
    height: 100%;
  }
  #topbar {
    width: min(480px, 90vw);
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }
}

#hud {
  display: none; /* superseded by topbar */
}

#score {
  background: rgba(15, 23, 42, 0.7);
  color: white;
  font-weight: 800;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 18px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 6, 23, 0.55);
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(92vw, 540px);
  background: var(--color-popup-bg);
  color: var(--color-text);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  border: 3px solid var(--color-popup-border);
}
.go-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mistake-highlight { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #b91c1c; }
.mistake-highlight img { width: 28px; height: 28px; display: block; }
.mistake-highlight .label { font-size: 16px; }
.start-hero {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 10px auto 6px auto;
}

.popup-body {
  margin-top: 8px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.panel h1,
.panel h2 {
  margin: 0 0 8px 0;
}

.panel p {
  margin: 0 0 14px 0;
}

.panel button {
  margin-top: 6px;
  width: 100%;
  background: var(--color-button-blue);
  color: var(--color-button-text);
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 700;
}

/* Primary orange button style to match START */
.button-orange {
  background: var(--color-button-orange) !important;
  color: var(--color-button-text) !important;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* Icon-left button variant for Share */
.icon-left {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.icon-left .icon {
  width: 22px;
  height: 22px;
  display: block;
}
.button-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #43a047;
  color: #ffffff;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-decoration: none;
}
.actions { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 10px 0 8px 0;
  font-weight: 600;
}
.fact {
  margin: 8px 0 10px 0;
  font-size: 14px;
  color: #334155;
}
.share-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  animation: pop 1.2s ease-in-out infinite;
}
.panel .share-cta {
  margin-top: 12px;
  margin-bottom: 12px;
  background-color: #fcfcfc;
  color: #0ea5e9;
  border: 1px solid #0ea5e9;
}
@keyframes pop {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

.banner {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 12px) + 76px);
  transform: translateX(-50%);
  background: rgba(13, 71, 161, 0.95);
  color: white;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.25);
  pointer-events: none;
  animation: pulseFloat 1.8s ease-in-out infinite;
}
.banner.hidden {
  display: none;
}
@keyframes pulseFloat {
  0%,
  100% {
    transform: translate(-50%, 0);
    filter: drop-shadow(0 6px 10px rgba(13, 71, 161, 0.25));
  }
  50% {
    transform: translate(-50%, -4px);
    filter: drop-shadow(0 10px 16px rgba(13, 71, 161, 0.35));
  }
}

.legend {
  list-style: none;
  margin: 0 0 10px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
}
.dot.bio {
  background: #16a34a;
}
.dot.plastic {
  background: #fb923c;
}
.dot.cardboard {
  background: #d97706;
}
.dot.mixed {
  background: #64748b;
}

@media (min-width: 720px) {
  #score {
    font-size: 20px;
  }
}
