/* Tetris Infinite — 2D pixel skin (framework 1.13.0)
 * Hard 8px grid, 0 radius, 2/3px borders and 4/6px offset shadows.
 * No gradients, blur, glow, translucent glass or soft shadows.
 */

:root {
  --tet-bg: var(--color-bg);
  --tet-surface: var(--color-surface);
  --tet-surface-2: var(--color-surface-2);
  --tet-ink: var(--color-text);
  --tet-muted: var(--color-text-muted);
  --tet-border: var(--color-border);
  --tet-brand: var(--color-brand-500);
  --tet-brand-strong: var(--color-brand-600);
  --tet-accent: var(--color-warning);
  --tet-leaf: var(--color-success);
  --tet-danger: var(--color-danger);
  --tet-on-brand: var(--color-on-brand);
  --tet-focus: var(--color-focus);

  --tet-grid: 8px;
  --tet-border-width: 3px;
  --tet-border-thin: 2px;
  --tet-shadow-offset: 4px;
  --tet-shadow-offset-lg: 6px;
  --tet-ui-font: var(--pixel-ui-font);

  --tet-console: var(--color-surface-2);
  --tet-console-deep: var(--color-surface);
  --tet-console-panel: var(--color-surface);
  --tet-console-text: var(--color-text);
  --tet-console-muted: var(--color-text-muted);
  --tet-console-edge: var(--color-text);
  --tet-shadow: var(--color-text);
  --tet-board-veil: color-mix(in srgb, var(--color-stage-bg) 88%, transparent);

  --tet-board-bg: var(--color-stage-bg);
  --tet-board-grid: color-mix(in srgb, var(--color-on-brand) 13%, transparent);
  --tet-board-edge: color-mix(in srgb, var(--color-on-brand) 36%, transparent);
  --tet-block-edge: color-mix(in srgb, var(--color-stage-bg) 82%, var(--color-text));
  --tet-highlight: color-mix(in srgb, var(--color-on-brand) 90%, var(--color-warning));
  --tet-shade: color-mix(in srgb, var(--color-stage-bg) 72%, var(--color-text));
  --tet-ghost: color-mix(in srgb, var(--color-on-brand) 34%, transparent);

  --tet-i: var(--color-brand-500);
  --tet-o: var(--color-warning);
  --tet-t: var(--color-success);
  --tet-s: color-mix(in srgb, var(--color-brand-500) 58%, var(--color-success));
  --tet-z: var(--color-danger);
  --tet-j: var(--color-brand-600);
  --tet-l: color-mix(in srgb, var(--color-warning) 55%, var(--color-danger));
  --tet-g: var(--color-text-muted);
}

[data-theme="dark"] {
  --tet-console: color-mix(in srgb, var(--color-stage-bg) 86%, var(--color-brand-500));
  --tet-console-deep: var(--color-stage-bg);
  --tet-console-panel: color-mix(in srgb, var(--color-stage-bg) 80%, var(--color-surface));
  --tet-console-text: var(--color-on-brand);
  --tet-console-muted: color-mix(in srgb, var(--color-on-brand) 64%, transparent);
  --tet-console-edge: color-mix(in srgb, var(--color-on-brand) 30%, transparent);
  --tet-shadow: var(--color-stage-bg);
  --tet-board-veil: color-mix(in srgb, var(--color-stage-bg) 80%, transparent);
  --tet-block-edge: color-mix(in srgb, var(--color-stage-bg) 70%, var(--color-on-brand));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--tet-bg);
}

body {
  color: var(--tet-ink);
  font-family: var(--font-sans);
  font-size: var(--font-size-min-mobile);
  line-height: var(--line-height-base);
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button,
canvas {
  touch-action: manipulation;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--tet-focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.tet-app {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding:
    max(var(--space-2), var(--safe-top))
    max(var(--space-2), var(--safe-right))
    max(var(--space-2), var(--safe-bottom))
    max(var(--space-2), var(--safe-left));
  overflow: hidden;
  border: var(--tet-border-width) solid var(--tet-console-edge);
  background: var(--tet-console);
  box-shadow: var(--tet-shadow-offset-lg) var(--tet-shadow-offset-lg) 0 var(--tet-shadow);
  isolation: isolate;
}

.tet-scene {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background-image: url("../assets/tetris-scene-light.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

[data-theme="dark"] .tet-scene {
  background-image: url("../assets/tetris-scene-dark.png");
}

.tet-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--tet-console) 78%, transparent);
}

.tet-header,
.tet-game {
  position: relative;
  z-index: 1;
}

.tet-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: 44px;
}

