:root {
  color-scheme: dark;
  --bg: #071b1d;
  --panel: #0c1020;
  --cyan: #b7a7ff;
  --cyan-soft: rgba(183, 167, 255, 0.18);
  --text: #eef8ff;
  --muted: #6f7e96;
  --danger: #ff6fae;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background:
    radial-gradient(ellipse at 50% -8%, rgba(40, 151, 143, 0.22), transparent 38rem),
    linear-gradient(180deg, #0a2829 0%, #071b1d 38%, #061719 100%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 4px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  position: relative;
  display: block;
  width: 34px;
  height: 34px;
  transform: rotate(45deg);
  border: 1px solid rgba(183, 167, 255, 0.46);
  background: rgba(183, 167, 255, 0.04);
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  content: "";
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(183, 167, 255, 0.7);
}

.brand-mark::before {
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 1px;
}

.brand-mark::after {
  top: 50%;
  right: 8px;
  left: 8px;
  height: 1px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--cyan);
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
}

.brand h1 {
  margin: 1px 0 0;
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0.12em;
}

.controls-hint {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #8794a9;
  font-size: 11px;
  letter-spacing: 0.05em;
}

kbd {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px 2px;
  border: 1px solid #283248;
  border-bottom-color: #43516b;
  border-radius: 4px;
  color: #b8c6d9;
  font-family: inherit;
  font-size: 10px;
  background: #101523;
  box-shadow: 0 1px 0 #03050a;
}

.hint-divider {
  width: 1px;
  height: 18px;
  background: #252b3a;
}

