:root {
  color-scheme: dark;
  --bg: #0b0e11;
  --stage: #14181c;
  --text: #e8edf2;
  --muted: #8b97a3;
  --line: #262d34;
  --p1: #e5484d;
  --p2: #5cd96b;
  --footer-height: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
}

/* 16:9 stage that fits the window above the footer. */
#stage {
  position: relative;
  width: min(100%, calc((100vh - var(--footer-height) - 42px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: var(--stage);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  /* Touches drive the tanks: no scrolling, zooming, text selection or long-press menus over the game. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stage:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--stage);
  outline: none;
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--stage);
}

#loader[hidden], #start[hidden], #install-bar[hidden], #install[hidden], #ios-hint[hidden], #update[hidden] { display: none; }

/* A newer build is ready: a small button over the top of the game, until it's tapped. */
#update {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 7px 16px;
  border: 1px solid var(--p2);
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.92);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
}

#update:hover { background: #1f262d; }
#update:focus-visible { outline: 3px solid var(--p2); outline-offset: 2px; }

/* Offer to install the game, over the bottom of the start screen. */
#install-bar {
  position: absolute;
  left: 50%;
  bottom: clamp(12px, 5%, 32px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  z-index: 1;
}

#install {
  padding: 9px 18px;
  border: 1px solid var(--p2);
  border-radius: 999px;
  background: rgba(20, 24, 28, 0.9);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

#install:hover { background: #1f262d; }
#install:focus-visible { outline: 3px solid var(--p2); outline-offset: 2px; }

#ios-hint {
  margin: 0;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(20, 24, 28, 0.9);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

#ios-hint b { color: var(--text); }

.logo {
  font-size: clamp(28px, 6vw, 64px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--p1);
}

.logo span { color: var(--p2); }

.bar {
  width: min(360px, 60%);
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

#bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  transition: width 0.2s ease-out;
}

#loader-text { color: var(--muted); font-variant-numeric: tabular-nums; }

#start {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(8, 10, 12, 0.55);
  color: var(--text);
  font: inherit;
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#start:focus-visible { outline: 3px solid var(--p2); outline-offset: -6px; }

#banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.banner-line {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(20, 24, 28, 0.92);
  border: 1px solid var(--line);
}

.banner-line.warning { border-color: #c9a227; }
.banner-line.error { border-color: var(--p1); }

#footer {
  width: min(100%, calc((100vh - var(--footer-height) - 42px) * 16 / 9));
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.keys { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.keys b { margin-right: 4px; letter-spacing: 0.04em; }
.p1 { color: var(--p1); }
.p2 { color: var(--p2); }
.p3 { color: #61a0ff; }
.p4 { color: #fad040; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  margin: 0 1px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #171c21;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: center;
}

.footer-buttons { display: flex; flex: none; gap: 8px; }

#fullscreen,
#more-games {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #171c21;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

#fullscreen:hover:not(:disabled),
#more-games:hover { background: #1f262d; }
#fullscreen:disabled { opacity: 0.5; cursor: default; }

#rotate-note {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--stage);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 640px) {
  #app { padding: 16px; justify-content: flex-start; }
  #footer { flex-direction: column; align-items: flex-start; }
}

/* Phones and tablets: the game fills the screen, and its on-screen controls replace the keyboard legend. */
@media (pointer: coarse) {
  #app { padding: 0; gap: 0; }
  #stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  #footer { display: none; }
}

@media (pointer: coarse) and (orientation: portrait) {
  #rotate-note { display: flex; }
}