.tet-brand {
  display: flex;
  flex: 0 1 200px;
  min-width: 0;
  align-items: center;
  gap: var(--space-2);
  padding-inline: 2px;
}

.tet-brand__mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-brand);
  box-shadow: 2px 2px 0 var(--tet-shadow);
}

.tet-brand__sprite {
  display: block;
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

.tet-brand__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: var(--line-height-tight);
}

.tet-brand__copy strong {
  overflow: hidden;
  color: var(--tet-console-text);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-sm);
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tet-brand__copy small {
  overflow: hidden;
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tet-hud-stats {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-1);
}

.tet-stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  padding: 3px 4px;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-panel);
  box-shadow: 2px 2px 0 var(--tet-shadow);
  line-height: var(--line-height-tight);
}

.tet-stat span {
  overflow: hidden;
  width: 100%;
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.tet-stat strong {
  overflow: hidden;
  width: 100%;
  color: var(--tet-console-text);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-md);
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-pop {
  animation: tet-pop 280ms steps(3, end);
  transform-origin: center;
}

@keyframes tet-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

.tet-game {
  display: grid;
  min-height: 0;
  flex: 1 1 auto;
  grid-template-areas:
    "hold board next"
    "controls controls controls";
  grid-template-columns: minmax(54px, 64px) minmax(0, 1fr) minmax(54px, 64px);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.tet-board-col {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  grid-area: board;
  align-items: center;
  justify-content: center;
  padding: 3px;
  border: var(--tet-border-width) solid var(--tet-console-edge);
  background: var(--tet-console-deep);
  box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
}

.tet-board-wrap {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  place-items: center;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background-color: var(--tet-board-bg);
  background-image: url("../assets/tetris-scene-dark.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

[data-theme="light"] .tet-board-wrap {
  background-image: url("../assets/tetris-scene-light.png");
}

.tet-board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--tet-board-veil);
  pointer-events: none;
}

#board {
  position: relative;
  z-index: 1;
  display: block;
  background: transparent;
  image-rendering: pixelated;
  touch-action: none;
}

.tet-special {
  position: absolute;
  z-index: 3;
  top: 6px;
  left: 50%;
  display: flex;
  max-width: calc(100% - 12px);
  align-items: center;
  gap: var(--space-1);
  padding: 2px 6px;
  transform: translateX(-50%);
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  color: var(--tet-console-text);
  background: var(--tet-console-panel);
  box-shadow: 2px 2px 0 var(--tet-shadow);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  line-height: 1.3;
  pointer-events: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.tet-special.is-pulsed {
  animation: tet-badge-pulse 320ms steps(3, end);
}

@keyframes tet-badge-pulse {
  0% {
    transform: translateX(-50%) scale(0.94);
    opacity: 0.6;
  }
  45% {
    transform: translateX(-50%) scale(1.06);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

.tet-special strong {
  font-variant-numeric: tabular-nums;
}

.tet-special span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tet-special[data-tone="danger"] {
  border-color: var(--tet-danger);
  background: color-mix(in srgb, var(--tet-danger) 24%, var(--tet-console-panel));
}

.tet-special[data-tone="warn"] {
  border-color: var(--tet-accent);
  background: color-mix(in srgb, var(--tet-accent) 24%, var(--tet-console-panel));
}

.tet-danger {
  position: absolute;
  z-index: 3;
  top: 6px;
  right: 6px;
  margin: 0;
  padding: 2px 5px;
  border: var(--tet-border-thin) solid var(--tet-danger);
  color: var(--tet-console-text);
  background: color-mix(in srgb, var(--tet-danger) 32%, var(--tet-console-panel));
  box-shadow: 2px 2px 0 var(--tet-shadow);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  letter-spacing: 0.04em;
  pointer-events: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.tet-pop-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.tet-pop {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, 0);
  color: var(--tet-accent);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.06em;
  text-align: center;
  text-shadow: 2px 2px 0 var(--tet-shadow);
  white-space: nowrap;
  animation: tet-pop-float 900ms steps(6, end) forwards;
}

.tet-pop--combo {
  top: 48%;
  color: var(--tet-leaf);
}

.tet-pop--tetris {
  top: 50%;
  color: var(--tet-brand);
  font-size: var(--font-size-xl);
}

.tet-pop--level {
  top: 30%;
  color: var(--tet-accent);
}

.tet-pop--warn {
  top: 42%;
  color: var(--tet-accent);
}

.tet-pop--danger {
  top: 56%;
  color: var(--tet-danger);
}

@keyframes tet-pop-float {
  0% {
    transform: translate(-50%, 12px);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -44px);
    opacity: 0;
  }
}

.tet-side {
  display: contents;
}

.tet-topbar {
  display: contents;
}

.tet-panel {
  min-width: 0;
  padding: var(--space-1);
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-panel);
  box-shadow: 2px 2px 0 var(--tet-shadow);
}

.tet-hold {
  grid-area: hold;
  align-self: start;
}

.tet-hold.is-pulsed {
  animation: tet-hold-pulse 300ms steps(3, end);
}

@keyframes tet-hold-pulse {
  0%,
  100% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(-2px);
  }
}

.tet-next {
  grid-area: next;
  align-self: start;
}

.tet-panel__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  margin: 0 0 3px;
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

kbd {
  padding: 0 3px;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  color: var(--tet-console-muted);
  background: var(--tet-console-deep);
  font-family: var(--tet-ui-font);
  font-size: 0.7em;
  font-weight: var(--font-weight-medium);
  text-transform: none;
}

code {
  padding: 0 3px;
  border: 1px solid var(--tet-console-edge);
  color: var(--tet-console-text);
  background: var(--tet-console-deep);
  font-family: var(--tet-ui-font);
  font-size: 0.92em;
}

.tet-preview {
  display: block;
  width: 100%;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-board-bg);
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

.tet-hold .tet-preview {
  height: 50px;
}

.tet-next__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tet-next .tet-preview {
  height: 46px;
}

.tet-stats {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  padding: var(--space-2);
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-panel);
  box-shadow: 2px 2px 0 var(--tet-shadow);
}

