.game-root { min-height: 28rem; }

.pipe-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-start;
  justify-content: center;
}

.pipe-queue {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 4.5rem;
}

.pipe-queue-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pipe-queue-stack {
  display: flex;
  flex-direction: column-reverse;
  gap: 0.35rem;
  align-items: center;
}

.pipe-preview {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 8px;
  background: #3a342c;
  border: 2px solid #5c5348;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  opacity: 0.72;
}

.pipe-preview.next {
  width: 3.75rem;
  height: 3.75rem;
  opacity: 1;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(184, 146, 58, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.pipe-preview svg {
  width: 86%;
  height: 86%;
  display: block;
}

.pipe-board-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.pipe-board {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 253, 247, 0.06), transparent 50%),
    linear-gradient(145deg, #2a322e 0%, #1c2420 55%, #16201c 100%);
  border: 1px solid #3d4a44;
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.pipe-cell {
  position: relative;
  width: 3rem;
  height: 3rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #4a4036;
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 1px);
  background-size: 8px 8px;
  cursor: pointer;
  overflow: hidden;
}

.pipe-cell:disabled {
  cursor: default;
}

.pipe-cell:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  z-index: 1;
}

.pipe-cell.empty:hover:not(:disabled) {
  background-color: #5a4e42;
}

.pipe-cell.has-pipe {
  background: #3a342c;
  background-image: none;
}

.pipe-cell.source,
.pipe-cell.sink {
  background: #2e3a34;
  background-image: none;
  cursor: default;
}

.pipe-cell.filling {
  box-shadow: inset 0 0 0 2px #3d9bcc;
}

.pipe-cell.filled {
  box-shadow: inset 0 0 0 2px #2a7a9e;
}

.pipe-cell.burst {
  box-shadow: inset 0 0 0 2px var(--danger);
  animation: pipe-shake 0.35s ease;
}

.pipe-cell svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.pipe-cell .pipe-label {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c9bfb0;
  pointer-events: none;
}

.pipe-status {
  font-weight: 600;
  color: var(--text);
}

.pipe-status.win { color: var(--success); }
.pipe-status.lose { color: var(--danger); }
.pipe-status.flow { color: #2a7a9e; }

@keyframes pipe-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@media (max-width: 640px) {
  .pipe-layout {
    flex-direction: column;
    align-items: center;
  }

  .pipe-queue {
    width: 100%;
    align-items: center;
  }

  .pipe-queue-stack {
    flex-direction: row;
    flex-direction: row-reverse;
  }

  .pipe-cell {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 36px;
    min-height: 36px;
  }
}

[data-theme="dark"] .pipe-board {
  border-color: #2a3832;
}

[data-theme="dark"] .pipe-cell {
  background-color: #3a342c;
}

[data-theme="dark"] .pipe-preview {
  background: #2a2620;
}
