/* =============================================
   CSS Variables - кольорова палітра Bikini Bottom
   ============================================= */
:root {
  --yellow: #FFE135;
  --yellow-dark: #F5C800;
  --turquoise: #40E0D0;
  --turquoise-dark: #2BC4B8;
  --sky-blue: #87CEEB;
  --ocean: #4ECDC4;
  --ocean-dark: #3BA99E;
  --coral: #FF6B6B;
  --coral-dark: #E85555;
  --white: #FFFFFF;
  --sand: #F4E4BC;
  --sand-dark: #E8D4A8;

  --bg-gradient-start: #7EC8E3;
  --bg-gradient-end: #4A9EBD;

  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(255, 255, 255, 0.6);
  --shadow-soft: 0 8px 32px rgba(0, 80, 120, 0.15);
  --shadow-cell: 0 2px 6px rgba(0, 60, 100, 0.12);
  --shadow-btn: 0 4px 12px rgba(0, 80, 120, 0.2);

  --radius-large: 24px;
  --radius-medium: 14px;
  --radius-small: 8px;

  --cell-size: 42px;
  --cell-gap: 4px;
  --tray-block-size: 28px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  --highlight-valid: rgba(76, 217, 100, 0.55);
  --highlight-invalid: rgba(255, 80, 80, 0.45);

  --selection-bg: var(--turquoise-dark);
  --selection-color: var(--white);

  --font-display: 'Spongeboy', cursive;

  --scrollbar-size: 10px;
  --scrollbar-track: rgba(255, 255, 255, 0.22);
  --scrollbar-thumb: var(--ocean-dark);
  --scrollbar-thumb-hover: var(--turquoise);
}

/* =============================================
   Шрифт Spongeboy
   ============================================= */
@font-face {
  font-family: 'Spongeboy';
  src: url('../fonts/Spongeboy.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

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

html,
body {
  overscroll-behavior: none;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 100px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--turquoise) 0%, var(--ocean-dark) 100%);
  border-radius: 100px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background-clip: padding-box;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--yellow) 0%, var(--yellow-dark) 100%);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: var(--font-display);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: #2C5F7C;
  background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
}

/* =============================================
   Мета проекту та футер
   ============================================= */
.project-meta {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 28px 16px 12px;
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 3px rgba(0, 60, 100, 0.35);
}

.project-meta__label {
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--yellow);
  text-shadow: 2px 2px 0 rgba(0, 80, 120, 0.2), 0 0 16px rgba(255, 225, 53, 0.35);
}

.project-meta__academy {
  opacity: 0.92;
}

.book-footer__credit {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 16px 32px;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 3px rgba(0, 60, 100, 0.3);
}

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-color);
  text-shadow: none;
}

::-moz-selection {
  background-color: var(--selection-bg);
  color: var(--selection-color);
  text-shadow: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

/* =============================================
   Фон морського дна
   ============================================= */
.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.light-rays {
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 60%;
  background: radial-gradient(ellipse at center top, rgba(255, 255, 200, 0.25) 0%, transparent 70%);
}

.bubbles {
  position: absolute;
  inset: 0;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.1));
  border: 1px solid rgba(255, 255, 255, 0.3);
  animation: float-up linear infinite;
}

.bubble:nth-child(1) { width: 12px; height: 12px; left: 8%;  bottom: -20px; animation-duration: 8s;  animation-delay: 0s; }
.bubble:nth-child(2) { width: 8px;  height: 8px;  left: 22%; bottom: -20px; animation-duration: 10s; animation-delay: 2s; }
.bubble:nth-child(3) { width: 16px; height: 16px; left: 45%; bottom: -20px; animation-duration: 12s; animation-delay: 1s; }
.bubble:nth-child(4) { width: 10px; height: 10px; left: 65%; bottom: -20px; animation-duration: 9s;  animation-delay: 3s; }
.bubble:nth-child(5) { width: 14px; height: 14px; left: 80%; bottom: -20px; animation-duration: 11s; animation-delay: 0.5s; }
.bubble:nth-child(6) { width: 6px;  height: 6px;  left: 92%; bottom: -20px; animation-duration: 7s;  animation-delay: 4s; }
.bubble:nth-child(7) { width: 18px; height: 18px; left: 35%; bottom: -20px; animation-duration: 13s; animation-delay: 2.5s; }
.bubble:nth-child(8) { width: 9px;  height: 9px;  left: 55%; bottom: -20px; animation-duration: 8.5s; animation-delay: 1.5s; }

@keyframes float-up {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 0.7; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-110vh) translateX(20px); opacity: 0; }
}

