/*
  Puzzle - one stylesheet, phone portrait first. Every page fills exactly the viewport
  (100dvh) and never scrolls as a whole: a board takes the height that is left, and a list
  that can grow (fleet, research, options) scrolls inside its own box.
*/

:root {
  --bg: #12131c;
  --panel: #1c1e2b;
  --panel-2: #272a3b;
  --line: #363a52;
  --text: #f1f2f8;
  --muted: #a3a8c0;
  --ink: #14151d;
  --accent: #ffd166;
  --danger: #ff8f8f;
  --well: #191b27;
  /* The game colours: the seven shapes and the six bubbles share them. */
  --cyan: #5fd4e8;
  --yellow: #ffd166;
  --violet: #b79cff;
  --green: #7bd88f;
  --red: #ff7a85;
  --blue: #6ea8ff;
  --orange: #ffa25e;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
p,
dl,
dd,
ol {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.3px;
}

h1:focus,
.page:focus {
  outline: none;
}

a {
  color: var(--accent);
}

/* ---------- Boot screen (index.html, before .NET has started) ---------- */

.boot {
  height: 100dvh;
  display: grid;
  place-content: center;
  gap: 18px;
  justify-items: center;
}

.boot__brand,
.brand {
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 26px;
}

.boot__brand span,
.brand span {
  color: var(--accent);
}

.boot__bar {
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.boot__bar i {
  display: block;
  height: 100%;
  width: var(--blazor-load-percentage, 8%);
  background: var(--accent);
  transition: width 0.2s;
}

#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 50;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #3a1f24;
  color: var(--text);
  font-size: 14px;
}

#blazor-error-ui .reload {
  margin-left: 8px;
}

#blazor-error-ui .dismiss {
  float: right;
  border: 0;
  background: none;
}

/* ---------- Shell ---------- */