.tet-stats__row {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
}

.tet-stats__row span {
  color: var(--tet-console-muted);
  text-transform: uppercase;
}

.tet-stats__row strong {
  overflow: hidden;
  color: var(--tet-console-text);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tet-controls {
  display: flex;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  grid-area: controls;
  gap: 10px;
  margin: var(--space-1) auto 0;
  padding: 2px 8px;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-panel);
  box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
}

.tet-pad-grid {
  display: grid;
  flex: 0 0 auto;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: transparent;
  grid-template-areas:
    "left rotate right hold"
    "soft hard hard pause";
  grid-template-columns: repeat(4, var(--touch-target-min));
  grid-auto-rows: var(--touch-target-min);
}

.tet-pad-grid__left {
  grid-area: left;
}

.tet-pad-grid__rotate {
  grid-area: rotate;
}

.tet-pad-grid__right {
  grid-area: right;
}

.tet-pad-grid__hold {
  grid-area: hold;
}

.tet-pad-grid__soft {
  grid-area: soft;
}

.tet-pad-grid__hard {
  grid-area: hard;
}

.tet-pad-grid__pause {
  grid-area: pause;
}

.tet-controls .tet-btn--pad {
  width: 100%;
  height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  padding: 0;
}

.tet-controls .tet-btn--rotate {
  border-color: var(--tet-brand);
  color: var(--tet-brand);
}

.tet-controls .tet-btn--hard {
  border-color: var(--tet-brand-strong);
  color: var(--tet-on-brand);
  background: var(--tet-brand);
}

