/* =========================================================
   NEOTRIS – Stylesheet
   Aufbau: Tokens · Grundlagen · HUD · Spielfeld · Tasten ·
           Overlays · Formulare · Responsive (iPhone/iPad)
   ========================================================= */

:root {
  --bg-0: #05070f;
  --bg-1: #0b1022;
  --bg-2: #141a33;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef1ff;
  --text-dim: #9aa3c7;
  --accent: #5ad1ff;
  --accent-2: #b980ff;
  --accent-3: #ff5d8f;
  --good: #4ce1b6;
  --danger: #ff6b6b;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --pad-scale: 1;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg-0);
  color: var(--text);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* Ruhiger Farbverlauf im Hintergrund, bewusst statisch für ältere Geräte */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(45% 35% at 18% 12%, rgba(90, 209, 255, 0.16), transparent 70%),
    radial-gradient(40% 40% at 85% 20%, rgba(185, 128, 255, 0.16), transparent 70%),
    radial-gradient(60% 45% at 50% 100%, rgba(255, 93, 143, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0) 60%);
  z-index: -1;
}

#app {
  position: relative;
  height: 100%;
  height: 100dvh;
}

/* ---------------------------------------------------------
   Bühne
   --------------------------------------------------------- */
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* eine Spalte, die nie breiter wird als die Bühne selbst */
  grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--sat) + 6px) calc(var(--sar) + 10px) calc(var(--sab) + 6px) calc(var(--sal) + 10px);
  gap: 8px;
}

/* ---------------------------------------------------------
   HUD
   --------------------------------------------------------- */
.hud {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.hud-scores {
  display: flex;
  flex: 1;
  gap: 14px;
  justify-content: center;
  min-width: 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stat-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.15;
}

.stat-score .stat-value {
  font-size: 24px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-value.bump { animation: bump 0.28s ease-out; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.hud-player {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 26vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--text);
  cursor: pointer;
}

.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:active { transform: scale(0.94); }

/* ---------------------------------------------------------
   Spielfeld
   --------------------------------------------------------- */
.playarea {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.rail {
  --rail-dir: 0;            /* 0 = Spalte, 1 = Zeile – wird von JS gelesen */
  --next-slots: 5;          /* Anzahl der Vorschausteine, ebenfalls für JS */
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: start;
  width: 60px;
}

.mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.mini-title {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.mini canvas { width: 100%; height: auto; display: block; }

.mini-value {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  /* min-* auf 0: sonst drueckt die Canvas-Eigengroesse die Spalte auf */
  min-width: 0;
  min-height: 0;
}

#c-board {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--r-md);
  background: rgba(4, 6, 14, 0.62);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 0 60px rgba(90, 209, 255, 0.06);
  touch-action: none;
}

.board-wrap.shake { animation: shake 0.28s cubic-bezier(0.36, 0.07, 0.19, 0.97); }

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 1px, 0); }
  30%, 70% { transform: translate3d(3px, -2px, 0); }
  50% { transform: translate3d(-4px, 2px, 0); }
}

.combo-toast {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, 0) scale(0.8);
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: clamp(15px, 4.4vw, 22px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: rgba(10, 14, 30, 0.8);
  border: 1px solid var(--line);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 18px rgba(90, 209, 255, 0.6);
}

.combo-toast.show { animation: pop 1.1s ease-out forwards; }

@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -6px) scale(1.06); }
  70% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(0.96); }
}

/* ---------------------------------------------------------
   Bildschirm-Tasten
   --------------------------------------------------------- */
.pad {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 4px 2px 2px;
}

.pad[hidden] { display: none; }

/* Beide Gruppen teilen sich die Breite – dadurch passt die Leiste
   vom iPhone SE bis zum iPad Pro ohne Sonderfälle. */
.pad-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(8px * var(--pad-scale));
  flex: 1 1 0;
  min-width: 0;
  max-width: calc(280px * var(--pad-scale));
}

.pad-act .pad-btn-wide { grid-column: 1 / -1; max-width: none; border-radius: calc(22px * var(--pad-scale)); }

.pad-btn {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: calc(74px * var(--pad-scale));
  height: calc(54px * var(--pad-scale));
  justify-self: center;
  border-radius: calc(18px * var(--pad-scale));
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.045));
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease;
  touch-action: none;
}