.seaweed {
  position: absolute;
  bottom: 0;
  width: 60px;
  height: 180px;
  opacity: 0.35;
}

.seaweed-left {
  left: 2%;
  background: linear-gradient(to top, #2D8B57, #3CB371 60%, transparent);
  border-radius: 50% 50% 0 0;
  transform: skewX(-5deg);
  animation: sway 4s ease-in-out infinite;
}

.seaweed-right {
  right: 3%;
  width: 50px;
  height: 150px;
  background: linear-gradient(to top, #228B4E, #4CAF50 60%, transparent);
  border-radius: 50% 50% 0 0;
  transform: skewX(8deg);
  animation: sway 5s ease-in-out infinite reverse;
}

@keyframes sway {
  0%, 100% { transform: skewX(-5deg) rotate(0deg); }
  50%      { transform: skewX(-5deg) rotate(3deg); }
}

.coral {
  position: absolute;
  bottom: 0;
  width: 70px;
  height: 50px;
  opacity: 0.4;
}

.coral-left {
  left: 10%;
  background: radial-gradient(ellipse at bottom, var(--coral) 30%, transparent 70%);
  border-radius: 50% 50% 0 0;
}

.coral-right {
  right: 12%;
  width: 55px;
  background: radial-gradient(ellipse at bottom, #FF8C69 30%, transparent 70%);
  border-radius: 50% 50% 0 0;
}

.sand-floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to top, var(--sand) 0%, transparent 100%);
  opacity: 0.5;
}

/* Декоративні персонажі на фоні */
.deco-char {
  position: absolute;
  bottom: 0;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 4px 12px rgba(0, 60, 100, 0.2));
}

.deco-house {
  left: 0;
  width: min(320px, 44vw);
  bottom: 4px;
  opacity: 0.9;
  z-index: 1;
}

.deco-patrick-house {
  right: 0;
  width: min(320px, 44vw);
  bottom: 4px;
  opacity: 0.9;
  z-index: 1;
}

.deco-sponge {
  left: 19%;
  width: min(180px, 28vw);
  bottom: 14px;
  opacity: 0.85;
  z-index: 2;
  animation: char-bob 3s ease-in-out infinite;
}

.deco-patrick {
  right: 295px;
  width: min(200px, 30vw);
  bottom: 8px;
  opacity: 0.85;
  z-index: 2;
  animation: char-bob 3.5s ease-in-out infinite reverse;
}

@keyframes char-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* =============================================
   Головний контейнер
   ============================================= */
.game-wrapper {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px 16px;
}

.game-container {
  width: 100%;
  max-width: 680px;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-soft), 0 0 60px rgba(64, 224, 208, 0.1);
  padding: 24px;
  backdrop-filter: blur(12px);
}

/* =============================================
   Логотип та рахунок
   ============================================= */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.logo {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: normal;
  color: var(--yellow);
  text-shadow: 2px 3px 0 rgba(0, 80, 120, 0.15), 0 0 20px rgba(255, 225, 53, 0.3);
  letter-spacing: 1px;
  line-height: 1.1;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: visible;
}

.score-panel {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.score-box {
  background: linear-gradient(135deg, var(--sky-blue), var(--ocean));
  border-radius: var(--radius-medium);
  padding: 8px 16px;
  text-align: center;
  box-shadow: var(--shadow-cell);
  min-width: 90px;
  flex: 0 0 auto;
}

.score-box--timer {
  width: 96px;
  min-width: 96px;
  flex: 0 0 96px;
}

.score-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  transition: transform var(--transition-fast);
  font-variant-numeric: tabular-nums;
}

.score-value.timer-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  display: block;
  width: 100%;
  white-space: nowrap;
}

.score-value.score-pop {
  animation: score-pop 0.35s var(--transition-bounce);
}

@keyframes score-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); color: var(--yellow); }
  100% { transform: scale(1); }
}

/* =============================================
   Кнопки керування
   ============================================= */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-medium);
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--yellow), var(--yellow-dark));
  color: #5A4A00;
  box-shadow: var(--shadow-btn);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(245, 200, 0, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--turquoise), var(--turquoise-dark));
  color: var(--white);
  box-shadow: var(--shadow-btn);
}

.btn-secondary:hover {
  box-shadow: 0 6px 16px rgba(64, 224, 208, 0.4);
  transform: translateY(-1px);
}

.btn-icon {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(78, 205, 196, 0.3);
  border-radius: 50%;
  box-shadow: var(--shadow-cell);
}

.btn-icon:hover {
  background: var(--white);
  transform: translateY(-1px);
}

.btn-icon.muted {
  opacity: 0.5;
}

