/* 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: 1080px;
  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;
}

.title .logo {
  font-size: 28px;
  line-height: 1;
}

.title h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.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;
}

.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: 18px;
}

#board.pug-targeting {
  cursor: crosshair;
}

.pug-breaker-btn {
  margin-top: 10px;
  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;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.pug-breaker-btn:hover:not(:disabled) {
  filter: brightness(1.13);
  transform: translateY(-1px);
}

.pug-breaker-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-icon {
  font-size: 19px;
  line-height: 1;
}

.pug-breaker-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;
}

@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);
}

.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;
}

.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);
}

.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;
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.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;
  }
  
  .title h1 {
    font-size: 24px;
  }
  
  .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);
  }
}
