/* Lucky Grab — DESIGN.md aligned styles */
/* Aesthetic: Playful Premium | Fonts: Outfit + Pretendard */

/* =============================================================
   CSS Custom Properties (from DESIGN.md)
   ============================================================= */
:root {
  --gold: #F5A623;
  --gold-light: #FFD07A;
  --gold-dark: #D48A0C;
  --action: #FF5566;
  --action-hover: #FF3347;
  --bg: #0B0B1A;
  --bg-elevated: #12122A;
  --surface: #1A1A2E;
  --surface-hover: #22223A;
  --border: #2A2A44;
  --text: #F0F0F5;
  --text-secondary: #B0B0CC;
  --text-muted: #8888AA;
  --text-dim: #555577;
  --success: #4ADE80;
  --warning: #FBBF24;
  --error: #F87171;

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Pretendard Variable', 'Pretendard', -apple-system, sans-serif;

  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 20px;
  --r-full: 9999px;
}

/* =============================================================
   Reset & Base
   ============================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  font-family: var(--font-body);
  color: var(--text);
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.game-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
  position: relative;
}

/* =============================================================
   Brand Header
   ============================================================= */
.brand-header { text-align: center; margin-bottom: 6px; }

.brand-name {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 10px;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(245, 166, 35, 0.4));
  line-height: 1.1;
}

.brand-event {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--gold-light);
  font-weight: 600;
  letter-spacing: 4px;
  margin-top: 2px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* =============================================================
   Machine
   ============================================================= */
.machine { width: 100%; max-width: 340px; position: relative; }

.machine-top {
  background: linear-gradient(180deg, #4a4a5a 0%, #3a3a4a 100%);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 12px 16px;
  border: 3px solid var(--border);
  border-bottom: none;
  position: relative;
  height: 60px;
}

.rail {
  width: 100%; height: 100%;
  position: relative;
  background: linear-gradient(180deg, #333345 0%, #2a2a3a 100%);
  border-radius: var(--r-md);
  overflow: visible;
}

/* Claw Assembly */
.claw-assembly {
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  z-index: 50;
}

.claw-rope {
  width: 3px; height: 20px;
  background: linear-gradient(180deg, #888, #aaa, #888);
}

.claw-head {
  position: relative; width: 40px; height: 24px;
  display: flex; justify-content: center;
}

.claw-arm {
  width: 4px; height: 22px;
  background: linear-gradient(180deg, #c0c0c0, #909090);
  border-radius: 0 0 2px 2px;
  position: absolute; top: 0;
  transform-origin: top center;
  transition: transform 0.3s ease;
}
.claw-arm.left { left: 8px; transform: rotate(-20deg); border-radius: 2px; }
.claw-arm.right { right: 8px; transform: rotate(20deg); border-radius: 2px; }

.claw-arm.left::after,
.claw-arm.right::after {
  content: ''; position: absolute; bottom: -4px;
  width: 6px; height: 6px; background: #a0a0a0;
  border-radius: 50%; left: 50%; transform: translateX(-50%);
}

.claw-assembly.closed .claw-arm.left { transform: rotate(-5deg); }
.claw-assembly.closed .claw-arm.right { transform: rotate(5deg); }

/* Grabbed ball */
.grabbed-ball {
  width: 30px; height: 30px; border-radius: 50%;
  position: absolute; bottom: -28px; display: none;
  box-shadow: inset -3px -3px 6px rgba(0,0,0,0.3), inset 3px 3px 6px rgba(255,255,255,0.2);
}
.grabbed-ball.visible { display: block; }

/* Machine Body */
.machine-body {
  background: linear-gradient(180deg, rgba(20,20,40,0.9) 0%, rgba(15,15,30,0.95) 100%);
  border-left: 3px solid var(--border);
  border-right: 3px solid var(--border);
  height: 280px; position: relative; overflow: hidden;
}

.machine-body::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 50%, rgba(255,255,255,0.02) 100%);
  pointer-events: none; z-index: 5;
}

.machine-body::after {
  content: ''; position: absolute; top: 10px; left: 10px;
  width: 40px; height: 80px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 100%);
  border-radius: var(--r-xl); pointer-events: none; z-index: 6;
}

.machine-label {
  position: absolute; bottom: 12px; right: 14px;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 900; letter-spacing: 5px;
  color: rgba(245, 166, 35, 0.07);
  z-index: 3; pointer-events: none;
}

/* Ball Pit */
.ball-pit { width: 100%; height: 100%; position: relative; }

.ball {
  position: absolute; border-radius: 50%;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.3),
              inset 4px 4px 8px rgba(255,255,255,0.15),
              0 2px 4px rgba(0,0,0,0.3);
  z-index: 2; transition: opacity 0.3s, transform 0.3s;
}

