/* ── App: widescreen row layout ── */
.app {
  padding: 0;
  display: flex;
  flex-direction: row;
  gap: 0;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  align-items: stretch;
  /* height set by JS after header is measured */
}

/* ── Sidebars ── */
.sidebar {
  width: 110px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 8px;
  background: var(--surface);
}

.sidebar-left  { border-right: 1px solid var(--border); }
.sidebar-right { border-left:  1px solid var(--border); }

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  min-width: 3ch;
  text-align: center;
}

.lives {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 22px;
  line-height: 1;
  align-items: center;
}

.heart {
  transition: opacity 0.2s, transform 0.2s;
  display: inline-block;
}

.heart.dead {
  opacity: 0.2;
  transform: scale(0.7);
  filter: grayscale(1);
}

#combo-val {
  font-size: 0.82rem;
  font-weight: 800;
  color: #f39c12;
  letter-spacing: 1px;
  white-space: nowrap;
  text-align: center;
}

/* ── Board ── */
.board-wrapper {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

#board {
  position: relative;
  width: 100%;
  overflow: hidden;
  line-height: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Result overlay ── */
#result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.87);
  z-index: 30;
  animation: fadein 0.3s ease;
}

#result-overlay[hidden] { display: none !important; }

@keyframes fadein {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1); }
}

#result-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 24px rgba(255,200,0,0.7);
  letter-spacing: 2px;
}

#result-score {
  font-size: 3rem;
  font-weight: 900;
  color: #f1c40f;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(241,196,15,0.5);
}

#result-best {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

/* ── Narrow screen: stack top/bottom ── */
@media (max-width: 540px) {
  .app {
    flex-direction: column;
    height: auto !important;
  }

  .sidebar {
    flex-direction: row;
    width: 100%;
    height: auto;
    padding: 6px 16px;
    justify-content: space-around;
    gap: 16px;
  }

  .sidebar-left  { border-right: none; border-bottom: 1px solid var(--border); order: 1; }
  .sidebar-right { border-left:  none; border-top:    1px solid var(--border); order: 3; }
  /* Switch board-wrapper to block so #board grows naturally to canvas height */
  .board-wrapper { order: 2; display: block; }
  #board { height: auto; }

  .sidebar-item {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }

  .hud-value { font-size: 1.2rem; }

  .lives {
    flex-direction: row;
    gap: 4px;
    font-size: 18px;
  }

  #game-canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 400 / 500;
  }
}