.tet-btn {
  display: flex;
  min-width: var(--touch-target-min);
  min-height: 48px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  padding: 3px;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  color: var(--tet-console-text);
  background: var(--tet-console-panel);
  box-shadow: 2px 2px 0 var(--tet-shadow);
  cursor: pointer;
  line-height: 1.15;
  touch-action: manipulation;
  user-select: none;
}

.tet-btn__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tet-icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.tet-icon--play {
  display: none;
}

[aria-pressed="true"] .tet-icon--pause {
  display: none;
}

[aria-pressed="true"] .tet-icon--play {
  display: block;
}

.tet-btn__label {
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
}

.tet-btn:active,
.tet-btn[data-pressed="true"] {
  transform: translate(2px, 2px);
  border-color: var(--tet-brand);
  background: color-mix(in srgb, var(--tet-brand) 18%, var(--tet-console-panel));
  box-shadow: none;
}

.tet-controls .tet-btn--hard:active,
.tet-controls .tet-btn--hard[data-pressed="true"] {
  border-color: var(--tet-brand-strong);
  color: var(--tet-on-brand);
  background: var(--tet-brand-strong);
  box-shadow: none;
}

.tet-btn--primary {
  width: 100%;
  min-height: 50px;
  flex-direction: row;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: var(--tet-border-width) solid var(--tet-brand-strong);
  color: var(--tet-on-brand);
  background: var(--tet-brand);
  box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
}

.tet-btn--primary:active {
  transform: translate(2px, 2px);
  color: var(--tet-on-brand);
  background: var(--tet-brand-strong);
  box-shadow: none;
}

.tet-meta {
  display: none;
  line-height: 1.4;
}

.tet-help,
.tet-seed-line {
  margin: 0;
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
}

.tet-seed-line strong {
  color: var(--tet-console-text);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-sm);
  letter-spacing: 0.03em;
}

.tet-seed-line span {
  display: block;
}

.tet-overlay {
  position: fixed;
  z-index: var(--z-overlay);
  inset: 0;
  display: grid;
  overflow: auto;
  padding:
    max(var(--space-4), var(--safe-top))
    max(var(--space-4), var(--safe-right))
    max(var(--space-4), var(--safe-bottom))
    max(var(--space-4), var(--safe-left));
  place-items: center;
  background: var(--color-scrim);
}

.tet-card {
  width: min(100%, 430px);
  max-height: 80vh;
  overflow: auto;
  padding: var(--space-4);
  border: var(--tet-border-width) solid var(--tet-console-edge);
  color: var(--tet-console-text);
  background: var(--tet-console-panel);
  box-shadow: var(--tet-shadow-offset-lg) var(--tet-shadow-offset-lg) 0 var(--tet-shadow);
  animation: tet-card-in var(--duration-base) steps(3, end);
}

@keyframes tet-card-in {
  from {
    transform: translateY(6px);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.tet-card--compact {
  max-width: 360px;
}

.tet-card__sprite {
  display: block;
  width: 32px;
  height: 32px;
  margin: 0 0 var(--space-2);
  image-rendering: pixelated;
  image-rendering: -webkit-optimize-contrast;
}

.tet-eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--tet-brand);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tet-card__title {
  margin: 0 0 var(--space-2);
  color: var(--tet-console-text);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-2xl);
  letter-spacing: 0.02em;
  line-height: var(--line-height-tight);
  text-transform: uppercase;
}

.tet-card__text {
  margin: 0 0 var(--space-3);
  color: var(--tet-console-muted);
  font-size: var(--font-size-md);
}

.tet-card__hint {
  margin: var(--space-3) 0 0;
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  line-height: 1.5;
}

.tet-card .tet-seed-line {
  margin: 0 0 var(--space-3);
}

.tet-card .tet-btn--primary {
  margin-top: var(--space-1);
}

.tet-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin: var(--space-3) 0;
}

.tet-result span {
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-deep);
  line-height: var(--line-height-tight);
}

.tet-result small {
  color: var(--tet-console-muted);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
}

.tet-result strong {
  color: var(--tet-console-text);
  font-family: var(--tet-ui-font);
  font-size: var(--font-size-lg);
  font-variant-numeric: tabular-nums;
}

