/* The matchday board, HUD, preview banner, combo state, goal sequence and controls. */

.page--match {
  padding-top: calc(var(--space-2) + var(--safe-top));
  gap: var(--space-3);
}

/* ---- HUD ---------------------------------------------------------------- */

.hud {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-line);
  background: linear-gradient(180deg, rgba(60, 36, 112, 0.7), rgba(32, 16, 56, 0.92));
  box-shadow: var(--shadow-sm);
}

.hud__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.hud__identity {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.hud__title {
  display: block;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud__subtitle {
  display: block;
  font-size: var(--size-eyebrow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud__row--stats {
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--surface-line);
}

.hud__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
}

.hud__value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hud__label {
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-objective {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--surface-line);
}

.hud-objective__icon {
  display: inline-flex;
  color: var(--brass-300);
}

.hud-objective__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-objective__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--size-small);
}

.hud-objective__label {
  color: var(--text-soft);
}

.hud-objective__count {
  color: var(--brass-300);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---- Board -------------------------------------------------------------- */

.match-stage {
  position: relative;
  display: flex;
  justify-content: center;
}

.board {
  position: relative;
  width: calc(min(100%, 420px) * var(--board-scale));
  max-width: 100%;
  aspect-ratio: 7 / 8.55;
  padding: 26px 10px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-line-strong);
  background:
    linear-gradient(180deg, rgba(14, 58, 39, 0.55), rgba(10, 40, 28, 0.9)),
    var(--meadow-700);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(251, 243, 228, 0.06);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.board__zones {
  position: absolute;
  inset: 26px 10px 10px;
  display: grid;
  grid-template-rows: 2fr 3fr 3fr;
  pointer-events: none;
  z-index: 0;
}

.board__zone {
  position: relative;
  border-bottom: 1px dashed rgba(251, 243, 228, 0.18);
}

.board__zone:last-child {
  border-bottom: none;
}

.board__zone[data-zone='final'] {
  background: rgba(201, 162, 39, 0.09);
}

.board__zone[data-zone='middle'] {
  background: rgba(251, 243, 228, 0.03);
}

.board__goal {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 52%;
  height: 10px;
  z-index: 2;
  pointer-events: none;
}

.board__goal-net {
  position: absolute;
  inset: 0;
  border-radius: 0 0 8px 8px;
  background-image: repeating-linear-gradient(90deg, rgba(251, 243, 228, 0.55) 0 1px, transparent 1px 6px);
  border-bottom: 2px solid rgba(251, 243, 228, 0.6);
}

.board__goal-label {
  position: absolute;
  top: 11px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  letter-spacing: 0.24em;
  color: rgba(251, 243, 228, 0.42);
}

.board__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  height: 100%;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(21, 12, 36, 0.28);
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow-inset);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), opacity var(--fast) var(--ease);
}

.cell[data-accent='sand'] { background: var(--tile-sand); color: var(--tile-sand-ink); }
.cell[data-accent='meadow'] { background: var(--tile-meadow); color: var(--tile-meadow-ink); }
.cell[data-accent='orchid'] { background: var(--tile-orchid); color: var(--tile-orchid-ink); }
.cell[data-accent='brass'] { background: var(--tile-brass); color: var(--tile-brass-ink); }
.cell[data-accent='ember'] { background: var(--tile-ember); color: var(--tile-ember-ink); }

.cell[data-blocker='true'] {
  background:
    repeating-linear-gradient(135deg, rgba(21, 12, 36, 0.5) 0 4px, transparent 4px 8px),
    var(--tile-slate);
  color: var(--tile-slate-ink);
  border-color: rgba(251, 243, 228, 0.18);
}

/* Stitched kit texture on the action tiles. */
.cell:not([data-blocker='true'])::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 7px;
  background-image: repeating-linear-gradient(90deg, rgba(21, 12, 36, 0.07) 0 1px, transparent 1px 5px);
  pointer-events: none;
}

.cell::after {
  content: attr(data-phase);
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.5625rem;
  font-weight: 800;
  opacity: 0.55;
}

:root[data-phase-numbers='false'] .cell::after {
  content: '';
}

.cell[data-legal='true'] {
  box-shadow: 0 0 0 2px rgba(251, 243, 228, 0.55), var(--shadow-inset);
}

.cell[data-hint='true'] {
  animation: hint-pulse 1.1s var(--ease) infinite;
}

.cell[data-selected='true'] {
  transform: scale(0.94);
  box-shadow: 0 0 0 3px var(--brass-300), 0 6px 14px rgba(8, 4, 18, 0.5);
  z-index: 3;
}

.cell[data-selected='true']::after {
  content: attr(data-order);
  top: auto;
  bottom: 2px;
  right: 4px;
  font-size: 0.625rem;
  opacity: 1;
  color: inherit;
}

.cell.is-new {
  animation: tile-in var(--normal) var(--ease) both;
}

.cell.is-clearing {
  animation: tile-clear 220ms var(--ease) both;
}

.cell.is-beaten {
  animation: tile-beaten 260ms var(--ease) both;
}

.cell:disabled {
  cursor: default;
}

