:root {
  color-scheme: dark;
  --ink: #f9fbff;
  --muted: #a9b6c7;
  --panel: rgba(12, 18, 26, 0.76);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #35d6a0;
  --danger: #ff5f5f;
  --gold: #ffd35c;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #070c12;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  touch-action: none;
}

button {
  border: 0;
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #070c12;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 44%, rgba(53, 214, 160, 0.18), transparent 34%),
    linear-gradient(180deg, #071018 0%, #04070b 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.preloader-card {
  width: min(520px, 78vw, 78vh);
  display: grid;
  justify-items: center;
  gap: 14px;
}

.preloader-logo {
  width: min(360px, 58vw, 48vh);
  height: auto;
  display: block;
  border-radius: 18px;
  filter: drop-shadow(0 20px 46px rgba(0, 0, 0, 0.58));
}

.preloader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.preloader-track {
  width: min(320px, 62vw);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.preloader-track span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35d6a0, #ffd35c);
  animation: preloader-sweep 1100ms ease-in-out infinite;
}

body.preload-done .preloader {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader[hidden] {
  display: none !important;
}

body.is-preloading .top-hud,
body.is-preloading .status-panel,
body.is-preloading .control-row {
  opacity: 0;
}

@keyframes preloader-sweep {
  0% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(260%);
  }
}

.top-hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand-block,
.stat-strip,
.status-panel,
.control-row {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.28);
}

.brand-block {
  min-width: 148px;
  padding: 10px 12px;
  border-radius: 8px;
}

.brand-block p {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.05;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, 1fr));
  gap: 1px;
  width: min(330px, 56vw);
  border-radius: 8px;
  overflow: hidden;
}

.stat-strip div {
  min-width: 0;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.035);
}

.stat-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.stat-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
}

.status-panel {
  position: absolute;
  left: 50%;
  bottom: calc(102px + env(safe-area-inset-bottom));
  width: min(340px, calc(100vw - 28px));
  transform: translateX(-50%);
  padding: 11px 14px;
  border-radius: 8px;
  text-align: center;
  pointer-events: none;
}

.status-panel p {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
}

.status-panel span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.control-row {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 52px minmax(112px, 148px) 52px 52px;
  gap: 8px;
  width: min(340px, calc(100vw - 28px));
  padding: 8px;
  border-radius: 8px;
}

.icon-button,
.primary-button {
  height: 52px;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
}

.icon-button span {
  font-size: 28px;
  line-height: 1;
}

.primary-button {
  background: var(--accent);
  color: #071018;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.icon-button:active,
.primary-button:active {
  transform: translateY(1px);
}

body.fire-tv-capture .status-panel,
body.fire-tv-capture .control-row {
  display: none;
}

@media (min-aspect-ratio: 4 / 3) {
  .game-shell {
    background:
      linear-gradient(
        90deg,
        rgba(5, 9, 14, 0.86) 0%,
        rgba(5, 9, 14, 0.26) 31%,
        rgba(5, 9, 14, 0.18) 50%,
        rgba(5, 9, 14, 0.26) 69%,
        rgba(5, 9, 14, 0.86) 100%
      ),
      url("assets/fire-tv/tv-side-backdrop-1920x1080.png") center / cover no-repeat #070c12;
  }
}

@media (max-width: 560px) {
  .top-hud {
    align-items: stretch;
  }

  .brand-block {
    min-width: 118px;
  }

  .brand-block h1 {
    font-size: 16px;
  }

  .stat-strip {
    width: min(220px, 58vw);
  }

  .stat-strip div {
    padding: 8px 7px;
  }

  .stat-strip strong {
    font-size: 16px;
  }
}

@media (max-height: 650px) {
  .status-panel {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .control-row {
    grid-template-columns: 46px minmax(102px, 1fr) 46px 46px;
  }

  .icon-button,
  .primary-button {
    height: 46px;
  }
}