.ball::after {
  content: ''; position: absolute; top: 20%; left: 25%;
  width: 30%; height: 20%;
  background: rgba(255,255,255,0.35);
  border-radius: 50%; transform: rotate(-30deg);
}

/* Machine Base */
.machine-base {
  background: linear-gradient(180deg, #3a3a4a 0%, #4a4a5a 50%, #3a3a4a 100%);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  border: 3px solid var(--border);
  border-top: 2px solid #4a4a5a;
  height: 60px; position: relative;
  display: flex; justify-content: center; align-items: center;
}

.exit-hole {
  width: 70px; height: 30px;
  background: radial-gradient(ellipse, var(--bg) 60%, var(--surface) 100%);
  border-radius: 0 0 35px 35px;
  border: 2px solid #333; border-top: none;
  position: absolute; top: 0;
}

/* =============================================================
   Controls
   ============================================================= */
.controls {
  display: flex; gap: 12px; margin-top: 20px;
  align-items: center; touch-action: none;
}

.ctrl-btn {
  width: 64px; height: 56px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #4a4a6a 0%, #3a3a5a 100%);
  color: #ddd; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: transform 0.1s ease, background 0.1s ease;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
  -webkit-touch-callout: none;
}
.ctrl-btn:active:not(:disabled) {
  transform: scale(0.92);
  background: linear-gradient(180deg, #5a5a7a 0%, #4a4a6a 100%);
}
.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Grab Button */
.grab-button {
  width: 120px; height: 56px;
  border: none; border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--action) 0%, var(--action-hover) 100%);
  color: white; font-family: var(--font-body);
  font-size: 20px; font-weight: 800; letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 85, 102, 0.4),
              0 2px 4px rgba(0,0,0,0.3),
              inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  position: relative; overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.grab-button::after {
  content: ''; position: absolute; top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: shimmer 3s infinite;
}
@keyframes shimmer { 0% { left: -100%; } 100% { left: 100%; } }

