/**
 * Block Puzzle Stylesheet - Popyca Games
 *
 * Warm cream, slate, and terracotta visual aesthetic.
 * Mobile-first responsive 8x8 grid with touch-action isolation.
 */

:root {
  --bp-board-bg: #ece6dc;
  --bp-cell-bg: #dfd8cc;
  --bp-cell-border: rgba(0, 0, 0, 0.05);

  --bp-color-1: #e26938; /* Warm Terracotta */
  --bp-color-2: #f59e0b; /* Golden Amber */
  --bp-color-3: #c2593f; /* Deep Rust */
  --bp-color-4: #8c7a65; /* Warm Slate */
  --bp-color-5: #3b82f6; /* Classic Azure */
  --bp-color-6: #10b981; /* Forest Emerald */

  --bp-preview-valid: rgba(226, 105, 56, 0.45);
  --bp-preview-invalid: rgba(239, 68, 68, 0.35);

  --bp-cell-size: min(10.5vw, 54px);
  --bp-dock-cell-size: min(4vw, 18px);
}

@media (min-width: 600px) {
  :root {
    --bp-cell-size: 54px;
    --bp-dock-cell-size: 20px;
  }
}

/* Container */
.game-view-container {
  max-width: 540px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header & Scores */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.game-title-group h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-charcoal);
  margin: 0 0 2px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.game-subtitle {
  font-size: 13px;
  color: var(--color-slate);
}

.scores-container {
  display: flex;
  gap: 8px;
}

.score-box {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 14px;
  min-width: 76px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.score-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-slate);
}

