* {
  box-sizing: border-box;
}

:root {
  --rarity-common: #fff0b8;
  --rarity-rare: #46e568;
  --rarity-uncommon: #3d91ff;
  --rarity-epic: #9b4fff;
  --rarity-noble: #ff6b2b;
  --rarity-legendary: #ffc400;
  --rarity-mythic: #ff315d;
}

html,
body,
#app,
#root,
#game-container {
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body {
  color: #f3ead1;
  background: #111611;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
  background: #171d18;
}

#stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #171d18;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: clamp(18px, 5vw, 48px);
  overflow: auto;
  pointer-events: auto;
  background:
    radial-gradient(circle at 50% 35%, rgba(118, 135, 81, 0.2), transparent 42%),
    rgba(8, 12, 9, 0.82);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.hidden {
  display: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-panel {
  width: min(520px, 100%);
  padding: clamp(28px, 6vw, 48px);
  text-align: center;
  border: 1px solid rgba(221, 211, 175, 0.32);
  border-radius: 18px;
  background: rgba(31, 39, 31, 0.94);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.start-panel > span {
  display: block;
  margin-top: 12px;
  color: #c0c8b1;
}

.eyebrow {
  margin: 0 0 10px;
  color: #d1b65a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 8vw, 54px);
}

.start-panel p:not(.eyebrow) {
  margin: 0 auto 26px;
  color: #c0c8b1;
  line-height: 1.65;
}

.start-panel small {
  display: block;
  margin-top: 16px;
  color: #899581;
}

#startButton {
  position: relative;
  z-index: 1;
  min-width: 190px;
  min-height: 48px;
  padding: 14px 30px;
  color: #171b14;
  font: inherit;
  font-weight: 900;
  letter-spacing: 0.12em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #e3cf7c, #9cab6b);
  box-shadow: 0 10px 30px rgba(181, 164, 81, 0.24);
  transition: transform 140ms ease, filter 140ms ease;
}

#startButton:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

#startButton:active {
  transform: translateY(1px) scale(0.98);
}

#startButton:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
}

/* 총기 및 등급 텍스트에 선명한 검은색 테두리를 적용해요. */
.gun-text,
.weapon-text,
.rarity-text,
[data-gun],
[data-weapon],
[data-rarity] {
  font-weight: 900;
  -webkit-text-stroke: 1px #000000;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 2px 3px rgba(0, 0, 0, 0.9);
}

.rarity-common,
[data-rarity="일반"] {
  color: var(--rarity-common);
}

.rarity-rare,
[data-rarity="레어"] {
  color: var(--rarity-rare);
}

.rarity-uncommon,
[data-rarity="희귀"] {
  color: var(--rarity-uncommon);
}

.rarity-epic,
[data-rarity="에픽"] {
  color: var(--rarity-epic);
}

.rarity-noble,
[data-rarity="고귀"] {
  color: var(--rarity-noble);
}

.rarity-legendary,
[data-rarity="전설"] {
  color: var(--rarity-legendary);
}

.rarity-mythic,
[data-rarity="신화"] {
  color: var(--rarity-mythic);
}

/* 기존 스타일을 유지하면서 미리보기와 모바일 화면 대응을 보강해요. */
html,
body {
  min-height: 100%;
  min-height: 100dvh;
}

body {
  overscroll-behavior: none;
}

#app,
#root,
#game-container {
  min-height: 100%;
  min-height: 100dvh;
}

#stage {
  max-width: none;
  max-height: none;
  outline: none;
}

.overlay {
  padding-top: max(clamp(18px, 5vw, 48px), env(safe-area-inset-top));
  padding-right: max(clamp(18px, 5vw, 48px), env(safe-area-inset-right));
  padding-bottom: max(clamp(18px, 5vw, 48px), env(safe-area-inset-bottom));
  padding-left: max(clamp(18px, 5vw, 48px), env(safe-area-inset-left));
}

@media (max-width: 640px), (max-height: 520px) {
  .overlay {
    align-items: center;
    padding: max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .start-panel {
    padding: clamp(20px, 5vw, 30px);
    border-radius: 14px;
  }

  h1 {
    margin-bottom: 10px;
    font-size: clamp(27px, 8vw, 42px);
  }

  .start-panel p:not(.eyebrow) {
    margin-bottom: 18px;
    line-height: 1.5;
  }

  #startButton {
    width: min(100%, 320px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  #startButton {
    transition: none;
  }
}

/*
 * 기존 디자인을 유지한 채 미리보기 iframe과 모바일 브라우저에서
 * 캔버스가 부모 영역 전체를 안정적으로 채우도록 보강해요.
 */
html,
body {
  position: relative;
  width: 100%;
  height: 100%;
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#stage {
  width: 100%;
  height: 100%;
  min-width: 1px;
  min-height: 1px;
  contain: layout paint;
}

@supports not (height: 100dvh) {
  #app {
    height: 100vh;
  }
}

@media (orientation: portrait) {
  #stage {
    width: 100%;
    height: 100%;
  }
}
