.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: #06210a;
  font-weight: 600;
  width: 100%;
}

.btn:active {
  background: var(--color-accent-dim);
}

.btn--secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-panel-border);
}

.btn--secondary:active {
  background: var(--color-panel);
}

.btn--link {
  background: transparent;
  border: none;
  color: var(--color-text-dim);
  width: auto;
  min-height: auto;
  padding: 8px;
  font-weight: 400;
  text-decoration: underline;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--gap);
}

.field label {
  font-size: 14px;
  color: var(--color-text-dim);
}

.field input,
.field select {
  min-height: var(--tap-min);
  padding: 0 14px;
  background: var(--color-input-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  width: 100%;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
}

.field-error {
  color: var(--color-danger);
  font-size: 13px;
  min-height: 16px;
}

.card {
  background: var(--color-panel);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius);
  padding: 20px;
}

.status-line {
  min-height: 20px;
  font-size: 14px;
  text-align: center;
  color: var(--color-warning);
  margin-top: 8px;
}

.status-line--error {
  color: var(--color-danger);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Dashed border (not the solid one a real .list-row uses) reads as "empty
   placeholder", not "an actual disabled row" — same footprint as a populated
   list either way, so the section doesn't visually collapse when empty. */
.list-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-dim);
  font-size: 14px;
  min-height: var(--tap-min);
  padding: 10px 14px;
  border: 1px dashed var(--color-panel-border);
  border-radius: var(--radius-sm);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--color-panel);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-height: var(--tap-min);
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}

.list-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Question text must stay fully readable — never truncated to one line. */
.list-row-name--wrap {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.list-row-badge {
  color: var(--color-text-dim);
  font-size: 13px;
  flex-shrink: 0;
}

/* .list-row centers its children vertically by default and puts the badge
   beside the name — fine for a one-line name, but once the name wraps to
   several lines (Armenian labels routinely run longer than their Russian
   originals) a vertically centered badge lands in the middle of that
   wrapped text instead of next to it. Force a real line break between them
   instead: the (possibly multi-line) name takes the full row width, and the
   badge drops to its own line below, left-aligned. */
.list-row:has(.list-row-name--wrap) {
  flex-wrap: wrap;
}

.list-row:has(.list-row-name--wrap) .list-row-name--wrap {
  flex-basis: 100%;
}

/* A row that needs a secondary line of detail below the name (rankings: age
   group + date; a match's opponent info) instead of squeezing it in beside
   the name/badge — stack the two full-width rows instead of fighting for
   horizontal space with them. */
.list-row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.list-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.list-row-sub {
  color: var(--color-text-dim);
  font-size: 12px;
}

/* The historical age-group + date pairing (rankings: what applied back when
   that match was played) reads as secondary detail next to the plain current
   age group beside it — stacked on two lines instead of joined with a
   separator, smaller, and a touch dimmer than .list-row-sub's own color. */
.list-row-sub--stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  font-size: 10px;
  line-height: 1.4;
  color: var(--color-text-dim);
  opacity: 0.75;
}

.perf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text-dim);
}

.perf-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.perf-legend-swatch {
  display: inline-block;
  flex-shrink: 0;
}

/* Dot swatch — matches the outcome marks plotted on the chart's points. */
.perf-legend-swatch--dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* Line swatch — matches the colored segments connecting those points. */
.perf-legend-swatch--line {
  width: 16px;
  height: 3px;
  border-radius: 1.5px;
}

.list-row-actions {
  display: flex;
  gap: 8px;
}

.list-row-actions .btn {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--color-panel);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Absolute, not a flex child that'd need fighting the panel's own `gap` — it
   sits over the content instead of taking a slot in the column. The title
   gets right padding below so it never runs under it, long dynamic titles
   included (e.g. "Играть с системой — выберите предмет"). */
.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--color-text-dim);
  font-size: 22px;
  line-height: 1;
}

.modal-close:active {
  background: var(--color-panel-border);
}

.modal-panel h2:first-of-type {
  padding-right: 30px;
}

/* Question text and question-review rows need real room to breathe — the
   default modal width was fine for short picker lists, but cramped anything
   with full sentences. Added alongside .modal-panel, not instead of it. */
.modal-panel--wide {
  max-width: 640px;
}

.modal-panel .list-row {
  cursor: pointer;
}

