/* BurtyBurt — Standalone Play Page */

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

html, body {
  height: 100%;
  background: #313338;
  color: #dcddde;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  /* Remove 300 ms tap delay */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Root layout ──────────────────────────────────────────── */
#play-root {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh; /* true visible viewport — avoids mobile address-bar crop */
  width: 100vw;
  overflow: hidden;
}

/* ── Game column ──────────────────────────────────────────── */
#play-game-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 10px;
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: min(calc((100vh - 80px) * 640 / 400), 100%);
  background: #0d1a0e;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0,0,0,0.6);
  border: 1px solid #202225;
  aspect-ratio: 640 / 400;
}

/* ── Live score overlay — floats top-center over the canvas ── */
#game-score-overlay {
  position:        absolute;
  top:             28px;
  left:            50%;
  transform:       translateX(-50%);
  z-index:         10;
  background:      rgba(0, 0, 0, 0.46);
  border:          1px solid rgba(255, 255, 255, 0.13);
  border-radius:   999px;
  padding:         3px 20px;
  font-family:     system-ui, sans-serif;
  font-size:       28px;
  font-weight:     800;
  color:           #ffffff;
  text-shadow:     0 1px 8px rgba(0, 0, 0, 0.7);
  letter-spacing:  0.05em;
  pointer-events:  none;
  user-select:     none;
  min-width:       52px;
  text-align:      center;
  white-space:     nowrap;
}

@keyframes score-overlay-pop {
  0%   { transform: translateX(-50%) scale(1);    }
  35%  { transform: translateX(-50%) scale(1.28); }
  100% { transform: translateX(-50%) scale(1);    }
}
#game-score-overlay.pop {
  animation: score-overlay-pop 0.19s ease-out forwards;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
  cursor: pointer;
  outline: none;
}

#game-canvas:focus-visible {
  box-shadow: 0 0 0 3px #5865f2;
}

/* ── Controls bar ─────────────────────────────────────────── */
#game-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: min(calc((100vh - 80px) * 640 / 400), 100%);
  gap: 8px;
}

#game-control-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

#game-score-display {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: #72767d;
}

#game-score-display span { color: #b9bbbe; }
#game-score-display strong { color: #fff; }

.game-btn {
  background: #2b2d31;
  border: 1px solid #3a3d44;
  border-radius: 6px;
  color: #b9bbbe;
  font-size: 0.72rem;
  padding: 4px 10px;
  min-height: 36px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.game-btn:hover { background: #383a40; color: #fff; }
.game-btn:focus-visible { outline: 2px solid #5865f2; outline-offset: 2px; }
.game-btn--active { background: #404249; border-color: #5865f2; color: #fff; }
.game-btn--active:hover { background: #4e505a; color: #fff; }
.game-btn--invite {
  background: #5865f2;
  border-color: #7289da;
  color: #fff;
  font-weight: 700;
}
.game-btn--invite:hover { background: #4752c4; color: #fff; }
.game-btn--invite:disabled { cursor: wait; opacity: 0.72; }

#game-invite-status {
  width: 100%;
  max-width: min(calc((100vh - 80px) * 640 / 400), 100%);
  min-height: 1.1em;
  color: #b9bbbe;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
}

#game-invite-status[hidden] { display: none; }

/* ── Powerup guide (left panel) ──────────────────────────── */
#powerup-guide {
  width: 160px;
  flex-shrink: 0;
  background: #2b2d31;
  border-right: 1px solid #3a3d44;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 12px;
  gap: 10px;
}

#powerup-guide::-webkit-scrollbar { width: 3px; }
#powerup-guide::-webkit-scrollbar-track { background: transparent; }
#powerup-guide::-webkit-scrollbar-thumb { background: #3a3d44; border-radius: 2px; }

#pu-guide-title {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #72767d;
  margin-bottom: 4px;
}

#pu-guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pu-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.pu-emoji {
  font-size: 1.05rem;
  line-height: 1.2;
  flex-shrink: 0;
  margin-top: 1px;
}

.pu-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.pu-name {
  font-size: 0.68rem;
  font-weight: 600;
  color: #dcddde;
  line-height: 1.2;
}

.pu-desc {
  font-size: 0.6rem;
  color: #72767d;
  line-height: 1.3;
}

/* Hide on narrow screens — guide is a nice-to-have, not critical */
@media (max-width: 900px) {
  #powerup-guide { display: none; }
}

/* Also hide in fullscreen */
:fullscreen #powerup-guide,
:-webkit-full-screen #powerup-guide { display: none; }

/* ── Leaderboard sidebar ──────────────────────────────────── */
#play-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #2b2d31;
  border-left: 1px solid #3a3d44;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#play-sidebar-inner {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* scrollbar */
#play-sidebar-inner::-webkit-scrollbar { width: 4px; }
#play-sidebar-inner::-webkit-scrollbar-track { background: transparent; }
#play-sidebar-inner::-webkit-scrollbar-thumb { background: #3a3d44; border-radius: 2px; }

#lb-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #72767d;
}

/* All-time plays counter under the title */
#lb-plays {
  font-size: 0.66rem;
  color: #72767d;
  letter-spacing: 0.02em;
}

