* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #1f2228;
  color: #fff8e8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid rgba(131, 226, 255, 0.48);
  background: rgba(34, 45, 57, 0.92);
  color: #fff7e8;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  min-width: 150px;
  border-radius: 6px;
}

button:hover {
  background: rgba(48, 66, 82, 0.98);
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#game-root,
#game-canvas {
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: #1f2228;
  color: #fff7e8;
  font-size: 18px;
  font-weight: 800;
}

body:not(.is-loading) .loading-screen {
  display: none;
}

body.is-loading .screen,
body.is-loading #hud,
body.is-loading #crosshair,
body.is-loading #damage-flash,
body.is-loading #toast {
  visibility: hidden;
  pointer-events: none;
}

#damage-flash {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(255, 34, 28, 0) 38%, rgba(150, 0, 0, 0.58) 100%),
    linear-gradient(rgba(255, 36, 28, 0.18), rgba(86, 0, 0, 0.12));
  mix-blend-mode: multiply;
  transition: opacity 50ms linear;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(84, 70, 50, 0.46), rgba(18, 22, 29, 0.9));
  z-index: 10;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: flex;
}

.panel {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 28px;
  border: 1px solid rgba(131, 226, 255, 0.28);
  background: rgba(27, 31, 38, 0.9);
  box-shadow: 0 0 48px rgba(125, 232, 255, 0.12);
  border-radius: 8px;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel.compact {
  width: min(380px, calc(100vw - 32px));
}

.kicker {
  margin: 0 0 8px;
  color: #83e2ff;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0 0 14px;
  max-width: 100%;
  overflow: hidden;
  line-height: 1.05;
  white-space: nowrap;
}

h1 {
  font-size: clamp(38px, 7vw, 72px);
}

h2 {
  font-size: 34px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
  color: #d9e8ea;
  font-size: 14px;
}

.mode-choice {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.mode-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 128px;
  min-width: 112px;
  min-height: 46px;
  padding: 10px 16px;
  text-align: center;
  white-space: nowrap;
  border-color: rgba(131, 226, 255, 0.42);
  background: rgba(25, 38, 48, 0.92);
}

.mode-card:nth-child(2) {
  border-color: rgba(131, 226, 255, 0.42);
  background: rgba(25, 38, 48, 0.92);
}

.mode-choice .mode-card:hover {
  background: rgba(48, 66, 82, 0.98);
}

.mode-card:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.mode-card strong {
  display: block;
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
}

.gameblocks-credit {
  margin: 18px 0 0;
  color: rgba(217, 232, 234, 0.68);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.gameblocks-credit a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
}

.bar-block {
  width: min(240px, 30vw);
  padding: 9px 10px;
  border: 1px solid rgba(131, 226, 255, 0.24);
  background: rgba(24, 30, 38, 0.74);
  border-radius: 6px;
}

.bar-block span {
  display: block;
  margin-bottom: 6px;
  color: #b9efff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #44ff9f, #ddff66);
}

.bar.heat i {
  background: linear-gradient(90deg, #ff8d68, #ffd166);
}

.readouts {
  margin-left: auto;
  width: max-content;
  max-width: calc(100vw - 32px);
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 189, 104, 0.25);
  background: rgba(24, 30, 38, 0.74);
  border-radius: 6px;
  text-align: right;
}

.readouts strong,
.readouts span {
  display: block;
  white-space: nowrap;
}

.readouts strong {
  color: #ffffff;
}

.readouts span {
  color: #d9e8ea;
  font-size: 13px;
  margin-top: 3px;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  margin-top: -15px;
  z-index: 3;
  pointer-events: none;
  border: 1px solid rgba(232, 200, 134, 0.46);
  border-radius: 50%;
  display: none;
}

#crosshair::before,
#crosshair::after,
#crosshair span::before,
#crosshair span::after {
  content: "";
  position: absolute;
  background: rgba(232, 200, 134, 0.84);
}

#crosshair::before,
#crosshair::after {
  top: 14px;
  width: 9px;
  height: 2px;
}

#crosshair::before {
  left: -5px;
}

#crosshair::after {
  right: -5px;
}

#crosshair span::before,
#crosshair span::after {
  left: 14px;
  width: 2px;
  height: 9px;
}

#crosshair span::before {
  top: -5px;
}

#crosshair span::after {
  bottom: -5px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 38px;
  transform: translateX(-50%);
  z-index: 5;
  color: #fff7e8;
  background: rgba(24, 30, 38, 0.86);
  border: 1px solid rgba(131, 226, 255, 0.34);
  border-radius: 6px;
  padding: 10px 14px;
  opacity: 0;
  transition: opacity 160ms ease;
}

#toast.visible {
  opacity: 1;
}

@media (max-width: 720px) {
  .hud {
    flex-wrap: wrap;
  }

  .bar-block {
    width: calc(50vw - 24px);
    min-width: 0;
  }

  .readouts {
    width: max-content;
    max-width: calc(100vw - 32px);
    text-align: right;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .mode-card {
    width: min(132px, calc(50% - 5px));
    min-height: 44px;
  }
}