.tet-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.tet-color-probe {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
 * Landscape: board on the left, information rail and controls on the right.
 * -------------------------------------------------------------------------- */
.tet-app[data-layout="landscape"] .tet-game {
  grid-template-areas: "board side";
  grid-template-columns: minmax(0, 1fr) 316px;
  grid-template-rows: minmax(0, 1fr);
}

.tet-app[data-layout="landscape"] .tet-board-col {
  padding: 0;
}

.tet-app[data-layout="landscape"] .tet-side {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: var(--space-2);
  grid-area: side;
}

.tet-app[data-layout="landscape"] .tet-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px 6px;
  padding: var(--space-1) var(--space-2);
}

.tet-app[data-layout="landscape"] .tet-hold,
.tet-app[data-layout="landscape"] .tet-next {
  align-self: stretch;
}

.tet-app[data-layout="landscape"] .tet-next__list {
  flex-direction: row;
}

.tet-app[data-layout="landscape"] .tet-hold .tet-preview,
.tet-app[data-layout="landscape"] .tet-next .tet-preview {
  height: 44px;
}

.tet-app[data-layout="landscape"] .tet-controls {
  margin-top: auto;
}

.tet-app[data-layout="landscape"] .tet-meta {
  display: block;
}

/* --------------------------------------------------------------------------
 * Portrait: Hold, Next and compact stats share one strip above the board.
 * The Shell HUD keeps Score/Best visible, so the in-game header is hidden.
 * -------------------------------------------------------------------------- */
.tet-app[data-layout="portrait"] {
  padding:
    max(0px, var(--safe-top))
    max(var(--space-1), var(--safe-right))
    max(0px, var(--safe-bottom))
    max(var(--space-1), var(--safe-left));
}

.tet-app[data-layout="portrait"] .tet-header {
  display: none;
}

