/* ============================================================
   Popdog Neo — Stylesheet
   Dark navy/teal theme, Passion One + DM Sans, oklch accents.
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0d1117;
  color: #fff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(120% 80% at 50% 8%, oklch(0.36 0.09 195) 0%, oklch(0.22 0.05 250) 45%, oklch(0.15 0.03 265) 100%);
  cursor: pointer;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 8px);
  animation: pd-drift 9s linear infinite;
}

@keyframes pd-drift {
  0% { background-position: 0 0; }
  100% { background-position: 0 -240px; }
}

.frenzy-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 220ms ease;
  background: radial-gradient(90% 60% at 50% 55%, rgba(255, 40, 40, 0) 0%, rgba(255, 30, 30, 0.42) 70%, rgba(120, 0, 0, 0.75) 100%);
}

.app.frenzy .frenzy-veil,
.app.angry .frenzy-veil {
  opacity: 1;
}

/* ---------- Mute Button ---------- */
.mute-btn {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.mute-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.08);
}

.mute-btn.muted {
  background: rgba(255, 60, 60, 0.25);
  border-color: rgba(255, 60, 60, 0.4);
}

/* ---------- Build Tag (dev only, confirms which build is loaded) ---------- */
.build-tag {
  position: fixed;
  bottom: 6px;
  left: 8px;
  z-index: 300;
  font-family: monospace;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  user-select: none;
}

/* ---------- Header ---------- */
.app-header {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 720px;
  padding: 14px 16px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
}

.you-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.country-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.flag {
  font-size: 15px;
  line-height: 1;
}

.country-name {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rank-label {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: oklch(0.86 0.19 140);
  padding-left: 4px;
  min-height: 1em;
}

.online-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.online-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: oklch(0.86 0.19 140);
  box-shadow: 0 0 6px oklch(0.86 0.19 140 / 0.8);
  animation: pd-pulse 1.8s ease-in-out infinite;
}

@keyframes pd-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.online-value {
  font-weight: 800;
  font-size: 11px;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.online-label {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.count-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.82;
}

.count {
  font-family: 'Passion One', sans-serif;
  font-weight: 900;
  font-size: clamp(46px, 12vw, 82px);
  letter-spacing: -0.02em;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}

.count-label {
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
}

.cps-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cps-pill {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: oklch(0.86 0.19 140);
  color: #0d1117;
}

.cps-value {
  font-family: 'Passion One', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}

.cps-unit {
  font-weight: 900;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.cps-status {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  padding-right: 4px;
  min-height: 1em;
}

.app.frenzy .cps-status {
  color: oklch(0.72 0.2 25);
}

/* ---------- Dog Stage ---------- */
.stage-wrap {
  position: relative;
  z-index: 2;
  flex: 1 1 0;
  min-height: 150px;
  width: 100%;
  max-width: 720px;
  container-type: inline-size;
}

.stage {
  position: absolute;
  top: 28px;
  right: 0;
  bottom: 0;
  left: 0;
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background: #f7f9f6;
  border-radius: 34px 34px 0 0;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-bottom: none;
  box-shadow: 0 0 70px rgba(150, 255, 200, 0.18);
  transition: background 200ms linear, box-shadow 200ms linear, border-color 200ms linear;
}

.app.frenzy .stage,
.app.angry .stage {
  background: #fdf3f3;
  border-color: oklch(0.62 0.22 25);
  box-shadow: 0 0 90px rgba(255, 60, 60, 0.55);
  animation: pd-shake 260ms linear infinite;
}

@keyframes pd-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 3px); }
}

.dog {
  width: 116%;
  height: 100%;
  object-fit: cover;
  object-position: center 78%;
  display: block;
  pointer-events: none;
  transition: filter 150ms ease;
}

/* Below this the box was still filling all available flex height while
   narrowing in width, stretching it into a tall, narrow shape that's a
   poor match for the dog photo's wide aspect ratio. Cap the box's own
   height via aspect-ratio instead (anchored to the bottom, never taller
   than the fill), so cover can crop the dog in on both sides by a
   modest, bounded amount instead of leaving blank space or squashing
   the shape. The box's width always matches its container (see
   .stage's max-width, no min-width floor) so its rounded corners never
   get clipped off-screen on narrow phones. */
@container (max-width: 437px) {
  .stage {
    top: auto;
    height: auto;
    aspect-ratio: 4 / 3;
    max-height: calc(100% - 28px);
  }
}

.app.frenzy .dog,
.app.angry .dog {
  filter: saturate(2.2) hue-rotate(-18deg) brightness(0.95) contrast(1.15);
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 250;
}

.ring {
  position: fixed;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  border: 4px solid oklch(0.72 0.19 140 / 0.75);
  pointer-events: none;
  animation: pd-ring 620ms ease-out forwards;
}

.app.frenzy .fx-layer .ring {
  border-color: oklch(0.62 0.22 25 / 0.8);
}

@keyframes pd-ring {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}