@keyframes tile-in {
  from { opacity: 0; transform: translateY(14px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

@keyframes tile-clear {
  to { opacity: 0; transform: scale(0.6); }
}

@keyframes tile-beaten {
  0% { transform: scale(1); }
  40% { transform: scale(1.1) rotate(4deg); }
  100% { opacity: 0; transform: scale(0.5) rotate(-8deg); }
}

@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(232, 206, 122, 0.4); }
  50% { box-shadow: 0 0 0 5px rgba(232, 206, 122, 0.12); }
}

.board__overlay {
  position: absolute;
  inset: 26px 10px 10px;
  width: auto;
  height: auto;
  z-index: 4;
  pointer-events: none;
}

.board__line {
  stroke: var(--brass-300);
  stroke-width: 1.6;
  opacity: 0.85;
  filter: drop-shadow(0 0 4px rgba(232, 206, 122, 0.45));
  vector-effect: non-scaling-stroke;
}

.board[data-preview-goal='true'] .board__line {
  stroke: var(--cream-100);
  stroke-width: 2.2;
}

.board[data-preview-off='true'] .board__line {
  stroke: var(--ember-300);
}

.board__ball {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform var(--normal) var(--ease);
}

.board__ball-core {
  width: 58%;
  height: 58%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, var(--cream-300) 60%, #b8a684);
  box-shadow: 0 0 0 2px rgba(21, 12, 36, 0.5), 0 0 16px rgba(251, 243, 228, 0.55);
  animation: ball-breathe 2.4s var(--ease) infinite;
}

@keyframes ball-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.board__burst {
  position: absolute;
  top: 0;
  left: 0;
  width: 10px;
  height: 10px;
  margin-left: calc(var(--burst-x) - 5px);
  margin-top: calc(var(--burst-y) - 5px);
  border-radius: 50%;
  border: 3px solid var(--brass-300);
  z-index: 6;
  pointer-events: none;
  animation: burst 850ms var(--ease) both;
}

@keyframes burst {
  from { opacity: 0.9; transform: scale(0.5); }
  to { opacity: 0; transform: scale(18); }
}

/* ---- Preview banner ----------------------------------------------------- */

.preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-line);
  background: var(--surface-muted);
  font-size: var(--size-small);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}

.preview__badge {
  flex: none;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--size-eyebrow);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(21, 12, 36, 0.45);
  color: var(--text-muted);
}

.preview__text {
  color: var(--text-soft);
}

.preview[data-tone='ready'] {
  border-color: rgba(232, 206, 122, 0.5);
}

.preview[data-tone='ready'] .preview__badge {
  background: rgba(201, 162, 39, 0.24);
  color: var(--brass-300);
}

.preview[data-tone='goal'] {
  border-color: rgba(62, 158, 114, 0.6);
  background: rgba(27, 107, 71, 0.2);
}

.preview[data-tone='goal'] .preview__badge {
  background: rgba(62, 158, 114, 0.3);
  color: var(--meadow-300);
}

.preview[data-tone='warn'] {
  border-color: rgba(226, 112, 90, 0.55);
}

.preview[data-tone='warn'] .preview__badge {
  background: rgba(226, 112, 90, 0.22);
  color: var(--ember-300);
}

/* ---- Combo state -------------------------------------------------------- */

.page--match[data-combo='true'] .board {
  border-color: var(--brass-300);
  box-shadow: var(--shadow-md), 0 0 24px rgba(232, 206, 122, 0.25);
}

.combo-banner {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--brass-300);
  background: rgba(32, 16, 56, 0.88);
  animation: combo-in var(--normal) var(--ease) both;
}

.combo-banner[hidden] {
  display: none;
}

.combo-banner__label {
  font-size: 0.5625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.combo-banner__value {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  color: var(--brass-300);
}

@keyframes combo-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ---- Goal sequence ------------------------------------------------------ */

.goal-sequence {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at 50% 45%, rgba(27, 107, 71, 0.92), rgba(21, 12, 36, 0.94));
  animation: goal-in var(--normal) var(--ease) both;
}

.goal-sequence[hidden] {
  display: none;
}

.goal-sequence__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-5);
}

.goal-sequence__word {
  font-family: var(--font-display);
  font-size: var(--size-hero);
  letter-spacing: 0.18em;
  color: var(--brass-300);
  text-shadow: 0 4px 18px rgba(232, 206, 122, 0.45);
  animation: goal-word 700ms var(--ease) both;
}

.goal-sequence__detail {
  font-size: var(--size-small);
  color: var(--cream-300);
}

@keyframes goal-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes goal-word {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---- Controls ----------------------------------------------------------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.controls__row {
  display: flex;
  gap: var(--space-2);
}

.controls__row--main {
  align-items: stretch;
}

.controls__row--main .btn--ghost {
  flex: 0 0 34%;
}

.controls__row--main .btn--primary {
  flex: 1;
}

:root[data-handedness='left'] .controls__row--main {
  flex-direction: row-reverse;
}

.control {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-line);
  background: var(--surface-muted);
  color: var(--text-soft);
  font-size: var(--size-eyebrow);
  letter-spacing: 0.04em;
  transition: background var(--fast) var(--ease);
}

.control:hover:not(:disabled) {
  background: rgba(91, 58, 166, 0.3);
}

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

/* ---- Pause dialog ------------------------------------------------------- */

.pause {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.pause__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  text-align: center;
}

.pause__stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.pause__stat span {
  font-size: var(--size-eyebrow);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pause__rule {
  font-size: var(--size-small);
  color: var(--text-soft);
}

.pause__ladder {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