.tet-app[data-layout="portrait"] .tet-game {
  gap: 0;
  grid-template-areas:
    "topbar"
    "board"
    "controls";
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.tet-app[data-layout="portrait"] .tet-topbar,
.tet-app[data-layout="portrait"] .tet-board-col,
.tet-app[data-layout="portrait"] .tet-controls {
  width: 100%;
  max-width: 100%;
  margin-inline: auto;
}

.tet-app[data-layout="portrait"] .tet-topbar {
  display: grid;
  grid-area: topbar;
  height: 30px;
  grid-template-columns: 72px minmax(0, 1fr) 84px;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  background: var(--tet-console-panel);
  box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
}

.tet-app[data-layout="portrait"] .tet-board-col {
  position: relative;
  padding: 0;
  border: var(--tet-border-thin) solid var(--tet-console-edge);
  border-top: 0;
  box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
}

.tet-app[data-layout="portrait"] .tet-controls {
  margin-top: 0;
}

.tet-app[data-layout="portrait"] .tet-hold,
.tet-app[data-layout="portrait"] .tet-next {
  display: flex;
  grid-area: auto;
  min-width: 0;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  align-self: stretch;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.tet-app[data-layout="portrait"] .tet-hold {
  border-right: 1px solid var(--tet-console-edge);
}

.tet-app[data-layout="portrait"] .tet-next {
  border-right: 1px solid var(--tet-console-edge);
}

.tet-app[data-layout="portrait"] .tet-stats {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.tet-app[data-layout="portrait"] .tet-panel__title {
  flex: 0 0 auto;
  margin: 0;
}

.tet-app[data-layout="portrait"] .tet-panel__title kbd {
  display: none;
}

.tet-app[data-layout="portrait"] .tet-hold .tet-preview {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-left: auto;
}

.tet-app[data-layout="portrait"] .tet-next__list {
  display: flex;
  flex-direction: row;
  gap: 2px;
  margin-left: auto;
}

.tet-app[data-layout="portrait"] .tet-next .tet-preview {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.tet-app[data-layout="portrait"] .tet-stats {
  display: grid;
  grid-area: auto;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0 4px;
  align-self: stretch;
}

.tet-app[data-layout="portrait"] .tet-stats__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px;
  min-width: 0;
  font-size: var(--font-size-xs);
  line-height: 1;
}

.tet-app[data-layout="portrait"] .tet-stats__row:nth-child(1),
.tet-app[data-layout="portrait"] .tet-stats__row:nth-child(2),
.tet-app[data-layout="portrait"] .tet-stats__row:nth-child(5),
.tet-app[data-layout="portrait"] .tet-stats__row:nth-child(6) {
  display: none;
}

@media (max-width: 300px) {
  .tet-controls {
    gap: var(--space-2);
    padding: 4px 6px;
  }

  .tet-pad-grid {
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .tet-app[data-layout="portrait"] .tet-topbar {
    grid-template-columns: 68px minmax(0, 1fr) 76px;
  }

  .tet-app[data-layout="portrait"] .tet-hold,
  .tet-app[data-layout="portrait"] .tet-next {
    gap: 3px;
    padding-inline: 4px;
  }

  .tet-app[data-layout="portrait"] .tet-hold .tet-preview {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .tet-app[data-layout="portrait"] .tet-next .tet-preview {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }
}

@media (max-width: 374px) {
  .tet-brand {
    flex-basis: 42px;
  }

  .tet-brand__copy {
    display: none;
  }

  .tet-brand__mark {
    width: 36px;
    height: 36px;
  }

  .tet-game {
    grid-template-columns: 54px minmax(0, 1fr) 54px;
  }

  .tet-panel__title kbd {
    display: none;
  }
}

@media (max-height: 560px) and (orientation: portrait) {
  .tet-brand__copy small {
    display: none;
  }

  .tet-card__hint,
  .tet-overlay .tet-eyebrow {
    display: none;
  }

  .tet-card__title {
    font-size: var(--font-size-xl);
  }

  .tet-hold .tet-preview {
    height: 42px;
  }

  .tet-next .tet-preview {
    height: 38px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .tet-btn:not(.tet-btn--primary):hover {
    transform: translate(-2px, -2px);
    border-color: var(--tet-brand);
    box-shadow: var(--tet-shadow-offset) var(--tet-shadow-offset) 0 var(--tet-shadow);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .tet-app[data-layout="landscape"] .tet-header {
    display: none;
  }

  .tet-overlay {
    padding: var(--space-2);
  }

  .tet-card {
    padding: var(--space-3);
  }

  .tet-card__title {
    margin-bottom: var(--space-1);
    font-size: var(--font-size-xl);
  }

  .tet-card__text {
    margin-bottom: var(--space-2);
  }

  .tet-card .tet-seed-line {
    margin-bottom: var(--space-2);
  }

  .tet-card__hint,
  .tet-overlay .tet-eyebrow {
    display: none;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .tet-app[data-layout="landscape"] .tet-header {
    min-height: 32px;
  }

  .tet-card__title {
    font-size: var(--font-size-lg);
  }

  .tet-card .tet-seed-line {
    margin-bottom: var(--space-1);
  }

  .tet-app[data-layout="landscape"] .tet-brand__mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .tet-app[data-layout="landscape"] .tet-brand__sprite {
    width: 26px;
    height: 26px;
  }

  .tet-app[data-layout="landscape"] .tet-side {
    display: grid;
    grid-template-areas:
      "hold next"
      "controls controls";
    grid-template-columns: 66px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: var(--space-1);
  }

  .tet-app[data-layout="landscape"] .tet-hold {
    grid-area: hold;
  }

  .tet-app[data-layout="landscape"] .tet-next {
    grid-area: next;
  }

  .tet-app[data-layout="landscape"] .tet-stats {
    display: none;
  }

  .tet-app[data-layout="landscape"] .tet-controls {
    grid-area: controls;
    align-self: end;
    margin-top: 0;
  }

  .tet-app[data-layout="landscape"] .tet-hold .tet-preview,
  .tet-app[data-layout="landscape"] .tet-next .tet-preview {
    height: 38px;
  }

  .tet-app[data-layout="landscape"] .tet-meta {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tet-scene,
  .tet-pop {
    animation: none;
  }

  .tet-pop {
    opacity: 1;
  }

  .tet-btn:not(.tet-btn--primary):hover {
    transform: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