.pop-label {
  position: fixed;
  font-family: 'Passion One', sans-serif;
  font-weight: 900;
  font-size: 30px;
  color: #111820;
  text-shadow: 0 0 3px #fff, 0 0 8px rgba(255, 255, 255, 0.9), 0 2px 0 rgba(255, 255, 255, 0.8);
  pointer-events: none;
  white-space: nowrap;
  animation: pd-float 900ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.pop-label.big {
  font-size: 46px;
  color: oklch(0.72 0.2 140);
}

@keyframes pd-float {
  0% { transform: translate(-50%, 0) scale(0.6) rotate(var(--r)); opacity: 1; }
  100% { transform: translate(-50%, -180px) scale(1.35) rotate(var(--r)); opacity: 0; }
}

/* ---------- Panels (battle + leaderboard) ---------- */
.panels {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  width: 100%;
  max-width: 720px;
  padding: 0 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.battle-card, .board-card {
  position: relative;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.battle-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 14px;
}

.battle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  gap: 6px;
}

.battle-side {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.battle-cps {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: oklch(0.86 0.19 140);
}

.battle-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  padding: 0 8px;
}

.gap-label {
  color: oklch(0.86 0.19 140);
  animation: pd-pulse 1.6s ease-in-out infinite;
}

@keyframes pd-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.trend-label {
  font-family: 'DM Sans', sans-serif;
  font-weight: 900;
  font-size: 9px;
  letter-spacing: 0.14em;
}

.trend-label.catching { color: oklch(0.86 0.19 140); }
.trend-label.losing { color: oklch(0.7 0.19 25); }

.battle-picker-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 4px 8px;
  margin: -4px -8px -4px 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font: inherit;
  cursor: pointer;
}

.battle-picker-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.battle-picker-btn .chev {
  font-size: 9px;
  color: oklch(0.86 0.19 140);
}

.tug-bar {
  position: relative;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: oklch(0.55 0.19 25);
}

.tug-fill {
  position: absolute;
  inset: 0;
  right: auto;
  width: 50%;
  background: oklch(0.86 0.19 140);
  box-shadow: 0 0 18px oklch(0.86 0.19 140);
  transition: width 260ms ease;
}

.battle-dropdown, .board-dropdown {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  max-height: min(52dvh, 340px);
  overflow-y: auto;
  border-radius: 18px;
  background: rgba(14, 20, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  list-style: none;
}

.battle-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
}

.battle-dropdown[hidden], .board-dropdown[hidden] {
  display: none;
}

.battle-dropdown-title {
  position: sticky;
  top: -10px;
  z-index: 1;
  margin: -10px -10px 0;
  padding: 14px 18px 8px;
  background: rgba(14, 20, 28, 0.97);
  font-weight: 900;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  color: #fff;
}

.picker-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.picker-row.selected {
  background: rgba(150, 255, 190, 0.14);
  border-color: oklch(0.86 0.19 140 / 0.5);
}

.picker-rank {
  width: 26px;
  font-family: 'Passion One', sans-serif;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.5);
}

.picker-flag {
  font-size: 17px;
}

.picker-name {
  flex: 1;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.picker-tag {
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: oklch(0.86 0.19 140);
}

.picker-score {
  font-family: 'Passion One', sans-serif;
  font-size: 19px;
  letter-spacing: 0.01em;
}

/* ---------- Leaderboard toggle card ---------- */
.board-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
}

.board-toggle span:first-child {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

.board-toggle span:last-child {
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: oklch(0.86 0.19 140);
}

.board-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
  background: rgba(14, 20, 28, 0.92);
  padding: 10px;
  gap: 8px;
}

.board-tabs {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 3px;
}

.tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tab.active {
  background: oklch(0.86 0.19 140);
  color: #0d1117;
}

.tab:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.board-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: oklch(0.86 0.19 140 / 0.35) transparent;
}

.board-list::-webkit-scrollbar {
  width: 4px;
}

.board-list::-webkit-scrollbar-thumb {
  background: oklch(0.86 0.19 140 / 0.35);
  border-radius: 2px;
}

.board-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.15s;
}

.board-item.you {
  background: rgba(150, 255, 190, 0.14);
  border: 1px solid oklch(0.86 0.19 140 / 0.5);
}

.board-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.board-rank {
  font-family: 'Passion One', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  min-width: 24px;
  text-align: center;
}

.board-rank.top {
  color: oklch(0.86 0.19 140);
}

.board-flag {
  font-size: 1.1rem;
  line-height: 1;
}

.board-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-score {
  margin-left: auto;
  font-family: 'Passion One', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: oklch(0.86 0.19 140);
}

.board-status {
  text-align: center;
  padding: 12px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
}

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
  .stage {
    top: 36px;
  }
}

/* Narrow mode: the header pill and tug-of-war row show flags only (no
   text at all — that's what overflowed); the dropdown lists keep a short
   code via data-code since a bare flag is ambiguous in a scrollable list. */
@media (max-width: 420px) {
  .country-name,
  .battle-name {
    display: none;
  }

  .picker-name,
  .board-name {
    font-size: 0;
  }

  .picker-name::after,
  .board-name::after {
    content: attr(data-code);
  }

  .picker-name::after { font-size: 13px; }
  .board-name::after { font-size: 0.8rem; }

  .app-header {
    padding: 12px 10px 0;
    gap: 4px;
  }

  .country-pill {
    padding: 5px 8px;
    gap: 4px;
  }

  .rank-label {
    font-size: 0;
  }

  .rank-label::after {
    content: attr(data-rank);
    font-size: 10px;
  }

  .online-pill {
    padding: 4px 7px;
  }

  .online-label {
    display: none;
  }
}