.app {
  position: relative;
  display: flex;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* The theme is words and one colour (docs/adr/0008): the shell's class moves the accent. */
.theme--farm {
  --accent: #a5d86a;
}

@media (min-width: 640px) {
  /* A phone app on a big screen: keep it phone-shaped. */
  .app {
    max-width: 520px;
    margin-inline: auto;
    border-inline: 1px solid var(--line);
  }
}

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.bar__back {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}

.bar__back svg,
.icon-button svg {
  width: 22px;
  height: 22px;
}

.bar h1 {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__stats {
  display: flex;
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat small,
.label,
.eyebrow {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  color: var(--accent);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

.button:disabled {
  opacity: 0.4;
}

.button--danger {
  border-color: rgb(255 143 143 / 0.45);
  color: var(--danger);
}

.icon-button {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

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

.segmented {
  flex: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.segmented button {
  min-width: 0;
  height: 38px;
  padding: 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
}

.banner {
  flex: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgb(255 143 143 / 0.14);
  color: var(--danger);
  font-size: 12.5px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.card h2 {
  font-size: 15px;
}

.card p {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
}

.card p strong {
  color: var(--text);
}

/* ---------- Overlay on a board: start, pause, game over ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  background: rgb(18 19 28 / 0.86);
  text-align: center;
}

.overlay__title {
  font-size: 22px;
  font-weight: 850;
}

.overlay__score {
  font-size: 40px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.overlay__note {
  max-width: 240px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--muted);
}

/* What a move brought, over the board for a moment: rows cleared, a supply delivered. */
.callout {
  position: absolute;
  inset: 12% 8px auto 8px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  pointer-events: none;
  animation: callout 1.6s ease-out forwards;
}

.callout strong {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgb(18 19 28 / 0.82);
  font-size: 15px;
  font-weight: 850;
  color: var(--accent);
}

.callout span {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgb(18 19 28 / 0.82);
  font-size: 12px;
  font-weight: 700;
}

.callout--big strong {
  font-size: 22px;
}

@keyframes callout {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }

  15% {
    opacity: 1;
    transform: none;
  }

  75% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-14px);
  }
}

.overlay .button {
  min-width: 140px;
  margin-top: 6px;
}

/* ---------- Toast ---------- */

.toast-host {
  position: absolute;
  inset: auto 12px calc(16px + env(safe-area-inset-bottom)) 12px;
  z-index: 40;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 650;
  animation: toast-in 0.18s ease-out;
}

.toast--refusal {
  border-color: rgb(255 143 143 / 0.5);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Start page ---------- */

.page--home {
  gap: 16px;
  padding-top: 18px;
}

.home__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.games {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.game {
  flex: 1 1 0;
  min-height: 112px;
  max-height: 190px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.game--main {
  flex: 1.3 1 0;
  border-color: var(--accent);
  --tint: var(--accent);
}

.games__label {
  flex: none;
  margin: 2px 4px -4px;
}

.game__gives {
  color: var(--text);
}

.game:active {
  background: var(--panel-2);
}

.game__icon {
  flex: none;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--tint);
}

.game__icon svg {
  width: 34px;
  height: 34px;
}

.game--blocks {
  --tint: var(--cyan);
}

.game--fleet {
  --tint: var(--yellow);
}

.game--bubbles {
  --tint: var(--red);
}

.game__text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}

.game__text strong {
  font-size: 18px;
  color: var(--text);
}

.game__text em {
  font-style: normal;
  font-weight: 700;
  color: var(--tint);
}

.home__foot {
  flex: none;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Blockfall ---------- */

.blocks {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 10px;
}

.blocks__well {
  flex: 1;
  min-width: 0;
  position: relative;
  display: grid;
  place-items: center;
  container-type: size;
}

.board {
  /* As large as fits, ten wide and twenty high: full height unless the width runs out first. */
  width: min(100cqw, 50cqh);
  height: min(200cqw, 100cqh);
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(20, 1fr);
  gap: 1px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--well);
  touch-action: none;
}

.c {
  border-radius: 3px;
  background: rgb(255 255 255 / 0.025);
}

.c--i {
  background: var(--cyan);
}

.c--o {
  background: var(--yellow);
}

.c--t {
  background: var(--violet);
}

.c--s {
  background: var(--green);
}

.c--z {
  background: var(--red);
}

.c--j {
  background: var(--blue);
}

.c--l {
  background: var(--orange);
}

.c--i,
.c--o,
.c--t,
.c--s,
.c--z,
.c--j,
.c--l {
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.22), inset 0 2px 0 rgb(255 255 255 / 0.25);
}

.c--landing {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.22);
}

/* A full row on its way out: a flash, then it folds away (BlocksPage.VanishTime is as long). */
.c--vanish {
  animation: row-vanish 0.32s ease-in forwards;
}

@keyframes row-vanish {
  0% {
    filter: brightness(1);
  }

  35% {
    filter: brightness(2.4) saturate(0.2);
    transform: scale(1.08);
  }

  100% {
    filter: brightness(2.4) saturate(0.2);
    transform: scale(0);
    opacity: 0;
  }
}

.blocks__side {
  flex: 0 0 78px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.blocks__side .value {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.blocks__side .value--accent {
  color: var(--accent);
}

.preview {
  aspect-ratio: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1px;
  margin-bottom: 10px;
}

.preview .c {
  background-color: transparent;
}

.preview .c--i {
  background-color: var(--cyan);
}

.preview .c--o {
  background-color: var(--yellow);
}

.preview .c--t {
  background-color: var(--violet);
}

.preview .c--s {
  background-color: var(--green);
}

.preview .c--z {
  background-color: var(--red);
}

.preview .c--j {
  background-color: var(--blue);
}

.preview .c--l {
  background-color: var(--orange);
}

.blocks__pause {
  margin-top: auto;
  align-self: flex-end;
}

.pad {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr 0.4fr 1fr 1fr 1.2fr;
  gap: 8px;
  touch-action: none;
}

.pad button {
  height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.pad button:nth-child(3) {
  grid-column: 4;
}

.pad button:active {
  background: var(--panel-2);
}

.pad svg {
  width: 28px;
  height: 28px;
}

.pad .pad__turn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

@media (max-height: 600px) {
  .pad button {
    height: 50px;
  }
}

/* ---------- Blasenjagd ---------- */

.bubbles {
  flex: 1;
  min-height: 0;
  position: relative;
}

.field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.field__ground {
  fill: var(--well);
}

.field__limit {
  stroke: var(--danger);
  stroke-width: 0.04;
  stroke-dasharray: 0.2 0.2;
  opacity: 0.55;
}

.bubble {
  stroke: rgb(0 0 0 / 0.28);
  stroke-width: 0.05;
}

.bubble--red {
  fill: var(--red);
}

.bubble--yellow {
  fill: var(--yellow);
}

.bubble--green {
  fill: var(--green);
}

.bubble--blue {
  fill: var(--blue);
}

.bubble--violet {
  fill: var(--violet);
}

.bubble--orange {
  fill: var(--orange);
}

.bubble--next {
  opacity: 0.85;
}

.bubble--pop,
.bubble--drop {
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
}

.bubble--pop {
  animation: bubble-pop 0.22s ease-out forwards;
}

.bubble--drop {
  animation: bubble-drop 0.5s ease-in forwards;
}

@keyframes bubble-pop {
  to {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes bubble-drop {
  to {
    transform: translateY(700%);
    opacity: 0;
  }
}

.aim {
  fill: none;
  stroke: var(--text);
  stroke-width: 0.06;
  stroke-dasharray: 0.02 0.3;
  stroke-linecap: round;
  opacity: 0.75;
}

.aim__landing {
  fill: none;
  stroke: var(--text);
  stroke-width: 0.04;
  opacity: 0.5;
}

.miss {
  fill: var(--line);
}

.miss--left {
  fill: var(--accent);
}

/* ---------- Erzflotte: text and numbers ---------- */

.page--mining {
  font-variant-numeric: tabular-nums;
}

.notice {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: rgb(255 209 102 / 0.1);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
}

.notice span {
  margin-left: auto;
  font-weight: 800;
  color: var(--accent);
}

.ledger {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.ledger__credits {
  display: flex;
  flex-direction: column;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--accent);
}

.ledger__credits small {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.ledger dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ledger dt {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.ledger dd {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
}

.ledger .boosted {
  color: var(--accent);
}

.ledger__boost {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.list__label {
  flex: none;
  margin: 6px 4px 0;
}

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  background: var(--cyan);
}

.meter--full i {
  background: var(--danger);
}

.actions {
  flex: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
}

.actions .button {
  min-height: 54px;
  font-size: 15px;
}

.list,
.settings {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
}

.row__text strong {
  font-size: 15px;
  color: var(--text);
}

.row__text strong b {
  margin-left: 4px;
  color: var(--accent);
}

.row--tall .row__text {
  gap: 6px;
  font-size: 13px;
}

.row__buy {
  flex: none;
  display: flex;
  gap: 6px;
}

.row__buy .button {
  flex-direction: column;
  gap: 0;
  min-width: 68px;
  min-height: 48px;
  padding: 0 8px;
  font-size: 13px;
}

.row__buy .button:not(:disabled) {
  border-color: var(--accent);
}

.row__buy small {
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.list__hint {
  padding: 6px 4px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  list-style: none;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.log li::before {
  content: "> ";
  color: var(--accent);
}

.log li:first-child {
  color: var(--text);
}

/* ---------- Optionen ---------- */

.settings {
  gap: 12px;
}

.settings__footer {
  padding: 4px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}