.game-frame {
  position: relative;
  height: clamp(410px, 66vh, 650px);
  overflow: hidden;
  border: 1px solid #1b2538;
  background: #040a11;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38), inset 0 0 80px rgba(0, 0, 0, 0.3);
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

.corner {
  position: absolute;
  width: 19px;
  height: 19px;
  pointer-events: none;
  border-color: rgba(183, 167, 255, 0.52);
}

.corner-tl { top: 7px; left: 7px; border-top: 1px solid; border-left: 1px solid; }
.corner-tr { top: 7px; right: 7px; border-top: 1px solid; border-right: 1px solid; }
.corner-bl { bottom: 7px; left: 7px; border-bottom: 1px solid; border-left: 1px solid; }
.corner-br { right: 7px; bottom: 7px; border-right: 1px solid; border-bottom: 1px solid; }

.status-pill {
  position: absolute;
  top: 18px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(111, 126, 150, 0.18);
  border-radius: 2px;
  color: #8592a6;
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 10px;
  letter-spacing: 0.19em;
  background: rgba(8, 12, 23, 0.62);
  backdrop-filter: blur(5px);
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #667085;
}

.status-pill.active {
  color: #ddd6ff;
  border-color: rgba(183, 167, 255, 0.2);
}

.status-pill.active .status-dot {
  background: var(--cyan);
  box-shadow: 0 0 9px var(--cyan);
  animation: pulse 1.2s ease-in-out infinite;
}

.sound-button {
  position: absolute;
  top: 17px;
  right: 18px;
  display: grid;
  width: 32px;
  height: 32px;
  padding: 7px;
  border: 1px solid rgba(111, 126, 150, 0.2);
  border-radius: 2px;
  color: #8794a9;
  background: rgba(8, 12, 23, 0.62);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

.sound-button:hover {
  color: var(--cyan);
  border-color: rgba(183, 167, 255, 0.35);
}

.sound-button svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.sound-button .sound-off,
.sound-button.muted .sound-on {
  display: none;
}

.sound-button.muted .sound-off {
  display: block;
}

.joystick-wrap {
  position: absolute;
  z-index: 4;
  bottom: 20px;
  left: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.62;
  transition: opacity 160ms ease;
  user-select: none;
  -webkit-user-select: none;
}

.joystick-wrap:hover,
.joystick-wrap:focus-within,
.joystick-wrap.active {
  opacity: 1;
}

.joystick-label {
  color: rgba(129, 217, 232, 0.62);
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 8px;
  letter-spacing: 0.24em;
  pointer-events: none;
}

.virtual-joystick {
  position: relative;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(183, 167, 255, 0.26);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(183, 167, 255, 0.08) 0 22%, transparent 23%),
    rgba(5, 11, 20, 0.56);
  box-shadow:
    inset 0 0 22px rgba(183, 167, 255, 0.04),
    0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: grab;
  touch-action: none;
  backdrop-filter: blur(5px);
}

.virtual-joystick:active {
  cursor: grabbing;
}

.virtual-joystick::before,
.virtual-joystick::after {
  position: absolute;
  content: "";
  width: 4px;
  height: 4px;
  border-color: rgba(183, 167, 255, 0.5);
  transform: rotate(45deg);
}

.virtual-joystick::before {
  top: 7px;
  left: 7px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.virtual-joystick::after {
  right: 7px;
  bottom: 7px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.joystick-axis {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  background: rgba(183, 167, 255, 0.12);
  pointer-events: none;
}

.axis-x {
  width: 54px;
  height: 1px;
  transform: translate(-50%, -50%);
}

.axis-y {
  width: 1px;
  height: 54px;
  transform: translate(-50%, -50%);
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 31px;
  height: 31px;
  border: 1px solid rgba(130, 241, 255, 0.82);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(183, 167, 255, 0.13);
  box-shadow:
    0 0 15px rgba(183, 167, 255, 0.15),
    inset 0 0 9px rgba(183, 167, 255, 0.1);
  pointer-events: none;
  will-change: transform;
}

.joystick-knob::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.start-panel,
.game-over-panel,
.pause-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(90%, 430px);
  transform: translate(-50%, -50%);
  text-align: center;
}

.start-panel,
.game-over-panel {
  animation: reveal 500ms ease both;
}

.game-over-panel,
.pause-panel {
  padding: 38px 30px;
  border: 1px solid rgba(122, 145, 176, 0.17);
  background: rgba(7, 10, 20, 0.84);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(11px);
}

[hidden] {
  display: none !important;
}

.ship-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  margin-bottom: 17px;
}

.ship-emblem svg {
  z-index: 1;
  width: 62px;
  height: 62px;
  overflow: visible;
  fill: rgba(183, 167, 255, 0.1);
  stroke: var(--cyan);
  stroke-width: 1.2px;
  filter: drop-shadow(0 0 9px rgba(183, 167, 255, 0.5));
}

.ship-emblem .emblem-core {
  fill: rgba(183, 167, 255, 0.34);
  stroke-width: 0.6px;
}

.emblem-ring {
  position: absolute;
  border: 1px solid rgba(183, 167, 255, 0.16);
  border-radius: 50%;
}

.ring-one {
  inset: 6px;
  border-top-color: rgba(183, 167, 255, 0.7);
  border-bottom-color: rgba(183, 167, 255, 0.44);
  animation: spin 8s linear infinite;
}

.ring-two {
  inset: 18px;
  border-right-color: rgba(183, 167, 255, 0.64);
  animation: spin 5s linear infinite reverse;
}

.panel-kicker {
  margin-bottom: 8px;
}

.panel-kicker.danger {
  color: var(--danger);
}

.start-panel h2,
.game-over-panel h2,
.pause-panel h2 {
  margin: 0;
  font-size: clamp(27px, 4vw, 38px);
  line-height: 1.3;
  letter-spacing: -0.045em;
}

.panel-copy {
  margin: 12px 0 25px;
  color: #8090a8;
  font-size: 13px;
  line-height: 1.85;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 45px;
  min-width: 196px;
  height: 52px;
  padding: 0 17px 0 24px;
  border: 1px solid var(--cyan);
  color: #061017;
  font-size: 14px;
  font-weight: 700;
  background: var(--cyan);
  box-shadow: 0 0 0 rgba(183, 167, 255, 0), inset 0 0 0 1px rgba(255,255,255,.2);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: #d4cbff;
  box-shadow: 0 9px 30px rgba(183, 167, 255, 0.21);
}

.primary-button:active {
  transform: translateY(0);
}

.game-over-actions {
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.game-over-actions .primary-button {
  min-width: 170px;
  gap: 25px;
}

.secondary-button {
  min-width: 104px;
  height: 52px;
  padding: 0 17px;
  border: 1px solid #2d3a50;
  color: #a3b0c3;
  font-size: 13px;
  font-weight: 600;
  background: rgba(13, 19, 32, 0.9);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.secondary-button:hover {
  color: #e5f8ff;
  border-color: #57677f;
  background: rgba(23, 31, 48, 0.96);
}

.button-arrow {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.mobile-tip {
  display: none;
  margin: 15px 0 0;
  color: #5f6b80;
  font-size: 10px;
}

.result-time {
  display: flex;
  flex-direction: column;
  margin: 18px 0 6px;
}

.result-time span {
  color: var(--cyan);
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-shadow: 0 0 25px rgba(183, 167, 255, 0.25);
}

.result-time small {
  color: #657187;
  font-size: 10px;
  letter-spacing: 0.16em;
}

.record-message {
  margin: 11px 0 23px;
  color: #8290a5;
  font-size: 12px;
}

.pause-panel p:last-child {
  margin: 15px 0 0;
  color: #8290a5;
  font-size: 12px;
}

.hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  min-height: 92px;
  border: 1px solid #1a2232;
  border-top: 0;
  background: linear-gradient(180deg, rgba(12, 16, 30, 0.94), rgba(7, 10, 19, 0.98));
}

.metric {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 15px 28px;
}

.time-metric {
  justify-content: flex-end;
  text-align: right;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(183, 167, 255, 0.16);
  border-radius: 50%;
  background: rgba(183, 167, 255, 0.035);
}

.bullet-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.bullet-icon span {
  width: 3px;
  height: 12px;
  border-radius: 3px;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(183, 167, 255, 0.5);
}

.bullet-icon span:nth-child(2) { height: 17px; }

.clock-icon span {
  position: relative;
  width: 17px;
  height: 17px;
  border: 1px solid var(--cyan);
  border-radius: 50%;
}

.clock-icon span::before,
.clock-icon span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "";
  width: 1px;
  height: 6px;
  transform-origin: top;
  background: var(--cyan);
}

.clock-icon span::before { transform: rotate(180deg); }
.clock-icon span::after { height: 5px; transform: rotate(130deg); }

.metric-copy p {
  margin: 0 0 1px;
  color: #69758a;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.13em;
}

.metric-copy strong {
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.09em;
  font-variant-numeric: tabular-nums;
}

.metric-copy small {
  color: #68758a;
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
}

.hud-center {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-center span {
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #2a3346);
}

.hud-center span:last-child {
  transform: rotate(180deg);
}

.hud-center i {
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  border: 1px solid #3a4961;
}

.footer-note {
  margin: 10px 3px 0;
  color: #454e61;
  font-family: "Arial Narrow", "Roboto Condensed", sans-serif;
  font-size: 10px;
  letter-spacing: 0.17em;
  text-align: right;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  50% { opacity: 0.38; }
}

@keyframes reveal {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 680px) {
  .app-shell {
    width: calc(100% - 18px);
    padding-top: 12px;
  }

  .topbar {
    min-height: 55px;
    padding-bottom: 10px;
  }

  .brand-mark {
    width: 27px;
    height: 27px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .controls-hint {
    display: none;
  }

  .game-frame {
    height: min(68vh, 610px);
    min-height: 430px;
  }

  .ship-emblem {
    width: 94px;
    height: 94px;
    margin-bottom: 11px;
  }

  .panel-copy {
    margin: 9px 0 19px;
  }

  .mobile-tip {
    display: block;
  }

  .joystick-wrap {
    bottom: 15px;
    left: 15px;
    opacity: 0.82;
  }

  .virtual-joystick {
    width: 72px;
    height: 72px;
  }

  .hud {
    min-height: 78px;
  }

  .metric {
    gap: 10px;
    padding: 11px 10px;
  }

  .metric-icon {
    width: 32px;
    height: 32px;
  }

  .metric-copy strong {
    font-size: 22px;
    white-space: nowrap;
  }

  .metric-copy p {
    letter-spacing: 0.05em;
    white-space: nowrap;
  }

  .hud-center span {
    width: 10px;
  }

  .game-over-panel {
    padding-right: 20px;
    padding-left: 20px;
  }

  .game-over-actions {
    width: 100%;
  }

  .game-over-actions .primary-button,
  .game-over-actions .secondary-button {
    min-width: 0;
  }

  .game-over-actions .primary-button {
    flex: 1.4;
  }

  .game-over-actions .secondary-button {
    flex: 1;
  }
}

@media (max-height: 650px) and (min-width: 681px) {
  .app-shell { padding-top: 14px; }
  .topbar { min-height: 48px; padding-bottom: 10px; }
  .game-frame { height: 70vh; min-height: 390px; }
  .ship-emblem { width: 90px; height: 90px; margin-bottom: 8px; }
  .panel-copy { margin: 8px 0 16px; }
  .hud { min-height: 74px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
