:root {
  --bg: #0d0d0f;
  --bg-card: #17171c;
  --bg-card-2: #1f1f26;
  --gold: #c9a227;
  --gold-bright: #e8c34a;
  --red: #b3202c;
  --red-bright: #e0313f;
  --text: #ece8df;
  --text-dim: #9a958a;
  --metal: #3a3a42;
  --metal-light: #55555f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #1a1a21 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: fadeIn 0.35s ease;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.title {
  font-size: clamp(2.4rem, 9vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(201, 162, 39, 0.35), 0 2px 0 rgba(0, 0, 0, 0.6);
}

.title-small {
  font-size: 1.5rem;
}

.title-dead {
  color: var(--red-bright);
  text-shadow: 0 0 32px rgba(224, 49, 63, 0.5), 0 2px 0 rgba(0, 0, 0, 0.6);
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  margin-top: -16px;
}

.setup-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid #2a2a33;
  border-radius: 20px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.setup-label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.bullet-selector {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.bullet-pill {
  flex: 1;
  max-width: 64px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--metal-light);
  background: var(--bg-card-2);
  color: var(--text-dim);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.bullet-pill:active {
  transform: scale(0.92);
}

.bullet-pill.selected {
  border-color: var(--gold);
  background: linear-gradient(160deg, #2c2617, #1d1a10);
  color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(201, 162, 39, 0.35);
}

.bullet-pill:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

.setup-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.btn {
  width: 100%;
  min-height: 64px;
  border: none;
  border-radius: 16px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  cursor: pointer;
  color: #141414;
  transition: transform 0.1s ease, filter 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  box-shadow: 0 6px 20px rgba(201, 162, 39, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-danger {
  background: linear-gradient(160deg, var(--red-bright), var(--red));
  color: #fff;
  box-shadow: 0 6px 24px rgba(179, 32, 44, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.revolver-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.revolver-wrap svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6));
}

.revolver-wrap-small svg {
  max-width: 220px;
}

.metal {
  fill: var(--metal);
  stroke: var(--metal-light);
  stroke-width: 1.5;
}

.metal-dark {
  fill: #26262d;
  stroke: var(--metal-light);
  stroke-width: 1;
}

.grip {
  fill: #4a3220;
  stroke: #63452c;
  stroke-width: 2;
}

.cylinder-body {
  fill: #2e2e36;
  stroke: var(--metal-light);
  stroke-width: 2;
}

.cylinder-axis {
  fill: #1b1b21;
  stroke: var(--metal-light);
  stroke-width: 1.5;
}

.cylinder {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.chamber {
  fill: #141419;
  stroke: var(--metal-light);
  stroke-width: 1.5;
}

.chamber-marker {
  fill: #6b6558;
}

.chamber-reveal-empty {
  fill: #141419;
  stroke: var(--metal-light);
  stroke-width: 2;
}

.chamber-reveal-bullet {
  fill: var(--red-bright);
  stroke: #ff6b76;
  stroke-width: 2;
}

.chamber-reveal-fired {
  fill: #3a2a2c;
  stroke: #6b4a4e;
  stroke-width: 2;
}

.flash {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 60% 45%, rgba(255, 230, 150, 0.9) 0%, rgba(255, 120, 40, 0.45) 35%, transparent 70%);
  pointer-events: none;
  animation: flashOut 0.25s ease-out forwards;
}

@keyframes flashOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.stats {
  width: 100%;
  display: flex;
  gap: 10px;
}

.stat {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid #2a2a33;
  border-radius: 14px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-accent {
  border-color: rgba(201, 162, 39, 0.55);
  background: linear-gradient(160deg, #221e12, var(--bg-card));
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-accent .stat-value {
  color: var(--gold-bright);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.result-message {
  min-height: 1.6em;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

.result-message.hit {
  color: var(--red-bright);
}

.result-message.safe {
  color: var(--gold-bright);
}

.over-detail {
  font-size: 1rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
  margin-top: -12px;
}

@media (max-height: 640px) {
  .screen {
    gap: 14px;
  }

  .revolver-wrap svg {
    max-width: 260px;
  }

  .btn {
    min-height: 56px;
  }
}