/* Site-wide plays badge — fixed top center, never blocks clicks.
   z-index stays far below the death gif (99999) and ad overlay (100000). */
#bb-plays-badge {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #b9bbbe;
  background: rgba(20, 21, 24, 0.82);
  border: 1px solid #3a3d44;
  border-radius: 999px;
  padding: 4px 12px;
  pointer-events: none;
  white-space: nowrap;
}

/* Currently-playing counter — lives inside the powerup guide sidebar */
#lb-active {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #b9bbbe;
  background: rgba(74,140,76,0.14);
  border: 1px solid rgba(74,140,76,0.30);
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
  text-align: center;
  margin-bottom: 6px;
}

/* Rarity section headers inside the powerup guide list */
.pu-section-label {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a5d64;
  padding: 4px 0 2px;
  list-style: none;
}
.pu-section-label--legendary { color: #b48aaa; }

/* "resets weekly*" tag next to the Leaderboard heading */
#lb-resets-tag {
  font-size: 0.65em;
  font-style: italic;
  font-weight: 400;
  color: #888;
  margin-left: 5px;
  letter-spacing: 0;
}

/* Connect Discord CTA */
#lb-connect {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  background: #232428;
  border: 1px solid #3a3d44;
  border-radius: 10px;
  text-align: center;
}

#lb-connect p {
  font-size: 0.75rem;
  color: #b9bbbe;
  line-height: 1.5;
}

#lb-connect a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  transition: background 0.15s;
}

#lb-connect a:hover { background: #4752c4; }
#lb-connect a[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.72;
}

#lb-connect-status {
  margin: 0;
  color: #f0b232;
}

/* Leaderboard list */
#lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: #232428;
  border: 1px solid transparent;
  transition: background 0.12s;
}

.lb-row--me {
  border-color: #5865f2;
  background: #2c2f4a;
}

.lb-rank {
  font-size: 0.68rem;
  font-weight: 700;
  color: #72767d;
  min-width: 18px;
  text-align: center;
}

.lb-rank--gold   { color: #ffc93c; }
.lb-rank--silver { color: #b9bbbe; }
.lb-rank--bronze { color: #cd7f32; }

.lb-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #3a3d44;
}

.lb-avatar-placeholder {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #3a3d44;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #72767d;
  flex-shrink: 0;
}

.lb-name {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.75rem;
  color: #dcddde;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-score {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

#lb-empty {
  font-size: 0.75rem;
  color: #72767d;
  text-align: center;
  padding: 12px 0;
}

#lb-loading {
  font-size: 0.75rem;
  color: #72767d;
  text-align: center;
  padding: 12px 0;
}

#lb-error {
  font-size: 0.75rem;
  color: #ed4245;
  text-align: center;
  padding: 12px 0;
}

