:root {
  color-scheme: dark;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  background: #101820;
  color: #f7fbff;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #0b1218;
}

.shell {
  position: relative;
  width: min(100%, 1280px);
}

.mobile-fullscreen,
.mobile-controls {
  display: none;
}

[hidden] {
  display: none !important;
}

.hud {
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hud > div,
button,
.controls {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.hud > div {
  padding: 10px 12px;
}

.label {
  display: block;
  color: #9db0bf;
  font-size: 12px;
}

strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.rage-panel {
  min-height: 54px;
}

.rage-meter {
  height: 16px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.rage-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffbc2e, #ffe66d);
  box-shadow: 0 0 14px rgba(255, 216, 74, 0.5);
}

button {
  color: #f7fbff;
  min-height: 54px;
  padding: 0 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: rgba(255, 255, 255, 0.14);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #000000;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  touch-action: manipulation;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  padding: 12px;
  color: #c8d6df;
  font-size: 14px;
}

@media (max-width: 700px) {
  body {
    padding: 10px;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud button {
    grid-column: 1 / -1;
  }

  strong {
    font-size: 20px;
  }
}

@media (pointer: coarse) and (max-width: 1024px) {
  body {
    overscroll-behavior: none;
  }

  .mobile-fullscreen {
    position: absolute;
    z-index: 20;
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    display: grid;
    place-items: center;
    width: 48px;
    min-height: 48px;
    padding: 0;
    border: 2px solid rgba(255, 220, 150, 0.75);
    border-radius: 12px;
    color: #ffe1a0;
    background: rgba(46, 24, 12, 0.86);
    font-size: 27px;
    line-height: 1;
    touch-action: manipulation;
  }

  .mobile-controls {
    position: absolute;
    z-index: 18;
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    display: flex;
    align-items: end;
    justify-content: space-between;
    pointer-events: none;
  }

  .mobile-control {
    width: 76px;
    min-height: 76px;
    padding: 0;
    border: 3px solid rgba(255, 224, 165, 0.82);
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(#9a552b, #54240f);
    box-shadow: 0 7px 0 #271006, 0 10px 22px rgba(0, 0, 0, 0.42);
    font: 900 13px Georgia, serif;
    text-shadow: 0 2px 2px #2a0e05;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }

  .mobile-fury {
    width: 68px;
    min-height: 68px;
    margin-bottom: 4px;
    border-color: rgba(255, 98, 79, 0.9);
    background: linear-gradient(#b82f24, #59150f);
  }

  .mobile-control.is-pressed {
    transform: translateY(6px);
    box-shadow: 0 2px 0 #271006, 0 5px 12px rgba(0, 0, 0, 0.38);
  }

  .shell:fullscreen,
  .shell.mobile-expanded {
    position: fixed;
    z-index: 9999;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    display: grid;
    place-items: center;
    background: #000000;
  }

  .shell:fullscreen canvas,
  .shell.mobile-expanded canvas {
    width: min(100vw, calc(100dvh * 16 / 9));
    max-height: 100dvh;
    border-radius: 0;
  }
}
