:root {
  color-scheme: light;
  --ink: #18353a;
  --muted-ink: #5b797d;
  --paper: rgba(255, 255, 255, 0.86);
  --line: rgba(255, 255, 255, 0.74);
  --shadow: 0 18px 48px rgba(32, 81, 76, 0.18);
  --accent: #eb8f51;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #65b9d4;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
  overflow: hidden;
  isolation: isolate;
  background: #75c9e1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 4vw, 56px) 0;
  pointer-events: none;
}

.brand-lockup {
  display: grid;
  gap: 2px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(21, 84, 99, 0.18);
}

.brand-mark {
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 850;
  letter-spacing: 0.13em;
}

.brand-subtitle {
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.15em;
  opacity: 0.75;
}

.game-title {
  margin-top: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.creator-credit {
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-panel {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(31, 101, 110, 0.14);
  backdrop-filter: blur(14px);
}

.form-status,
.crystal-status,
.health-status,
.weapon-status {
  min-height: 60px;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 10px 17px;
}

.form-status,
.crystal-status {
  border-right: 1px solid rgba(44, 105, 106, 0.12);
}

.form-status strong {
  font-size: 16px;
  line-height: 1.15;
}

.status-label {
  color: var(--muted-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.crystal-status {
  position: relative;
  grid-template-columns: auto auto;
  column-gap: 7px;
}

.crystal-status .status-label {
  grid-column: 2;
}

.crystal-status strong {
  font-size: 17px;
  line-height: 1.1;
}

.crystal-gem {
  width: 15px;
  height: 20px;
  grid-row: span 2;
  align-self: center;
  clip-path: polygon(50% 0, 93% 33%, 75% 100%, 25% 100%, 7% 33%);
  background: linear-gradient(135deg, #e6fdff 8%, #52d7ef 42%, #6d70e6 100%);
  filter: drop-shadow(0 2px 4px rgba(57, 122, 213, 0.45));
}

.health-status {
  color: #df6b58;
  font-size: 17px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.health-status.life-up {
  animation: life-up 0.8s ease both;
}

.weapon-status {
  min-width: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-left: 1px solid rgba(44, 105, 106, 0.12);
  color: #5a4b79;
  font-size: 17px;
  white-space: nowrap;
}

.weapon-status strong {
  font-size: 12px;
}

.weapon-status[hidden] {
  display: none;
}

.scene-label {
  position: absolute;
  top: 101px;
  left: clamp(18px, 4vw, 56px);
  z-index: 8;
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-shadow: 0 2px 8px rgba(25, 88, 100, 0.18);
  pointer-events: none;
}

.time-status {
  position: absolute;
  top: 126px;
  left: clamp(18px, 4vw, 56px);
  z-index: 8;
  color: rgba(255, 255, 255, 0.82);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(25, 88, 100, 0.22);
}

.pause-button {
  position: absolute;
  top: max(82px, calc(env(safe-area-inset-top) + 74px));
  right: clamp(18px, 4vw, 56px);
  z-index: 26;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  color: #21494d;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(35, 93, 91, 0.16);
  backdrop-filter: blur(12px);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.03em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pause-button:hover,
.pause-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.94);
}

.pause-button:active {
  transform: translateY(1px) scale(0.97);
}

.game-credit {
  position: absolute;
  top: 132px;
  left: clamp(18px, 4vw, 56px);
  z-index: 8;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(25, 88, 100, 0.18);
  pointer-events: none;
}

.alert-strip {
  position: absolute;
  top: 102px;
  left: 50%;
  z-index: 12;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 15px;
  border: 1px solid rgba(255, 236, 187, 0.72);
  border-radius: 999px;
  background: rgba(89, 53, 36, 0.62);
  color: #fff3bf;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.alert-strip.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.survival-panel {
  position: absolute;
  top: 132px;
  right: clamp(18px, 4vw, 56px);
  z-index: 9;
  display: grid;
  gap: 6px;
  min-width: 104px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 12px;
  background: rgba(24, 78, 83, 0.34);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 18px rgba(33, 88, 92, 0.1);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 750;
  pointer-events: none;
}

.bonus-crystal-status,
.oxygen-status {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.bonus-crystal-status strong,
.oxygen-status strong {
  color: #eaffb0;
  font-size: 11px;
}

.oxygen-status {
  color: #bffaff;
}

.oxygen-status[hidden] {
  display: none;
}

.oxygen-track {
  width: 48px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.oxygen-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #70f0ff, #d5ffff);
  transition: width 0.15s linear, background 0.2s ease;
}

.effect-strip {
  position: absolute;
  top: 186px;
  left: clamp(18px, 4vw, 56px);
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(56vw, 620px);
  pointer-events: none;
}

.effect-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 999px;
  background: rgba(25, 76, 78, 0.42);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 6px 15px rgba(31, 84, 87, 0.1);
  backdrop-filter: blur(8px);
}

.effect-chip strong {
  color: #fff0ad;
}

.controls {
  position: absolute;
  right: clamp(18px, 4vw, 56px);
  bottom: calc(var(--safe-bottom) + 32px);
  left: clamp(18px, 4vw, 56px);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.dpad {
  position: relative;
  width: 158px;
  height: 158px;
  pointer-events: auto;
}

.control-button,
.action-button {
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #21494d;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 24px rgba(35, 93, 91, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  touch-action: none;
}

.control-button {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 17px;
  font-size: 19px;
  font-weight: 850;
  transition: transform 0.08s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.control-button:hover,
.control-button:focus-visible,
.action-button:hover,
.action-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.92);
}

.control-button:active,
.control-button.is-pressed {
  transform: translateY(2px) scale(0.94);
  background: #fff;
  box-shadow: 0 4px 12px rgba(35, 93, 91, 0.2), inset 0 2px 6px rgba(35, 93, 91, 0.12);
}

.control-button.up {
  top: 0;
  left: 51px;
}

.control-button.left {
  top: 51px;
  left: 0;
}

.control-button.down {
  top: 102px;
  left: 51px;
}

.control-button.right {
  top: 51px;
  left: 102px;
}

.action-button {
  min-width: 90px;
  min-height: 60px;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 8px 16px;
  border-radius: 19px;
  color: #fff;
  background: rgba(30, 84, 82, 0.78);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  animation: action-in 0.25s ease both;
  pointer-events: auto;
}

.controls.has-flight .action-button:not([hidden]) {
  margin-right: 104px;
}

.flight-button {
  position: absolute;
  right: 0;
  bottom: 0;
  min-width: 92px;
  min-height: 60px;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(145deg, rgba(128, 91, 171, 0.9), rgba(60, 119, 158, 0.86));
  box-shadow: 0 10px 24px rgba(48, 49, 107, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.48);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  animation: action-in 0.25s ease both;
}

.flight-button[hidden] {
  display: none;
}

.attack-button {
  position: absolute;
  right: 0;
  bottom: 72px;
  min-width: 92px;
  min-height: 56px;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 8px 14px;
  border: 1px solid rgba(255, 239, 189, 0.92);
  border-radius: 18px;
  color: #fff9e4;
  background: linear-gradient(145deg, rgba(141, 73, 75, 0.94), rgba(94, 58, 91, 0.9));
  box-shadow: 0 10px 24px rgba(79, 44, 65, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.42);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  animation: action-in 0.25s ease both;
}

.attack-button[hidden] {
  display: none;
}

.attack-button:hover,
.attack-button:focus-visible {
  outline: none;
  filter: brightness(1.1);
}

.attack-button:active {
  transform: translateY(2px) scale(0.95);
}

.attack-icon {
  color: #ffe2a1;
  font-size: 20px;
  line-height: 1;
}

.flight-button:hover,
.flight-button:focus-visible {
  outline: none;
  filter: brightness(1.1);
}

.flight-button.is-pressed {
  transform: translateY(2px) scale(0.95);
  background: linear-gradient(145deg, rgba(158, 113, 202, 0.96), rgba(73, 147, 187, 0.94));
}

.flight-icon {
  color: #fff4bd;
  font-size: 22px;
  line-height: 1;
}

.action-button[hidden] {
  display: none;
}

.action-button:active {
  transform: translateY(2px) scale(0.95);
}

.action-icon {
  color: #ffe39b;
  font-size: 22px;
  line-height: 1;
}

.hint-bar {
  position: absolute;
  right: clamp(18px, 4vw, 56px);
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 8;
  display: flex;
  gap: 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.keyboard-hint {
  opacity: 0.7;
}

.dialogue-bubble {
  position: absolute;
  z-index: 11;
  max-width: min(280px, calc(100vw - 40px));
  padding: 12px 15px 13px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 15px 15px 15px 3px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(23, 80, 86, 0.2);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translate(15px, -100%) scale(0.94);
  transform-origin: left bottom;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.dialogue-bubble.visible {
  opacity: 1;
  transform: translate(15px, calc(-100% - 14px)) scale(1);
}

.dialogue-speaker {
  display: block;
  margin-bottom: 3px;
  color: #2f9299;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.transform-overlay {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  background: rgba(24, 42, 69, 0.35);
  color: #fff;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.transform-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 39, 54, 0.42);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pause-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pause-panel {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 22px 54px rgba(10, 44, 54, 0.24);
  text-align: center;
}

.pause-kicker {
  color: #3e8e87;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.pause-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 6vw, 38px);
  letter-spacing: -0.06em;
}

.pause-panel p {
  margin: 0 0 7px;
  color: var(--muted-ink);
  font-size: 13px;
}

.resume-button {
  min-width: 128px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #1d7774;
  box-shadow: 0 8px 18px rgba(29, 119, 116, 0.22);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
}

.resume-button:hover,
.resume-button:focus-visible {
  outline: 2px solid rgba(29, 119, 116, 0.28);
  outline-offset: 3px;
  background: #176460;
}

.transform-kicker {
  color: #9ff4ff;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.25em;
}

.transform-title {
  font-size: clamp(32px, 7vw, 76px);
  font-weight: 900;
  letter-spacing: -0.07em;
  text-shadow: 0 4px 28px rgba(105, 229, 255, 0.7);
}

.transform-overlay p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
}

.transform-progress {
  width: min(260px, 68vw);
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.transform-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8effe1, #e8fcff, #b26dff);
  box-shadow: 0 0 14px #a6f8ff;
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  background: #69bdd4;
  color: #fff;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.is-ready {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen strong {
  font-size: 18px;
  letter-spacing: -0.03em;
}

.loading-screen span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.loading-orbit {
  width: 55px;
  height: 55px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: orbit 1s linear infinite;
}

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

@keyframes action-in {
  from { opacity: 0; transform: translateY(10px) scale(0.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes life-up {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 225, 126, 0)); }
  38% { transform: scale(1.25); filter: drop-shadow(0 0 12px rgba(255, 225, 126, 0.95)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 225, 126, 0)); }
}

@media (max-width: 620px) {
  .hud {
    gap: 8px;
  }

  .brand-subtitle,
  .keyboard-hint {
    display: none;
  }

  .game-title {
    font-size: 11px;
  }

  .pause-button {
    top: max(72px, calc(env(safe-area-inset-top) + 66px));
    min-width: 36px;
    justify-content: center;
    padding: 8px 10px;
  }

  #pause-label {
    display: none;
  }

  .status-panel {
    border-radius: 14px;
  }

  .form-status,
  .crystal-status {
    min-height: 52px;
    padding: 8px 11px;
  }

  .form-status strong,
  .crystal-status strong {
    font-size: 14px;
  }

  .scene-label {
    top: 80px;
  }

  .time-status {
    top: 105px;
  }

  .game-credit {
    top: 108px;
  }

  .survival-panel {
    top: 106px;
    right: 18px;
    min-width: 96px;
    padding: 6px 8px;
  }

  .effect-strip {
    top: 143px;
    max-width: calc(100vw - 36px);
  }

  .health-status {
    padding: 8px 9px;
    font-size: 13px;
    letter-spacing: 0.02em;
  }

  .flight-button {
    min-width: 82px;
    min-height: 54px;
  }

  .alert-strip {
    top: 78px;
    max-width: 80vw;
    text-align: center;
  }

  .hint-bar {
    left: 18px;
    justify-content: center;
    text-align: center;
  }
}

@media (orientation: portrait) and (max-width: 620px) {
  .controls {
    bottom: calc(var(--safe-bottom) + 34px);
  }

  .hint-bar {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

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