/* ── Fullscreen mode: sidebar hidden, game fills screen ───── */
:fullscreen #play-sidebar,
:-webkit-full-screen #play-sidebar {
  display: none;
}

:fullscreen #play-game-col,
:-webkit-full-screen #play-game-col {
  background: #000;
}

/* ── Responsive: narrow viewport — stack vertically ──────── */
@media (max-width: 680px) {
  html, body { overflow: auto; touch-action: pan-y; }

  #play-root {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  #play-game-col {
    padding: 10px 10px 6px;
  }

  #game-wrapper {
    max-width: 100%;
  }

  #game-controls {
    max-width: 100%;
    flex-wrap: wrap;
    gap: 6px;
  }

  #game-control-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  #game-invite-status {
    max-width: 100%;
    font-size: 0.7rem;
  }

  #game-score-display {
    font-size: 0.74rem;
  }

  /* Larger touch targets on mobile */
  .game-btn {
    font-size: 0.72rem;
    padding: 8px 10px;
    min-height: 44px;
  }

  .game-vol-slider {
    width: 60px;
    height: 6px;
  }

  .game-vol-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  .game-vol-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  #play-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid #3a3d44;
    /* Allow sidebar to be a natural height on mobile, not full screen */
    height: auto;
    max-height: none;
  }

  #play-sidebar-inner {
    padding: 14px 14px 12px;
    overflow-y: visible;
  }

  /* Larger leaderboard rows for touch */
  .lb-row {
    padding: 10px 10px;
    min-height: 44px;
  }

  #lb-footer {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  #game-canvas { animation: none !important; }
}

/* ── Leaderboard footer / back button ─────────────────────── */
@keyframes lb-back-glow {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(88,101,242,0.45), 0 0 0 0 rgba(88,101,242,0.3); }
  50%       { box-shadow: 0 0 14px 3px rgba(88,101,242,0.7), 0 0 0 5px rgba(88,101,242,0); }
}
@keyframes lb-back-slide {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(-3px); }
}
@keyframes lb-ztv-glow {
  0%, 100% { box-shadow: 0 0 6px 1px rgba(146,83,253,0.45), 0 0 0 0 rgba(146,83,253,0.3); }
  50%       { box-shadow: 0 0 14px 3px rgba(146,83,253,0.7), 0 0 0 5px rgba(146,83,253,0); }
}
@keyframes lb-ztv-slide {
  0%, 100% { transform: translateX(0); }
  50%       { transform: translateX(3px); }
}

#lb-footer {
  display: flex;
  gap: 8px;
  padding: 12px 14px 16px;
  border-top: 1px solid #3a3d44;
  flex-shrink: 0;
}

#lb-link-status {
  margin: -8px 14px 12px;
  min-height: 1.1em;
  color: #f0b232;
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: center;
}

#lb-link-status[hidden] { display: none; }

#lb-back-btn,
#lb-ztv-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 9px 10px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: transform 0.15s, filter 0.15s;
}

#lb-back-btn {
  background: linear-gradient(135deg, #3442d9 0%, #5865f2 100%);
  border: 1px solid #7289da;
  animation: lb-back-glow 2.2s ease-in-out infinite;
}

#lb-ztv-btn {
  background: linear-gradient(135deg, #6234d5 0%, #9253fd 100%);
  border: 1px solid #a97bff;
  animation: lb-ztv-glow 2.2s ease-in-out infinite;
  padding: 4px 10px;
}

#lb-back-btn .lb-back-arrow {
  display: inline-block;
  animation: lb-back-slide 1.6s ease-in-out infinite;
  font-style: normal;
}

#lb-ztv-btn .lb-ztv-arrow {
  display: inline-block;
  animation: lb-ztv-slide 1.6s ease-in-out infinite;
  font-style: normal;
}

.lb-ztv-logo-img {
  display: inline-block;
  height: 34px;
  width: auto;
  vertical-align: middle;
  filter:
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.95))
    drop-shadow(0 0 1px rgba(0, 0, 0, 0.95))
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

#lb-back-btn:hover,
#lb-ztv-btn:hover {
  filter: brightness(1.15);
  transform: scale(1.03);
}

