:root {
  color-scheme: dark;
  font-family: "Inter", "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #101418;
  color: #f4f1e9;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  touch-action: none;
  user-select: none;
}

#app {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(255, 186, 118, 0.16), rgba(16, 20, 24, 0) 36%),
    #101418;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.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));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.metric {
  min-width: clamp(72px, 14vw, 132px);
  height: 54px;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 0 14px;
  border: 1px solid rgba(244, 241, 233, 0.14);
  border-radius: 8px;
  background: rgba(16, 20, 24, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.metric span {
  color: rgba(244, 241, 233, 0.68);
  font-size: 12px;
  line-height: 1;
}

.metric strong {
  color: #fff8e6;
  font-size: 20px;
  line-height: 1.05;
  font-weight: 780;
  letter-spacing: 0;
}

.icon-button {
  margin-left: auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 241, 233, 0.18);
  border-radius: 50%;
  color: #f4f1e9;
  background: rgba(16, 20, 24, 0.72);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
  cursor: pointer;
  pointer-events: auto;
  font-size: 25px;
  line-height: 1;
}

.icon-button:focus-visible,
.round-control:focus-visible,
.start-layer button:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 3px;
}

.wire-panel {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.wire-chip {
  width: 58px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid rgba(244, 241, 233, 0.12);
  background: rgba(16, 20, 24, 0.7);
  backdrop-filter: blur(10px);
}

.wire-chip span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(244, 241, 233, 0.26);
  box-shadow: 0 0 0 rgba(255, 255, 255, 0);
}

.wire-chip strong {
  font-size: 15px;
  color: rgba(244, 241, 233, 0.78);
}

.wire-chip.attached.left span {
  background: #4fd3c4;
  box-shadow: 0 0 18px rgba(79, 211, 196, 0.9);
}

.wire-chip.attached.right span {
  background: #ff7f66;
  box-shadow: 0 0 18px rgba(255, 127, 102, 0.9);
}

.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.crosshair::before,
.crosshair::after,
.crosshair span::before,
.crosshair span::after {
  content: "";
  position: absolute;
  background: rgba(255, 248, 230, 0.82);
  box-shadow: 0 0 10px rgba(255, 224, 138, 0.48);
}

.crosshair::before,
.crosshair::after {
  left: 50%;
  width: 2px;
  height: 10px;
  transform: translateX(-50%);
}

.crosshair::before {
  top: 0;
}

.crosshair::after {
  bottom: 0;
}

.crosshair span::before,
.crosshair span::after {
  top: 50%;
  width: 10px;
  height: 2px;
  transform: translateY(-50%);
}

.crosshair span::before {
  left: 0;
}

.crosshair span::after {
  right: 0;
}

.touchbar {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.round-control {
  width: clamp(58px, 11vw, 76px);
  height: clamp(58px, 11vw, 76px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #101418;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  touch-action: none;
}

.round-control span {
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 850;
  line-height: 1;
}

.round-control.left {
  background: linear-gradient(180deg, #a8fff4, #36bbae);
}

.round-control.right {
  background: linear-gradient(180deg, #ffc1ad, #ef644f);
}

.round-control.boost {
  width: clamp(50px, 9vw, 64px);
  height: clamp(50px, 9vw, 64px);
  margin-bottom: 6px;
  background: linear-gradient(180deg, #ffe08a, #d39b24);
}

.round-control:active {
  transform: translateY(2px) scale(0.98);
}

.start-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.start-layer.hidden {
  display: none;
}

.start-layer button {
  min-width: 118px;
  height: 52px;
  padding: 0 28px;
  border: 1px solid rgba(255, 224, 138, 0.42);
  border-radius: 8px;
  background: rgba(255, 224, 138, 0.92);
  color: #101418;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  font-size: 18px;
  font-weight: 850;
  pointer-events: auto;
}

@media (max-width: 720px) {
  .hud {
    gap: 6px;
  }

  .metric {
    min-width: 62px;
    height: 46px;
    padding: 0 9px;
  }

  .metric span {
    font-size: 10px;
  }

  .metric strong {
    font-size: 16px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    font-size: 23px;
  }

  .wire-panel {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 76px);
  }
}