.btn-large {
  padding: 14px 32px;
  font-size: 1.1rem;
  width: 100%;
}

/* Icons for sound & music buttons */
.btn-icon-img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.btn-icon-img[hidden] {
  display: none !important;
}

.btn-icon.muted .btn-icon-img:not([hidden]) {
  opacity: 0.45;
}

/* =============================================
   Ігрова область
   ============================================= */
.game-area {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.board-wrapper {
  position: relative;
  flex-shrink: 0;
}

/* Основне ігрове поле 8×8 */
.game-board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--cell-gap);
  padding: 12px;
  background: linear-gradient(145deg, rgba(135, 206, 235, 0.3), rgba(78, 205, 196, 0.2));
  border-radius: var(--radius-medium);
  border: 2px solid rgba(78, 205, 196, 0.3);
  box-shadow: inset 0 2px 8px rgba(0, 60, 100, 0.08);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: var(--radius-small);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: var(--shadow-cell);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.6);
}

.cell.filled {
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.cell.highlight-valid {
  background: var(--highlight-valid) !important;
  box-shadow: 0 0 8px rgba(76, 217, 100, 0.5);
}

.cell.highlight-invalid {
  background: var(--highlight-invalid) !important;
  box-shadow: 0 0 8px rgba(255, 80, 80, 0.4);
}

/* Анімація встановлення блоку */
.cell.place-bounce {
  animation: place-bounce 0.35s var(--transition-bounce);
}

@keyframes place-bounce {
  0%   { transform: scale(0.5); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Анімація очищення лінії */
.cell.clearing {
  animation: clear-cell 0.4s ease forwards;
}

@keyframes clear-cell {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.3); opacity: 0.8; box-shadow: 0 0 16px var(--yellow); }
  100% { transform: scale(0); opacity: 0; }
}

/* Бульбашки при очищенні */
.clear-bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), rgba(135, 206, 235, 0.3));
  pointer-events: none;
  animation: clear-bubble-rise 0.6s ease forwards;
  z-index: 10;
}

@keyframes clear-bubble-rise {
  0%   { transform: translateY(0) scale(0.5); opacity: 1; }
  100% { transform: translateY(-30px) scale(1.2); opacity: 0; }
}

/* =============================================
   Комбо
   ============================================= */
.combo-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--coral), 0 0 20px rgba(255, 225, 53, 0.6);
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}

.combo-display.show {
  animation: combo-appear 1s ease forwards;
}

@keyframes combo-appear {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.8); }
}

/* =============================================
   Панель фігур
   ============================================= */
.pieces-tray {
  flex: 1;
  min-width: 140px;
}

.tray-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.tray-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: normal;
  color: var(--ocean-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0;
  text-align: center;
  user-select: none;
}

.btn-shuffle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 169, 158, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.btn-shuffle:hover {
  background: rgba(59, 169, 158, 0.2);
  transform: scale(1.08);
}

.btn-shuffle:active {
  transform: scale(0.95);
}

.icon-shuffle {
  display: block;
  width: 20px;
  height: 20px;
  background-color: #3BA99E;
  mask: url('../images/icons/shuffle.svg') center / contain no-repeat;
  -webkit-mask: url('../images/icons/shuffle.svg') center / contain no-repeat;
}

.pieces-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.pieces-list.shuffle-animation {
  animation: shuffle-shake 0.4s ease;
}

@keyframes shuffle-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px) rotate(-2deg); }
  75%       { transform: translateX(5px) rotate(2deg); }
}