#lb-back-btn:focus-visible,
#lb-ztv-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── Volume slider (play page) ─────────────────────────────── */
.game-vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: #3a3d44;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}

.game-vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #5865f2;
  cursor: pointer;
  transition: background 0.15s;
}

.game-vol-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: #5865f2;
  cursor: pointer;
  transition: background 0.15s;
}

.game-vol-slider:hover::-webkit-slider-thumb { background: #fff; }
.game-vol-slider:hover::-moz-range-thumb     { background: #fff; }

.game-vol-slider:focus-visible {
  outline: 2px solid #5865f2;
  outline-offset: 2px;
}

.game-btn--icon {
  padding: 4px 8px;
  min-width: 30px;
  text-align: center;
}

/* ── Ad-break overlay ──────────────────────────────────────── */
#brk-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}
#brk-overlay.brk-active { display: flex; }

#brk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

#brk-container {
  position: relative;
  width: 75vw;
  aspect-ratio: 16 / 9;
  max-height: 80vh;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 64px rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

/* Loading spinner */
#brk-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  z-index: 3;
}
#brk-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.12);
  border-top-color: #fff;
  animation: brk-spin 0.85s linear infinite;
}
@keyframes brk-spin {
  to { transform: rotate(360deg); }
}

/* Video element */
#brk-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  background: #000;
}

/* Top-left info text — bold, outlined, on a frosted pill so it stays
   readable over any footage without blocking or distracting from the ad
   (pointer-events stays off; colors stay muted monochrome). */
#brk-info-text {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 4;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  letter-spacing: 0.02em;
  /* 8-direction shadow = crisp dark outline around the letters (works
     everywhere; unlike text-stroke it never eats into small glyphs) */
  text-shadow:
    -1px -1px 0 rgba(0,0,0,0.9),
     0   -1px 0 rgba(0,0,0,0.9),
     1px -1px 0 rgba(0,0,0,0.9),
    -1px  0   0 rgba(0,0,0,0.9),
     1px  0   0 rgba(0,0,0,0.9),
    -1px  1px 0 rgba(0,0,0,0.9),
     0    1px 0 rgba(0,0,0,0.9),
     1px  1px 0 rgba(0,0,0,0.9),
     0    2px 6px rgba(0,0,0,0.8);
  /* frosted, outlined pill behind the text */
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 280px;
  line-height: 1.45;
}

/* Controls bar (only pause) */
#brk-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
}
#brk-pause-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#brk-pause-btn:hover { background: rgba(255,255,255,0.28); }

/* Fullscreen button — hidden by default; JS reveals it on touch devices */
#brk-fs-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#brk-fs-btn:hover { background: rgba(255,255,255,0.28); }
#brk-fs-btn.brk-fs-active { background: rgba(255,255,255,0.35); }

/* Display-only progress bar (not interactive) */
#brk-progress-wrap {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.18);
  overflow: hidden;
  pointer-events: none;
  cursor: default;
}
#brk-progress-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.25s linear;
}

/* Continue button (shown only after video ends) */
#brk-continue-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
}
#brk-continue-btn {
  background: #5865f2;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 14px 36px;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 24px rgba(88,101,242,0.5);
  transition: background 0.15s, transform 0.1s;
}
#brk-continue-btn:hover { background: #4752c4; transform: scale(1.03); }
#brk-continue-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

@media (max-width: 680px) {
  #brk-container { width: 95vw; }
  #brk-info-text { font-size: 0.64rem; max-width: 210px; padding: 5px 8px; }
}

/* When the ad overlay itself is fullscreen (mobile ⛶), fill the screen.
   Kept as separate rules: an unknown pseudo-class in a selector list would
   invalidate the entire rule in browsers that don't support it. */
#brk-overlay:fullscreen { background: #000; }
#brk-overlay:fullscreen #brk-container {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
}
#brk-overlay:-webkit-full-screen { background: #000; }
#brk-overlay:-webkit-full-screen #brk-container {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
}
