/* Breakout. Loads after base.css, which supplies the tokens, reset, background
   and card chrome. The field is a canvas, so everything below is chrome. */

:root {
  --gap: 8px;
  --board-radius: 12px;
  /* The field drives the layout: its height is picked first and the 3:4 aspect
     ratio derives the width, so a short viewport shrinks the board rather than
     pushing the footer off screen. */
  --field-height: clamp(320px, 56vh, 540px);
}

.card {
  max-width: 460px;
}

.card__body {
  padding: 26px 26px 22px;
}

.card__foot {
  padding: 13px 26px;
}

/* Header: title + scores */
.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.title {
  position: relative;
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.7rem, 6.4vw, 2.35rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  background: linear-gradient(
    100deg,
    var(--accent-cyan) 0%,
    #818cf8 45%,
    var(--accent-violet) 100%
  );
  background-size: 200% auto;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation:
    rise 700ms var(--ease-smooth) 120ms both,
    shimmer 8s linear infinite;
}

.scores {
  display: flex;
  gap: 8px;
  animation: fade-in 700ms var(--ease-smooth) 240ms both;
}

.score {
  position: relative;
  min-width: 74px;
  padding: 6px 10px 7px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-chip);
  text-align: center;
}

.score__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  line-height: 1.4;
}

.score__value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Floating "+500" that rises out of the score box when a level falls */
.score__gain {
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent-lime);
  opacity: 0;
  pointer-events: none;
}

.score__gain--run {
  animation: gain 700ms var(--ease-smooth);
}

/* Hint line */
.hint {
  margin: 18px 0 14px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  animation: fade-in 600ms var(--ease-smooth) 320ms both;
}

.hint__sigil {
  color: var(--accent-lime);
  margin-right: 8px;
}

.hint__touch { display: none; }

/* Coarse pointers get the drag wording instead of the keyboard one. */
@media (hover: none) and (pointer: coarse) {
  .hint__desktop { display: none; }
  .hint__touch { display: inline; }
}

/* Playfield */
.play {
  display: flex;
  justify-content: center;
  animation: rise 700ms var(--ease-smooth) 400ms both;
}

/* Padding is equal on all sides, so the canvas inside the border box keeps the
   3:4 ratio of the field it draws. */
.board {
  position: relative;
  flex: none;
  height: var(--field-height);
  aspect-ratio: 3 / 4;
  padding: var(--gap);
  border: 1px solid var(--border-color);
  border-radius: var(--board-radius);
  background: rgba(255, 255, 255, 0.025);
  /* Dragging the paddle must not scroll the page. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: none;
}

.board__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Red wash when the last ball goes out, held just long enough to be read before
   the overlay lands on top of it. */
.board--dead {
  animation: crash 320ms ease-out;
}

/* Meters under the field */
.meters {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  animation: fade-in 700ms var(--ease-smooth) 480ms both;
}

.meter {
  flex: 1;
  padding: 5px 9px 6px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-chip);
  text-align: center;
}

.meter__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  line-height: 1.4;
}

.meter__value {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Lives are drawn as pips, so they need a little air between them. */
#lives {
  color: var(--accent-lime);
  letter-spacing: 0.18em;
}

#lives:empty::before {
  content: '—';
  color: var(--text-dim);
  letter-spacing: 0;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: var(--board-radius);
  background: rgba(5, 5, 7, 0.82);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  text-align: center;
  cursor: default;
  animation: fade-in 320ms var(--ease-smooth) both;
}

.overlay[hidden] { display: none; }

.overlay__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--accent-cyan), var(--accent-violet));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.overlay__text {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Buttons */
.controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-chip);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    color var(--duration-short) var(--ease-smooth),
    border-color var(--duration-short) var(--ease-smooth),
    background var(--duration-short) var(--ease-smooth);
}

.btn:hover:not(:disabled),
.btn:focus-visible {
  color: var(--accent-cyan);
  border-color: var(--border-hover);
  outline: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  color: var(--text-primary);
  border-color: rgba(34, 211, 238, 0.25);
  background: rgba(34, 211, 238, 0.1);
}

.btn[aria-pressed="true"] {
  color: var(--accent-lime);
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.1);
}

/* Square glyph-only button, so it does not eat the row on a narrow phone. */
.btn--icon {
  flex: none;
  min-width: 46px;
  padding: 9px 0;
  font-size: 0.95rem;
}

.btn--icon[aria-pressed="false"] {
  color: var(--text-dim);
  text-decoration: line-through;
}

/* The field is narrow, so overlay buttons stack rather than sit side by side. */
.overlay .btn {
  flex: none;
  width: 100%;
  max-width: 150px;
}

/* Animation Keyframes */
@keyframes gain {
  0% { opacity: 0; transform: translateY(0); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-26px); }
}

@keyframes crash {
  0% {
    background: rgba(244, 63, 94, 0.3);
    border-color: rgba(244, 63, 94, 0.7);
  }
  100% {
    background: rgba(255, 255, 255, 0.025);
    border-color: var(--border-color);
  }
}

/* Responsive Design */
@media (max-width: 560px) {
  :root {
    --gap: 6px;
    --field-height: clamp(300px, 52vh, 480px);
  }

  .stage { padding: 14px; }

  .card__body { padding: 20px 16px 18px; }

  .card__foot { padding: 12px 16px; }

  .hint { font-size: 0.68rem; }
}
