:root {
  color-scheme: light;
  --hud-bg: rgba(255, 255, 255, 0.24);
  --hud-border: rgba(255, 255, 255, 0.48);
  --hud-shadow: rgba(37, 110, 170, 0.22);
  --text: #17344d;
  --muted: rgba(23, 52, 77, 0.64);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: var(--hexwing-app-height, 100dvh);
  min-height: var(--hexwing-app-height, 100dvh);
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #7fd0ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: var(--hexwing-app-height, 100dvh);
}

.game-shell {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: var(--hexwing-app-height, 100dvh);
  overflow: hidden;
  background: #7fd0ff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  contain: strict;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  contain: strict;
  transform: translateZ(0);
}



.guide-button {
  position: absolute;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 5;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: rgba(21, 55, 86, 0.78);
  font: 900 18px/1 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(37, 110, 170, 0.16), inset 0 1px 0 rgba(255,255,255,0.45);
  transform: translateX(-50%);
  opacity: 0.72;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.guide-button:active {
  transform: translateX(-50%) scale(0.95);
  opacity: 0.95;
}

.kick-button {
  position: absolute;
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 4;
  display: none;
  width: clamp(72px, 13vw, 104px);
  height: clamp(54px, 10vw, 72px);
  place-items: center;
  color: #fff7f5;
  font: 900 clamp(15px, 2.2vw, 20px)/1 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(107, 8, 19, 0.42);
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 32%),
    linear-gradient(145deg, rgba(255, 107, 94, 0.94), rgba(201, 24, 42, 0.94));
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 22px;
  box-shadow: 0 14px 32px rgba(126, 17, 33, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.48);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.kick-button:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: 0 8px 22px rgba(126, 17, 33, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.mobile-tap-hint {
  position: absolute;
  left: calc(14px + env(safe-area-inset-left));
  bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--hexwing-browser-bottom-inset, 0px));
  z-index: 4;
  display: none;
  max-width: min(38vw, 230px);
  padding: 6px 9px;
  color: rgba(21, 55, 86, 0.58);
  font: 850 10px/1.05 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-align: left;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(37, 110, 170, 0.10), inset 0 1px 0 rgba(255,255,255,0.22);
  opacity: 0.72;
  pointer-events: none;
  backdrop-filter: blur(6px) saturate(1.08);
  -webkit-backdrop-filter: blur(6px) saturate(1.08);
}

.hud {
  position: absolute;
  inset: env(safe-area-inset-top) env(safe-area-inset-right) auto env(safe-area-inset-left);
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: clamp(8px, 1.5vw, 14px);
  padding: clamp(10px, 2vw, 18px);
  pointer-events: none;
  contain: layout paint style;
}

.hud-card {
  display: grid;
  gap: 2px;
  min-height: 44px;
  padding: 10px 13px;
  color: var(--text);
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  box-shadow: 0 14px 34px var(--hud-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(16px) saturate(1.22);
  -webkit-backdrop-filter: blur(16px) saturate(1.22);
  contain: paint;
}

.hud-card strong {
  font-size: clamp(14px, 1.8vw, 19px);
  line-height: 1;
  letter-spacing: 0.02em;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.help-card {
  align-self: stretch;
  display: flex;
  align-items: center;
  margin-left: auto;
  flex: 0 1 auto;
  font-size: clamp(11px, 1.25vw, 13px);
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.mobile-help {
  display: none;
}


.daily-button {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  top: calc(max(18px, env(safe-area-inset-top)) + 46px);
  z-index: 7;
  min-width: 74px;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,0.88), rgba(204,238,255,0.74));
  color: #153d67;
  font: 900 12px/1 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(32, 94, 158, 0.20), inset 0 1px 0 rgba(255,255,255,0.78);
  cursor: pointer;
}

.daily-button:active {
  transform: translateY(1px) scale(0.98);
}

.mode-card strong,
.mission-card strong {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-card {
  flex: 1 1 230px;
}

@media (max-width: 680px), (orientation: portrait) {
  .hud {
    justify-content: space-between;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left));
  }

  .hud-card {
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 15px;
  }

  .title-card {
    display: none;
  }

  .help-card {
    flex-basis: auto;
    max-width: none;
    margin-left: 0;
    font-size: 11px;
    white-space: normal;
    text-align: right;
  }

  .desktop-help {
    display: none;
  }

  .mobile-help {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  #gameCanvas {
    cursor: default;
  }
}


.orientation-lock {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  place-items: center;
  padding: calc(20px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  color: var(--text);
  text-align: center;
  pointer-events: auto;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.20) 36%, rgba(108, 191, 255, 0.42) 100%),
    linear-gradient(180deg, rgba(112, 201, 255, 0.92), rgba(238, 249, 255, 0.94));
  backdrop-filter: blur(12px) saturate(1.18);
  -webkit-backdrop-filter: blur(12px) saturate(1.18);
}