.piece-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  min-width: 100px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-medium);
  border: 2px dashed rgba(78, 205, 196, 0.3);
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.piece-slot:not(.empty) {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.piece-slot:not(.empty):active {
  cursor: grabbing;
}

.piece-slot.empty {
  opacity: 0.3;
  pointer-events: none;
}

.piece-slot.dragging-source {
  opacity: 0.5;
}

.piece-slot .piece-grid {
  display: inline-grid;
  gap: 3px;
  width: max-content;
  height: max-content;
  place-items: center;
  pointer-events: none;
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.piece-slot .piece-grid > div:not(.piece-block) {
  width: var(--tray-block-size);
  height: var(--tray-block-size);
}

.piece-block {
  border-radius: 6px;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.piece-slot .piece-block {
  width: var(--tray-block-size);
  height: var(--tray-block-size);
}

/* Кольори блоків фігур */
.piece-color-0 { background: linear-gradient(135deg, #FFE135, #F5C800); }
.piece-color-1 { background: linear-gradient(135deg, #FF6B6B, #E85555); }
.piece-color-2 { background: linear-gradient(135deg, #40E0D0, #2BC4B8); }
.piece-color-3 { background: linear-gradient(135deg, #87CEEB, #5BAFDB); }
.piece-color-4 { background: linear-gradient(135deg, #FF8C69, #FF6B45); }
.piece-color-5 { background: linear-gradient(135deg, #B19CD9, #9575CD); }
.piece-color-6 { background: linear-gradient(135deg, #98D8C8, #6BC4A6); }

/* =============================================
   Привид перетягування
   ============================================= */
.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.25));
  transition: none;
}

.drag-ghost .piece-grid {
  display: grid;
  gap: var(--cell-gap);
}

.drag-ghost .piece-block {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: var(--radius-small);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* =============================================
   Модальні вікна
   ============================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 50, 80, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.overlay[hidden] {
  display: none;
}

.overlay.is-opening {
  animation: overlay-bubble-fade 0.4s ease forwards;
}

.overlay.is-open {
  opacity: 1;
}

.modal {
  position: relative;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-large);
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  max-width: 360px;
  width: 100%;
}

.overlay.is-opening .modal:not(.is-settled) {
  will-change: transform, opacity, box-shadow;
  animation: bubble-pop-in 0.6s cubic-bezier(0.22, 1.18, 0.36, 1) forwards;
}

.modal.is-settled {
  opacity: 1;
  transform: none;
  box-shadow: var(--shadow-soft), 0 0 48px rgba(64, 224, 208, 0.1);
}

@keyframes overlay-bubble-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes bubble-pop-in {
  from {
    opacity: 0;
    transform: scale(0.28);
    box-shadow: 0 0 0 0 rgba(64, 224, 208, 0.45), var(--shadow-soft);
  }
  to {
    opacity: 1;
    transform: scale(1);
    box-shadow: var(--shadow-soft), 0 0 48px rgba(64, 224, 208, 0.1);
  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: normal;
  color: var(--coral);
  margin-bottom: 20px;
}

.modal-scores {
  margin-bottom: 24px;
}

.modal-score {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: #2C5F7C;
}

.modal-score strong {
  color: var(--ocean-dark);
  font-size: 1.3rem;
}

/* Music prompt modal */
.overlay-prompt {
  z-index: 200;
}

.music-prompt-modal {
  max-width: 380px;
}

.music-prompt-image {
  width: 140px;
  height: auto;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 60, 100, 0.2));
}

.music-prompt-text {
  font-size: 1.1rem;
  color: #2C5F7C;
  margin-bottom: 24px;
  line-height: 1.4;
}

.music-prompt-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.music-prompt-buttons .btn-large {
  width: 100%;
}

.time-up-modal {
  max-width: 380px;
}

.game-over-modal {
  max-width: 380px;
}

.game-over-image {
  width: 140px;
  height: auto;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 60, 100, 0.2));
}

.time-up-image {
  width: 140px;
  height: auto;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 60, 100, 0.2));
}

.time-up-text {
  font-size: 1.1rem;
  color: #2C5F7C;
  margin-bottom: 12px;
  line-height: 1.4;
}

.time-up-modal .modal-score {
  margin-bottom: 24px;
}

/* =============================================
   Сплеск бульбашок при встановленні
   ============================================= */
.place-splash {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.7), transparent);
  pointer-events: none;
  animation: splash 0.5s ease forwards;
  z-index: 5;
}

@keyframes splash {
  0%   { transform: scale(0); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* =============================================
   Адаптивність
   ============================================= */
@media (max-width: 640px) {
  :root {
    --cell-size: 36px;
    --cell-gap: 3px;
    --tray-block-size: 22px;
  }

  .game-container {
    padding: 16px;
  }

  .logo {
    font-size: 1.5rem;
  }

  .game-header {
    flex-direction: column;
    align-items: center;
  }

  .score-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
    min-width: 0;
  }

  .score-box {
    min-width: 0;
    width: 100%;
    padding: 8px 10px;
    box-sizing: border-box;
  }

  .score-box--timer {
    width: 100%;
    min-width: 0;
  }

  .score-value {
    white-space: nowrap;
    display: block;
    width: 100%;
    text-align: center;
  }

  .deco-char {
    display: none;
  }

  .controls {
    justify-content: center;
  }

  .game-area {
    flex-direction: column;
    align-items: center;
  }

  .pieces-tray {
    width: 100%;
  }

  .pieces-list {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
  }

  .piece-slot {
    min-height: 70px;
    min-width: 80px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  :root {
    --cell-size: 32px;
    --cell-gap: 2px;
    --tray-block-size: 18px;
  }

  .game-board {
    padding: 8px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

@media (min-width: 900px) {
  :root {
    --cell-size: 48px;
  }
}