.pad-btn svg {
  width: calc(24px * var(--pad-scale));
  height: calc(24px * var(--pad-scale));
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pad-btn.is-down,
.pad-btn:active {
  transform: scale(0.93);
  background: linear-gradient(180deg, rgba(90, 209, 255, 0.4), rgba(185, 128, 255, 0.22));
}

.pad-btn-primary { border-color: rgba(90, 209, 255, 0.45); }

.pad[data-hand="left"] { flex-direction: row-reverse; }
.pad[data-hand="split"] .pad-dir,
.pad[data-hand="split"] .pad-act { justify-items: center; }

/* ---------------------------------------------------------
   Overlays / Screens
   --------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 14px) calc(var(--sar) + 14px) calc(var(--sab) + 14px) calc(var(--sal) + 14px);
  background: rgba(4, 6, 14, 0.72);
  backdrop-filter: blur(22px) saturate(120%);
  -webkit-backdrop-filter: blur(22px) saturate(120%);
}

.screen.is-open { display: flex; animation: fade 0.22s ease-out; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: min(440px, 100%);
  max-height: 100%;
  padding: 24px 22px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(24, 30, 56, 0.92), rgba(11, 16, 34, 0.94));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}

.sheet-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.sheet h2 {
  margin: 0 0 16px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.logo {
  margin: 0;
  font-size: clamp(38px, 12vw, 56px);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}

.logo span { opacity: 0.85; }

.tagline {
  margin: 6px 0 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.btn {
  appearance: none;
  min-height: 52px;
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.07s ease, filter 0.15s ease;
}

.btn:active { transform: scale(0.975); }

.btn-primary {
  border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #06101c;
  box-shadow: 0 10px 26px rgba(90, 209, 255, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  min-height: 44px;
  font-weight: 500;
}

.btn-danger { color: var(--danger); }

.btn[disabled] { opacity: 0.38; pointer-events: none; }

.hint {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

.pause-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pause-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--glass);
  border: 1px solid var(--line);
}

.pause-stats span {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.pause-stats strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.final-score {
  margin: 0 0 16px;
  text-align: center;
  font-size: clamp(40px, 13vw, 58px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rank-note {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 14px;
  color: var(--good);
  background: rgba(76, 225, 182, 0.1);
  border: 1px solid rgba(76, 225, 182, 0.3);
}

/* Bestenliste */
.score-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.score-list li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--glass);
  border: 1px solid var(--line);
}

.score-list li.is-me { border-color: rgba(90, 209, 255, 0.5); }

.score-rank { font-weight: 800; color: var(--text-dim); text-align: center; }
.score-list li:nth-child(1) .score-rank { color: #ffd76a; }
.score-list li:nth-child(2) .score-rank { color: #d7dcf5; }
.score-list li:nth-child(3) .score-rank { color: #e0a06a; }

.score-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.score-meta { display: block; font-size: 11px; color: var(--text-dim); font-weight: 400; }
.score-points { font-weight: 700; font-variant-numeric: tabular-nums; }

.empty-note { color: var(--text-dim); font-size: 14px; text-align: center; padding: 24px 0; }


/* Umschalter in der Bestenliste */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}

.tab {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: none;
  border-radius: calc(var(--r-md) - 5px);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #06101c;
}

.list-note {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  text-align: center;
}

.list-note[hidden] { display: none; }

/* ---------------------------------------------------------
   Formulare
   --------------------------------------------------------- */
.field { display: block; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 16px; /* verhindert Auto-Zoom in iOS Safari */
  font-family: inherit;
  -webkit-user-select: text;
  user-select: text;
  appearance: none;
}

select { max-width: 190px; }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 209, 255, 0.18);
}

.group-title {
  margin: 22px 0 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.row label { font-size: 15px; }
.row input[type="number"] { max-width: 92px; text-align: center; }

input[type="range"] {
  appearance: none;
  width: 150px;
  height: 30px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.16); }
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border: none; border-radius: 50%; background: var(--accent); }

.switch {
  appearance: none;
  position: relative;
  width: 52px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.2s ease;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.3, 1.3, 0.6, 1);
}

.switch:checked { background: linear-gradient(120deg, var(--accent), var(--accent-2)); }
.switch:checked::after { transform: translateX(21px); }

.help-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
}

.help-list strong { color: var(--text); }

/* ---------------------------------------------------------
   Toast
   --------------------------------------------------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sab) + 22px);
  transform: translate(-50%, 20px);
  z-index: 50;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(12, 17, 36, 0.94);
  border: 1px solid var(--line);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* Sichtbarer Startfehler statt stiller Blockade */