.rotate-card {
  width: min(86vw, 420px);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px 22px 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.48);
  box-shadow: 0 24px 60px rgba(37, 110, 170, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rotate-card strong {
  font-size: clamp(24px, 8vw, 38px);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.rotate-card p {
  max-width: 31ch;
  margin: 0;
  color: rgba(23, 52, 77, 0.72);
  font-size: clamp(14px, 4vw, 17px);
  font-weight: 700;
  line-height: 1.35;
}

.rotate-icon {
  position: relative;
  width: 112px;
  height: 92px;
  margin-bottom: 2px;
}

.phone-shape {
  position: absolute;
  left: 34px;
  top: 11px;
  width: 44px;
  height: 70px;
  border: 5px solid rgba(23, 52, 77, 0.84);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.90), rgba(157, 225, 255, 0.72));
  box-shadow: 0 12px 24px rgba(37, 110, 170, 0.18);
  animation: phoneRotateHint 2.2s ease-in-out infinite;
  transform-origin: 50% 50%;
}

.phone-shape::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 9px;
  height: 3px;
  border-radius: 999px;
  background: rgba(23, 52, 77, 0.54);
  transform: translateX(-50%);
}

.rotate-arrow {
  position: absolute;
  inset: 5px 3px 0;
  border: 5px solid rgba(255, 255, 255, 0.78);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  transform: rotate(18deg);
}

.rotate-arrow::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 10px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid rgba(255, 255, 255, 0.78);
  transform: rotate(43deg);
}

@keyframes phoneRotateHint {
  0%, 22% {
    transform: rotate(0deg) scale(1);
  }

  58%, 100% {
    transform: rotate(90deg) scale(1.03);
  }
}

@media (hover: none) and (pointer: coarse) {
  .guide-button {
    top: calc(8px + env(safe-area-inset-top));
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .kick-button {
    display: grid;
  }

  .desktop-help {
    display: none;
  }

  .mobile-help {
    display: inline;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .kick-button {
    right: calc(14px + env(safe-area-inset-right));
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--hexwing-browser-bottom-inset, 0px));
  }

  .mobile-tap-hint {
    display: block;
  }

  .hud {
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left));
  }

  .title-card {
    display: none;
  }

  .hud-card {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 14px;
  }

  .hud-card strong {
    font-size: 14px;
  }

  .eyebrow {
    font-size: 9px;
    letter-spacing: 0.13em;
  }

  .help-card {
    max-width: 44vw;
    margin-left: auto;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
    text-align: right;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  :root {
    --hexwing-control-lift: 52px;
  }

  .orientation-lock {
    display: grid;
  }

  .mobile-tap-hint {
    display: none;
  }

  #gameCanvas {
    filter: none;
  }

  .guide-button {
    left: calc(12px + env(safe-area-inset-left));
    top: calc(8px + env(safe-area-inset-top));
    width: 32px;
    height: 32px;
    transform: none;
    opacity: 0.74;
  }

  .guide-button:active {
    transform: scale(0.95);
  }

  .daily-button {
    right: calc(10px + env(safe-area-inset-right));
    top: calc(8px + env(safe-area-inset-top));
    min-width: 64px;
    min-height: 30px;
    font-size: 10.5px;
    letter-spacing: 0.025em;
    opacity: 0.86;
  }

  .kick-button {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--hexwing-browser-bottom-inset, 0px) + var(--hexwing-control-lift, 52px));
    width: clamp(82px, 22vw, 106px);
    height: clamp(52px, 14vw, 68px);
    border-radius: 18px;
    font-size: clamp(15px, 4vw, 19px);
  }

  .hud {
    justify-content: center;
    gap: 5px;
    padding: calc(7px + env(safe-area-inset-top)) calc(72px + env(safe-area-inset-right)) 0 calc(72px + env(safe-area-inset-left));
  }

  .hud-card {
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 13px;
    background: rgba(255,255,255,0.20);
    box-shadow: 0 8px 18px rgba(37, 110, 170, 0.12), inset 0 1px 0 rgba(255,255,255,0.32);
  }

  .hud-card strong {
    font-size: 13px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 0.11em;
  }

  .title-card,
  .help-card,
  .mode-card,
  .mission-card,
  .deflect-card,
  .gate-card,
  .state-card,
  .core-card {
    display: none;
  }

  .score-card {
    flex: 0 0 auto;
  }
}


/* Firefox is more sensitive to backdrop-filter and large soft shadows on top of a busy canvas. */
@-moz-document url-prefix() {
  .hud-card {
    background: rgba(255, 255, 255, 0.34);
    box-shadow: 0 8px 22px rgba(37, 110, 170, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.42);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .orientation-lock {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}


body.firefox-canvas .hud-card {
  background: rgba(255, 255, 255, 0.34);
  box-shadow: 0 8px 22px rgba(37, 110, 170, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.42);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.firefox-canvas .orientation-lock {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.firefox-canvas #gameCanvas {
  filter: none !important;
}

body.firefox-canvas .rotate-card {
  box-shadow: 0 14px 34px rgba(37, 110, 170, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