.modal-panel h3 {
  font-size: 14px;
  color: var(--color-text-dim);
  margin: 14px 0 8px;
}

.modal-panel h3:first-child {
  margin-top: 0;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  width: 100%;
  aspect-ratio: 1;
  background: var(--color-input-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* No grid `gap` — the ship-sprite/fx-marker layers position themselves with
   plain percentages (cell size = 100%/10), which only lines up with the real
   cell boundaries when the cells are perfectly contiguous. Gridlines come from
   an inset box-shadow instead, which doesn't consume any layout space. */
.board--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: var(--color-text-dim);
  font-size: 14px;
}

.board-cell {
  background: transparent;
  border: none;
  padding: 0;
  min-height: 0;
  position: relative;
  z-index: 1;
  box-shadow: inset 0 0 0 1px var(--color-panel-border);
}

.board-ships-layer,
.board-fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board-ships-layer {
  z-index: 2;
}

.board-fx-layer {
  z-index: 3;
}

.ship-sprite {
  position: absolute;
  /* fill, not contain: the source art is a fixed 66x113 single-ship image, and
     the ship's box is sized by cell count (e.g. 1x4 cells for a battleship) —
     contain would letterbox it down to fit its own aspect ratio, leaving most
     of a long ship's cells empty. Stretching non-uniformly to the box exactly
     covers the ship's real footprint, matching how the GameMaker client always
     scaled this same art (see frontend/_new_assets/README.md). */
  object-fit: fill;
  transform-origin: center;
}

.ship-sunk-overlay {
  position: absolute;
  background: rgba(210, 30, 30, 0.5);
  border-radius: 2px;
  transform-origin: center;
}

.pending-answer-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-warning);
  color: #3a2a00;
  border-radius: 50%;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  animation: pending-answer-blink 1s ease-in-out infinite;
}

@keyframes pending-answer-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.fx-marker {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-marker::before {
  content: '';
  display: block;
  width: 60%;
  height: 60%;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.fx-miss::before {
  -webkit-mask-image: url(../assets/effects/fx_miss.png);
  mask-image: url(../assets/effects/fx_miss.png);
  background: #4fa3ff;
}

/* Hit and sunk both read as a plain red X over the cell (the original design's
   "wound"/"destroyed" mark) — two crossed bars scale with the marker's own
   percentage-sized box, so they line up correctly at any board size. */
.fx-hit,
.fx-sunk {
  --x-thickness: 18%;
}

.fx-hit::before,
.fx-hit::after,
.fx-sunk::before,
.fx-sunk::after {
  content: '';
  position: absolute;
  width: 76%;
  height: var(--x-thickness);
  background: #ff2d2d;
  border-radius: 2px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
}

.fx-hit::before,
.fx-sunk::before {
  transform: rotate(45deg);
}

.fx-hit::after,
.fx-sunk::after {
  transform: rotate(-45deg);
}

.board-cell--preview-valid {
  background: rgba(124, 255, 107, 0.45);
}

.board-cell--preview-invalid {
  background: rgba(255, 107, 107, 0.45);
}

.board-cell--flash {
  outline: 2px solid var(--color-warning);
  outline-offset: -2px;
  z-index: 4;
}

.board-cell--flash-enemy {
  outline: 2px solid var(--color-danger);
  outline-offset: -2px;
  z-index: 4;
}

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

.tray-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tray-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.tray-row-icons {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.tray-icon {
  width: 44px;
  height: 44px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-input-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tray-icon img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* Belt-and-suspenders alongside the img's draggable="false" attribute — a
     real mouse-drag on an <img> starts the browser's own native image drag by
     default, which hijacks the gesture before our pointermove-based drag ever
     sees meaningful movement. This is exactly why a scripted/synthetic drag
     test looked fine while a real mouse drag did nothing. */
  -webkit-user-drag: none;
  user-drag: none;
}

.tray-icon[data-orientation="horizontal"] img {
  transform: rotate(90deg);
}

.tray-icon.is-selected {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  opacity: 0.85;
  object-fit: contain;
  transform-origin: center;
}

.tray-icon:disabled {
  opacity: 0.35;
}

.question-difficulty {
  color: var(--color-text-dim);
  font-size: 13px;
  text-transform: uppercase;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-panel-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
