* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #02040a;
  color: #0a1018;
  font-family: "Segoe UI", "Share Tech Mono", Consolas, monospace;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#arena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#music-match,
#music-duel {
  display: none;
}

#hud {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  pointer-events: none;
  z-index: 4;
}

.hud-capsule {
  background: linear-gradient(180deg, #f4f7fb 0%, #d9e0ea 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 0 0 1px rgba(10, 16, 28, 0.35),
    0 8px 22px rgba(0, 0, 0, 0.45);
  color: #0b1220;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  padding: 10px 22px;
  border-radius: 999px;
  white-space: nowrap;
}

#hud-time {
  position: absolute;
  right: 28px;
  top: 0;
}

#hud-stem {
  position: absolute;
  top: 52px;
  left: 50%;
  width: 2px;
  height: 46px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(220, 240, 255, 0.55), rgba(220, 240, 255, 0));
  pointer-events: none;
  z-index: 3;
}

#hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(210, 240, 255, 0.42);
  font-size: 11px;
  letter-spacing: 0.28em;
  pointer-events: none;
  z-index: 4;
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 4, 10, 0.62);
  z-index: 8;
}

#overlay.hidden {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 36px 48px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 0%, rgba(80, 140, 180, 0.18), rgba(8, 12, 20, 0.92));
  border: 1px solid rgba(180, 230, 255, 0.28);
  box-shadow: 0 0 40px rgba(80, 200, 255, 0.12);
}

.overlay-card h1 {
  color: #e8f6ff;
  letter-spacing: 0.34em;
  font-size: 28px;
  margin-bottom: 12px;
}

.overlay-card p {
  color: rgba(210, 230, 245, 0.7);
  letter-spacing: 0.12em;
  margin-bottom: 22px;
}

#btn-start {
  appearance: none;
  border: 1px solid rgba(180, 240, 255, 0.45);
  background: linear-gradient(180deg, #d8fbff, #7ed4e8);
  color: #071018;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.28em;
  padding: 10px 28px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
}

#btn-start:hover {
  filter: brightness(1.08);
}

#btn-install {
  display: none;
  appearance: none;
  margin-top: 12px;
  border: 1px solid rgba(180, 240, 255, 0.35);
  background: rgba(8, 16, 24, 0.72);
  color: #d8f6ff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.2em;
  padding: 10px 22px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
}

#btn-install.hidden,
#pwa-help.hidden {
  display: none;
}

#pwa-help {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(210, 230, 245, 0.78);
}

#banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #e8f6ff;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.42em;
  text-shadow: 0 0 24px rgba(140, 230, 255, 0.7);
  pointer-events: none;
  z-index: 7;
}

#banner.hidden {
  display: none;
}

body[data-biome="field"] #hint,
body[data-biome="water"] #hint,
body[data-biome="ice"] #hint {
  color: rgba(12, 36, 56, 0.55);
}

body[data-biome="fire"] #hint {
  color: rgba(255, 214, 190, 0.62);
}

body[data-biome="field"] #banner,
body[data-biome="water"] #banner,
body[data-biome="ice"] #banner {
  color: #102030;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.55);
}

@media (max-width: 760px), (max-height: 560px) {
  #hud {
    top: max(8px, env(safe-area-inset-top));
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
  }

  .hud-capsule {
    font-size: 10px;
    letter-spacing: 0.06em;
    padding: 8px 12px;
    max-width: calc(100vw - 20px);
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  #hud-time {
    position: static;
    right: auto;
  }

  #hud-stem {
    display: none;
  }

  #hint {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
    transform: none;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-align: center;
    white-space: normal;
    line-height: 1.45;
  }

  .overlay-card {
    margin: 16px;
    padding: 24px 18px;
    max-width: calc(100vw - 28px);
  }

  .overlay-card h1 {
    font-size: 20px;
    letter-spacing: 0.16em;
  }

  .overlay-card p {
    font-size: 13px;
    letter-spacing: 0.04em;
    margin-bottom: 18px;
  }

  #btn-start,
  #btn-install {
    width: 100%;
    max-width: 260px;
    letter-spacing: 0.16em;
    padding: 12px 20px;
  }

  #btn-install:not(.hidden) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #banner {
    font-size: 26px;
    letter-spacing: 0.16em;
  }
}