.score-value {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-charcoal);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* Controls Bar */
.game-controls-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.combo-streak-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-terracotta);
  background: rgba(226, 105, 56, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.combo-streak-badge.hidden {
  opacity: 0;
  pointer-events: none;
}

.controls-actions {
  display: flex;
  gap: 8px;
}

.btn-game-action {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  color: var(--color-charcoal);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-game-action:hover:not(:disabled) {
  background: #f0ebe1;
  border-color: #d1c8b9;
}

.btn-game-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-restart {
  background: var(--color-terracotta);
  border-color: var(--color-terracotta);
  color: #ffffff;
}

.btn-restart:hover {
  background: #cb592b;
  border-color: #cb592b;
}

/* Board Wrapper & 8x8 Grid */
.bp-board-container {
  position: relative;
  background: var(--bp-board-bg);
  padding: 8px;
  border-radius: 12px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.bp-grid {
  display: grid;
  grid-template-columns: repeat(8, var(--bp-cell-size));
  grid-template-rows: repeat(8, var(--bp-cell-size));
  gap: 4px;
}

.bp-cell {
  width: var(--bp-cell-size);
  height: var(--bp-cell-size);
  background: var(--bp-cell-bg);
  border-radius: 6px;
  position: relative;
  box-sizing: border-box;
  transition: background-color 0.12s ease;
}

/* Filled Cells */
.bp-cell.filled {
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4), 0 2px 4px rgba(0, 0, 0, 0.15);
  animation: blockPopIn 0.16s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bp-cell.color-1 { background: var(--bp-color-1); }
.bp-cell.color-2 { background: var(--bp-color-2); }
.bp-cell.color-3 { background: var(--bp-color-3); }
.bp-cell.color-4 { background: var(--bp-color-4); }
.bp-cell.color-5 { background: var(--bp-color-5); }
.bp-cell.color-6 { background: var(--bp-color-6); }

/* Ghost Previews */
.bp-cell.preview-valid {
  background: var(--bp-preview-valid) !important;
  outline: 2px dashed var(--color-terracotta);
  outline-offset: -2px;
}

.bp-cell.preview-invalid {
  background: var(--bp-preview-invalid) !important;
}

/* Line Clear Flash */
.bp-cell.line-clearing {
  animation: lineClearFlash 0.35s ease forwards;
}

@keyframes lineClearFlash {
  0% {
    transform: scale(1);
    filter: brightness(1.8);
    opacity: 1;
  }
  50% {
    transform: scale(1.08);
    filter: brightness(2.2);
    opacity: 0.9;
  }
  100% {
    transform: scale(0.6);
    opacity: 0;
  }
}

@keyframes blockPopIn {
  0% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Floating Combo Indicator */
.floating-combo-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10;
}

.floating-combo-text {
  font-size: 26px;
  font-weight: 900;
  color: var(--color-terracotta);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  animation: floatCombo 0.8s ease-out forwards;
}

@keyframes floatCombo {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.8);
  }
  30% {
    opacity: 1;
    transform: translateY(-8px) scale(1.15);
  }
  80% {
    opacity: 0.9;
    transform: translateY(-20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
}

/* Dock / 3 Candidate Pieces */
.bp-dock-container {
  width: 100%;
  margin-top: 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  min-height: 110px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 6px;
  box-sizing: border-box;
  touch-action: none;
}

.dock-slot {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 90px;
  cursor: grab;
  position: relative;
  transition: transform 0.15s ease;
  border-radius: 8px;
  padding: 4px;
}

.dock-slot:active {
  cursor: grabbing;
}

.dock-slot.selected {
  background: rgba(226, 105, 56, 0.1);
  border: 1.5px solid var(--color-terracotta);
  transform: scale(1.05);
}

.dock-slot.unfit {
  opacity: 0.35;
  filter: grayscale(0.6);
  cursor: not-allowed;
}

.dock-piece-grid {
  display: grid;
  gap: 2px;
  pointer-events: none;
}

.dock-piece-cell {
  width: var(--bp-dock-cell-size);
  height: var(--bp-dock-cell-size);
  border-radius: 3px;
}

.dock-piece-cell.empty {
  visibility: hidden;
}

.dock-piece-cell.color-1 { background: var(--bp-color-1); }
.dock-piece-cell.color-2 { background: var(--bp-color-2); }
.dock-piece-cell.color-3 { background: var(--bp-color-3); }
.dock-piece-cell.color-4 { background: var(--bp-color-4); }
.dock-piece-cell.color-5 { background: var(--bp-color-5); }
.dock-piece-cell.color-6 { background: var(--bp-color-6); }

/* Helper instructions banner below dock */
.bp-play-hint {
  font-size: 13px;
  color: var(--color-slate);
  margin-top: 12px;
  text-align: center;
  font-weight: 500;
}

/* Modal Overlay (Game Over) */
.game-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(250, 247, 242, 0.92);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
  z-index: 20;
  animation: fadeIn 0.25s ease forwards;
}

.game-modal-overlay.hidden {
  display: none;
}

.modal-badge {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-terracotta);
  background: rgba(226, 105, 56, 0.15);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-charcoal);
  margin: 0 0 10px;
}

.modal-body {
  font-size: 15px;
  color: var(--color-slate);
  margin-bottom: 24px;
}

.modal-final-score {
  font-size: 40px;
  font-weight: 900;
  color: var(--color-charcoal);
  margin-top: 6px;
  display: block;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 240px;
}

.modal-btn-primary {
  background: var(--color-terracotta);
  color: #ffffff;
  border: none;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-btn-primary:hover {
  background: #cb592b;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* How to Play Section */
.game-info-card {
  width: 100%;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 24px;
  margin-top: 24px;
}

.game-info-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-charcoal);
  margin-top: 0;
  margin-bottom: 12px;
}

.game-info-card p {
  font-size: 14px;
  line-height: 1.6;
  color: #4a443c;
  margin-bottom: 14px;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.instruction-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.instruction-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(226, 105, 56, 0.15);
  color: var(--color-terracotta);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.instruction-text h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-charcoal);
  margin: 0 0 4px;
}

.instruction-text p {
  font-size: 13px;
  color: var(--color-slate);
  margin: 0;
  line-height: 1.4;
}