.grab-button:active:not(:disabled) {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(255,85,102,0.3), 0 1px 2px rgba(0,0,0,0.3);
}
.grab-button:disabled {
  background: linear-gradient(180deg, #666 0%, #555 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); cursor: not-allowed;
}
.grab-button:disabled::after { display: none; }

.hint {
  color: var(--text-dim); font-size: 11px;
  margin-top: 12px; text-align: center; line-height: 1.4;
}

.remaining-plays {
  color: var(--text-muted); font-size: 12px;
  margin-top: 8px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   Toast
   ============================================================= */
.toast {
  position: fixed; top: 18%; left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(26, 26, 46, 0.95);
  color: var(--gold-light); padding: 12px 28px;
  border-radius: var(--r-full); font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 500; pointer-events: none;
  border: 1px solid rgba(245, 166, 35, 0.2);
  white-space: nowrap;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============================================================
   Result Overlay
   ============================================================= */
.result-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  display: none; justify-content: center; align-items: center;
  z-index: 1000; opacity: 0; transition: opacity 0.4s ease;
}
.result-overlay.visible { display: flex; opacity: 1; }

.result-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border-radius: var(--r-xl); padding: 40px 32px;
  text-align: center; max-width: 320px; width: 90%;
  border: 2px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative; overflow: hidden;
}
.result-overlay.visible .result-card { transform: scale(1); }

.result-ball {
  width: 80px; height: 80px; border-radius: 50%;
  margin: 0 auto 20px;
  box-shadow: inset -6px -6px 12px rgba(0,0,0,0.3),
              inset 6px 6px 12px rgba(255,255,255,0.15),
              0 4px 20px rgba(0,0,0,0.3);
  animation: float 2s ease-in-out infinite;
}
.result-ball::after {
  content: ''; position: absolute; top: 18%; left: 22%;
  width: 35%; height: 22%;
  background: rgba(255,255,255,0.35);
  border-radius: 50%; transform: rotate(-30deg);
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.result-title {
  font-family: var(--font-display);
  color: var(--gold); font-size: 24px; font-weight: 800;
  margin-bottom: 8px;
}

.result-desc {
  color: var(--text-secondary); font-size: 14px;
  line-height: 1.5; margin-bottom: 24px;
}

.coupon-button {
  width: 100%; padding: 14px;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
  color: var(--bg); border: none;
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-size: 16px; font-weight: 700; cursor: pointer;
  margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(245, 166, 35, 0.3);
  transition: transform 0.1s ease;
}
.coupon-button:active { transform: scale(0.96); }

.share-button {
  width: 100%; padding: 12px;
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 600; cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.15s ease;
}
.share-button:hover { background: var(--surface-hover); }

.retry-button {
  background: linear-gradient(180deg, #5566ff 0%, #4455dd 100%);
  color: white; border: none;
  border-radius: var(--r-full); padding: 12px 40px;
  font-family: var(--font-body);
  font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(80,100,255,0.3);
  transition: transform 0.1s ease;
  touch-action: manipulation;
}
.retry-button:active { transform: scale(0.95); }
.retry-button:disabled { opacity: 0.4; cursor: not-allowed; }

/* =============================================================
   Suspense Overlay ("과연...?")
   ============================================================= */
.suspense-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; justify-content: center; align-items: center;
  z-index: 800; opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
.suspense-overlay.visible { opacity: 1; pointer-events: auto; }

.suspense-text {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 800;
  color: var(--gold-light);
  animation: suspensePulse 1s ease-in-out infinite;
}
@keyframes suspensePulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* =============================================================
   Event Status Screens
   ============================================================= */
.status-screen {
  text-align: center; padding: 80px 24px;
}
.status-emoji { font-size: 64px; margin-bottom: 16px; }
.status-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800; color: var(--text);
  margin-bottom: 8px;
}
.status-desc {
  color: var(--text-secondary); font-size: 15px; line-height: 1.6;
}
.status-time {
  color: var(--gold); font-size: 14px; margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   Animations
   ============================================================= */
@keyframes ballShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px) rotate(-2deg); }
  75% { transform: translateX(2px) rotate(2deg); }
}
.ball.shaking { animation: ballShake 0.15s ease infinite; }

/* Confetti */
.confetti {
  position: absolute; width: 8px; height: 8px;
  border-radius: 2px;
  animation: confettiFall 1.5s ease forwards;
  pointer-events: none;
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(120px) rotate(720deg) scale(0.3); }
}

/* =============================================================
   Stars Background
   ============================================================= */
.game-container::before {
  content: ''; position: fixed; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 50% 10%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 20% 90%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 80% 15%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 60% 75%, rgba(255,255,255,0.3), transparent);
  pointer-events: none; z-index: 0;
}
.game-container > * { position: relative; z-index: 1; }

/* =============================================================
   Mute Button
   ============================================================= */
.mute-btn {
  position: fixed; top: 16px; right: 16px;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.mute-btn:active { background: var(--surface-hover); }

/* =============================================================
   Landscape Warning
   ============================================================= */
.landscape-warning {
  display: none; position: fixed; inset: 0;
  background: var(--bg);
  flex-direction: column;
  justify-content: center; align-items: center;
  z-index: 9999; color: var(--text);
}
.landscape-icon { font-size: 48px; margin-bottom: 16px; animation: rotatePhone 2s ease-in-out infinite; }
.landscape-warning p {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
}
@keyframes rotatePhone { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }

@media (orientation: landscape) and (max-height: 500px) {
  .landscape-warning { display: flex; }
}

/* =============================================================
   Reduced Motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
