/* PugBreaker — Self-contained responsive styles */

:root {
  --bg: #0f1320;
  --panel: #181d2e;
  --panel-light: #22283d;
  --accent: #7c9cff;
  --text: #e8e9f0;
  --text-muted: #8f96aa;
  --frame: #2a3148;
  --success: #4ade80;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

.app {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-image {
  display: block;
  width: clamp(220px, 34vw, 500px);
  max-width: calc(100vw - 32px);
  height: auto;
}

.mode-label {
  margin: 1px 0 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score-display {
  background: var(--panel);
  border-radius: 10px;
  padding: 4px 14px;
  text-align: center;
  min-width: 108px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.score-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.score-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}

.main {
  display: flex;
  gap: 20px;
  flex: 1;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.board-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 520px;
  min-width: 0;
}

.board-frame {
  background: var(--frame);
  padding: 14px;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45),
              inset 0 1px 0 rgba(255,255,255,0.06),
              inset 0 -1px 0 rgba(0,0,0,0.3);
  position: relative;
  max-width: 100%;
  width: fit-content;
  margin: 0 auto;
  box-sizing: border-box;
}

#board {
  display: block;
  /* Size is controlled by JS (style.width/height) + .board-frame for responsiveness */
  height: auto;
  border-radius: 8px;
  background: #12151f;
  touch-action: none;
  cursor: pointer;
  image-rendering: crisp-edges;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

.board-frame {
  -webkit-tap-highlight-color: transparent;
}

.status-line {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  min-height: 38px;
  line-height: 1.35;
  width: 100%;
  max-width: 480px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board.pug-targeting {
  cursor: crosshair;
}

.pug-actions {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pug-action-btn {
  border: 1px solid rgba(246, 195, 107, 0.58);
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff4d6;
  background: linear-gradient(180deg, #9b642d, #70431f);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transform-origin: center;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.pug-action-btn:hover:not(:disabled) {
  filter: brightness(1.13);
  transform: translateY(-1px);
}

.pug-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  filter: saturate(0.55);
}

.pug-breaker-btn.targeting {
  background: linear-gradient(180deg, #d28b36, #9b5d21);
  box-shadow: 0 0 0 3px rgba(246, 195, 107, 0.22), 0 5px 16px rgba(0, 0, 0, 0.36);
}

.pug-breaker-btn.earned {
  animation: breakerEarned 0.58s ease;
}

.pug-breaker-btn.reward-target {
  position: relative;
  z-index: 76;
  transform: scale(var(--reward-scale, 1));
}

.reward-pug-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 75;
}

.pug-shuffle-btn {
  border-color: rgba(124, 156, 255, 0.65);
  color: #eef2ff;
  background: linear-gradient(180deg, #5268b7, #34457f);
}

.pug-action-icon {
  font-size: 19px;
  line-height: 1;
}

.pug-action-count {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4a2b10;
  background: #f6c36b;
  font-size: 13px;
  font-weight: 800;
}

.pug-shuffle-btn .pug-action-count {
  color: #23305d;
  background: #aebeff;
}

@keyframes breakerEarned {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.1) rotate(-1deg); }
}

.sidebar {
  flex: 0 0 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 220px;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-heading h3 {
  margin: 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
  font-size: 14.5px;
}

.stat-value {
  font-weight: 700;
  color: var(--accent);
}

.instructions ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.instructions li {
  margin: 4px 0;
}

@media (min-width: 1100px) {
  .main {
    display: grid;
    grid-template-columns: minmax(480px, 520px) 260px minmax(300px, 360px);
    justify-content: center;
  }

  .board-container {
    grid-column: 1;
  }

  .sidebar {
    grid-column: 2;
    width: 260px;
    align-self: start;
  }

  .panel.instructions {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: start;
    max-width: 360px;
  }

  .instructions ul {
    font-size: 14px;
  }

  .instructions li {
    margin: 7px 0;
  }
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.leaderboard-list .rank {
  color: #f6c36b;
  font-weight: 800;
}

.leaderboard-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.leaderboard-list .score {
  color: var(--success);
  font-weight: 800;
}

.leaderboard-list .muted {
  display: block;
  color: var(--text-muted);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.1s ease;
  user-select: none;
  background: var(--panel-light);
  color: var(--text);
}

.btn:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn:active {
  transform: scale(0.985);
}

.btn.primary {
  background: linear-gradient(180deg, #5b7cff, #3f5fe8);
  color: white;
  box-shadow: 0 2px 6px rgba(63, 95, 232, 0.4);
}

.btn.danger {
  background: linear-gradient(180deg, #f25c5c, #d63a3a);
  color: white;
}

.btn.small {
  padding: 5px 10px;
  font-size: 12px;
}

.btn.large {
  padding: 12px 28px;
  font-size: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 18, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.summary-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 26px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.mode-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 26px;
  width: min(92vw, 520px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.mode-card h2 {
  margin: 0 0 18px;
  text-align: center;
  font-size: 26px;
}

.mode-options {
  display: grid;
  gap: 12px;
}

.mode-option {
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  color: var(--text);
  background: #111624;
  cursor: pointer;
  font: inherit;
}

.mode-option:hover,
.mode-option:focus-visible {
  border-color: rgba(124, 156, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.14);
  outline: none;
}

.mode-option span {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 800;
}

.mode-option small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
}

.summary-card h2 {
  margin: 0 0 16px;
  font-size: 24px;
}

.summary-stats {
  margin-bottom: 18px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 15px;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row .big {
  font-size: 19px;
  font-weight: 700;
}

.summary-row.bonus {
  color: #f6c36b;
}

.summary-row.total {
  font-weight: 700;
  font-size: 17px;
  color: var(--success);
}

#sum-final {
  font-size: 22px;
}

.new-high {
  margin: 8px 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #f6c36b;
}

.new-high.hidden {
  display: none;
}

.leaderboard-submit {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  text-align: left;
}

.leaderboard-submit.hidden {
  display: none;
}

.leaderboard-submit label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.submit-row {
  display: flex;
  gap: 8px;
}

.submit-row input {
  min-width: 0;
  flex: 1 1 auto;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: #111624;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

.submit-row .btn {
  flex: 0 0 auto;
  padding-inline: 12px;
}

.submit-status {
  min-height: 18px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.reset-card {
  width: min(92vw, 390px);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid rgba(248, 113, 113, 0.48);
  background: linear-gradient(180deg, #231924, #181d2e 42%);
  box-shadow: 0 22px 58px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255,255,255,0.04) inset;
  text-align: center;
}

.danger-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, #f87171, #c82727);
  box-shadow: 0 8px 22px rgba(248, 113, 113, 0.26);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.reset-card h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: 23px;
}

.reset-card p {
  margin: 0;
  color: #d8dae4;
}

.reset-detail {
  margin-top: 10px !important;
  color: #ffb4b4 !important;
  font-size: 13px;
  font-weight: 700;
}

.reset-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.reset-actions .btn {
  min-width: 112px;
}

.footer {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.footer-links {
  display: flex;
  gap: 12px;
}

.footer a,
.legal-page a {
  color: #a9bbff;
  text-underline-offset: 2px;
}

.footer a:hover,
.legal-page a:hover {
  color: var(--text);
}

.legal-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.legal-header {
  margin-bottom: 20px;
}

.legal-header a {
  display: inline-block;
  margin-bottom: 14px;
  font-weight: 600;
  text-decoration: none;
}

.legal-page h1 {
  margin: 0 0 4px;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.15;
}

.legal-page h2 {
  margin: 28px 0 8px;
  font-size: 19px;
  color: #c8d2ff;
}

.legal-page p,
.legal-page li {
  color: #c7cad5;
}

.legal-page ul {
  padding-left: 22px;
}

.legal-page .effective-date {
  margin: 0;
  color: var(--text-muted);
}

.legal-card {
  padding: 24px clamp(18px, 4vw, 34px) 30px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

/* Responsive */
@media (max-width: 720px) {
  .main {
    flex-direction: column;
    align-items: center;
  }
  
  .board-container {
    width: 100%;
    max-width: 100%;
  }
  
  .sidebar {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    gap: 12px;
  }
  
  .panel {
    flex: 1;
  }
  
  .panel.stats {
    min-width: 0;
  }
  
  .panel.instructions {
    display: none; /* Hide verbose instructions on very small screens */
  }
  
  .header {
    gap: 8px;
  }
  
  .brand-image {
    width: clamp(220px, 58vw, 360px);
  }
  
  .score-display {
    order: 2;
    width: 100%;
    max-width: 140px;
  }
  
  .board-frame {
    padding: 8px;
  }
}

/* Nice subtle board highlight when active */
.board-frame {
  transition: box-shadow 0.2s ease;
}

.board-frame:hover {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255,255,255,0.06);
}

/* Floating score pop style (positioned by JS) */
.floating-score {
  position: absolute;
  pointer-events: none;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  z-index: 50;
  animation: floatUp 0.9s ease forwards;
  font-size: 15px;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-42px); }
}

/* Selection preview bubble - shows score for current highlighted group */
.selection-bubble {
  position: absolute;
  pointer-events: none;
  background: #22283d;
  color: #a5d6a7;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  border: 1px solid rgba(165, 214, 167, 0.3);
  transform: translate(-50%, -135%);
  z-index: 65;
  white-space: nowrap;
  animation: bubblePop 0.12s cubic-bezier(0.23, 1.0, 0.32, 1);
}

@keyframes bubblePop {
  from {
    opacity: 0;
    transform: translate(-50%, -115%) scale(0.65);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -135%) scale(1);
  }
}