.fatal {
  position: fixed;
  left: 50%;
  top: calc(var(--sat) + 12px);
  transform: translateX(-50%);
  z-index: 999;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: rgba(60, 12, 24, 0.96);
  border: 1px solid rgba(255, 107, 107, 0.6);
  color: #ffd9d9;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.fatal[hidden] { display: none; }

.version {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(154, 163, 199, 0.65);
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
/* Sehr schmale Geräte (iPhone SE/mini) */
@media (max-width: 400px) {
  .rail { width: 52px; }
  .hud-player { display: none; }
  .pad-btn { height: calc(48px * var(--pad-scale)); max-width: calc(62px * var(--pad-scale)); }
  .pad-group { gap: calc(6px * var(--pad-scale)); }
  .pad { gap: 8px; }
}

/* Größere Telefone im Querformat und kleine Tablets */
@media (min-width: 601px) {
  .rail { width: 84px; }
}

/* Tablets: mehr Luft, größere Seitenspalten */
@media (min-width: 768px) {
  .stage { padding-left: calc(var(--sal) + 26px); padding-right: calc(var(--sar) + 26px); gap: 14px; }
  .rail { width: 128px; }
  .mini-title { font-size: 11px; }
  .mini-value { font-size: 20px; }
  .stat-value { font-size: 22px; }
  .stat-score .stat-value { font-size: 32px; }
  .playarea { gap: 22px; }
  .pad { padding: 10px 6px 6px; }
  .pad-group { gap: calc(14px * var(--pad-scale)); max-width: calc(360px * var(--pad-scale)); }
  .pad-btn { max-width: calc(104px * var(--pad-scale)); height: calc(72px * var(--pad-scale)); border-radius: calc(24px * var(--pad-scale)); }
  .pad-btn svg { width: calc(32px * var(--pad-scale)); height: calc(32px * var(--pad-scale)); }
  .sheet { width: min(520px, 100%); padding: 32px 30px; }
}

/* Tablet im Querformat: Tasten an die Ränder, das Feld bekommt
   die volle Höhe. */
@media (orientation: landscape) and (min-width: 768px) and (min-height: 501px) {
  .stage { grid-template-rows: auto minmax(0, 1fr); }
  .pad {
    position: absolute;
    inset: auto 0 0 0;
    padding: 0 calc(var(--sar) + 20px) calc(var(--sab) + 16px) calc(var(--sal) + 20px);
    pointer-events: none;
  }
  .pad-group { pointer-events: auto; max-width: calc(300px * var(--pad-scale)); }
  .pad-btn { max-width: calc(84px * var(--pad-scale)); height: calc(64px * var(--pad-scale)); }
}

/* Querformat auf dem Telefon: Tasten neben das Feld */
@media (orientation: landscape) and (max-height: 500px) {
  .stage { grid-template-rows: auto minmax(0, 1fr); gap: 6px; }
  .hud { padding: 4px 10px; }
  .stat-score .stat-value { font-size: 18px; }
  .pad {
    position: absolute;
    inset: auto 0 0 0;
    padding: 0 calc(var(--sar) + 10px) calc(var(--sab) + 8px) calc(var(--sal) + 10px);
    pointer-events: none;
  }
  .pad-group { pointer-events: auto; max-width: calc(220px * var(--pad-scale)); }
  .pad-btn { max-width: calc(58px * var(--pad-scale)); height: calc(46px * var(--pad-scale)); }
  /* kürzere Vorschau, damit die Spalte nicht unter die Tasten läuft */
  .rail { width: 88px; --next-slots: 3; }
}

/* ---------------------------------------------------------
   Telefon im Hochformat: Halten und Vorschau wandern über das
   Feld, damit das Spielfeld die volle Breite bekommt.
   --------------------------------------------------------- */
@media (max-width: 600px) and (orientation: portrait) {
  .playarea {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "hold next"
      "board board";
    align-items: stretch;
    justify-items: stretch;
    gap: 8px;
  }

  .rail {
    --rail-dir: 1;
    --next-slots: 3;
    flex-direction: row;
    align-items: stretch;
    width: auto;
    gap: 8px;
  }

  .rail-left { grid-area: hold; }
  .rail-right { grid-area: next; }
  .board-wrap { grid-area: board; }

  .mini {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 5px 9px;
  }

  .rail-right .mini { flex: 1; }
  .mini canvas { flex: 1 1 auto; width: auto; min-width: 34px; }
  .rail-left .mini canvas { min-width: 46px; max-width: 64px; }

  /* Der Bestwert steht im Menü und am Spielende – hier zählt Platz */
  .mini-best { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
