/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Light Theme ── */
:root {
  --bg: #faf9f7;
  --bg2: #f2f0ed;
  --surface: rgba(255,255,255,0.82);
  --surface2: rgba(245,243,240,0.75);
  --border: rgba(228,224,218,0.7);
  --primary: #e8590c;
  --primary-hover: #d9480f;
  --primary-glow: rgba(232,89,12,0.18);
  --primary-subtle: rgba(232,89,12,0.06);
  --accent: #f59f00;
  --accent2: #2b8a3e;
  --accent3: #1971c2;
  --text: #1a1a1a;
  --text2: #6b6b6b;
  --text3: #9a9a9a;
  --success: #2b8a3e;
  --danger: #e03131;
  --shadow: rgba(0,0,0,0.06);
  --card-shadow: 0 4px 24px rgba(0,0,0,0.05);
  --radius: 14px;
  --nav-bg: rgba(250,249,247,0.92);
  --gradient-party: linear-gradient(135deg, #e8590c, #f59f00, #2b8a3e, #1971c2);
  --gradient-hero: linear-gradient(135deg, #e8590c, #f59f00);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════ */
.screen { display: none; flex-direction: column; min-height: 100vh; }
.screen.active { display: flex; }

/* ═══════════════════════════════════════════
   NAV
   ═══════════════════════════════════════════ */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: transparent;
}
.nav-logo {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
}
.nav-back {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: color 0.2s;
}
.nav-back:hover { color: var(--text); }

/* ═══════════════════════════════════════════
   HERO / LANDING
   ═══════════════════════════════════════════ */
/* ── Global Background Shapes ── */
.bg-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
}
.shape-1 {
  width: 500px; height: 500px;
  background: #ff6b6b;
  top: -15%; left: -10%;
  animation: float1 8s ease-in-out infinite;
}
.shape-2 {
  width: 400px; height: 400px;
  background: #ffd43b;
  bottom: -10%; right: -8%;
  animation: float2 10s ease-in-out infinite;
}
.shape-3 {
  width: 350px; height: 350px;
  background: #51cf66;
  top: 40%; left: 55%;
  animation: float3 12s ease-in-out infinite;
}
.shape-4 {
  width: 300px; height: 300px;
  background: #339af0;
  top: 10%; right: 20%;
  animation: float1 14s ease-in-out infinite reverse;
}
@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(40px,30px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-30px,-40px); } }
@keyframes float3 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-20px,30px); } }

#app { position: relative; z-index: 1; }

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px 60px;
}

.hero-content { max-width: 580px; }
.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -1.5px;
  margin-bottom: 20px;
  text-align: center;
}
.gradient-text {
  background: var(--gradient-party);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-desc {
  font-size: 1.05rem;
  color: var(--text2);
  line-height: 1.7;
  margin-bottom: 36px;
}

.btn-hero {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 16px 40px;
  background: var(--gradient-hero);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 8px 30px var(--primary-glow);
}
.btn-hero:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px var(--primary-glow);
}
.btn-hero svg { transition: transform 0.2s; }
.btn-hero:hover svg { transform: translateX(4px); }

/* ── Features ── */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 24px 60px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.feature-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: all 0.3s;
}
.feature-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--card-shadow);
}
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 0.85rem; color: var(--text2); line-height: 1.5; }

/* ── Footer ── */
.landing-footer {
  text-align: center;
  padding: 24px;
  color: var(--text3);
  font-size: 0.82rem;
}

/* ═══════════════════════════════════════════
   CREATE DIALOG
   ═══════════════════════════════════════════ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
  padding: 24px;
}
.dialog {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  position: relative;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--card-shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.dialog.dialog-wide { max-width: 460px; }
.dialog-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}
.dialog-close:hover { color: var(--text); }
.dialog-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 20px;
}
.dialog-body { margin-bottom: 20px; }
.dialog-body .form-group { margin-bottom: 14px; }
.dialog-body .form-group:last-child { margin-bottom: 0; }
.dialog-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Toggle Option (Checkbox 스타일) */
.toggle-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 14px;
}
.toggle-option:hover { border-color: var(--primary); }
.toggle-option input { display: none; }
.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 20px;
  flex-shrink: 0;
  transition: background 0.25s;
}
.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}
.toggle-option input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-option input:checked + .toggle-slider::after {
  transform: translateX(16px);
}
.toggle-text { display: flex; flex-direction: column; gap: 1px; }
.toggle-text strong { font-size: 0.85rem; font-weight: 700; }
.toggle-text small { font-size: 0.72rem; color: var(--text2); }

/* Input */
.input-large {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-large:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.input-large::placeholder { color: var(--text3); }

/* Input with inline action button */
.input-with-action { position: relative; }
.input-with-action .input-large { padding-right: 42px; }
.input-action-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.input-action-btn:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

.option-hint { color: var(--text3); font-weight: 400; }

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid #d0cac0;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  background: var(--surface2);
}
.stepper-btn {
  width: 40px;
  height: 40px;
  background: var(--surface2);
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stepper-btn:hover { background: var(--primary-subtle); }
.stepper input {
  flex: 1;
  min-width: 0;
  width: auto;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
}

/* ═══════════════════════════════════════════
   COMMON COMPONENTS
   ═══════════════════════════════════════════ */

/* Card */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 10px 16px; font-size: 0.85rem; }
.btn.full { width: 100%; margin-top: 12px; padding: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-create-final {
  padding: 10px 24px;
  font-size: 0.92rem;
  box-shadow: 0 4px 16px var(--primary-glow);
}

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text2);
  margin-bottom: 6px;
  font-weight: 600;
}
select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
select:focus { border-color: var(--primary); }

.text-muted { color: var(--text3); }

/* ═══════════════════════════════════════════
   JOIN SCREEN
   ═══════════════════════════════════════════ */
.join-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.join-wrapper .card {
  width: 100%;
  max-width: 420px;
}
.join-wrapper h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 20px;
}

.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 8px; min-height: 20px; }

/* ═══════════════════════════════════════════
   ROOM LAYOUT (2-column)
   ═══════════════════════════════════════════ */
.room-layout {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

/* ── Left: Game Area ── */
.room-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  gap: 0;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Game Toolbar */
.game-toolbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.game-toolbar-left { display: flex; align-items: center; gap: 10px; }
.game-toolbar-right { display: flex; align-items: center; gap: 6px; }
.game-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.game-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.game-tool-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}
.game-tool-btn.icon-only {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}
.game-tool-btn svg { flex-shrink: 0; }
.game-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 12px;
}
.game-area > #game-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.btn-start-nav {
  padding: 8px 20px;
  font-size: 0.88rem;
  box-shadow: 0 2px 12px var(--primary-glow);
  flex-shrink: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  display: block;
}

/* ── Right: Chat ── */
.room-right {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.room-right .panel-tabs { flex: 1; }

.panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text2);
}
.panel-body { padding: 14px 16px; }

/* Options panel */
.panel-options { flex-shrink: 0; }
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.option-row label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text2);
}
.toggle-group { display: flex; gap: 6px; }
.dialog .toggle-group { width: 100%; }
.dialog .toggle-btn { flex: 1; padding: 10px; font-size: 0.85rem; }
.toggle-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.toggle-btn:hover { border-color: var(--primary); }
.toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Participants (inside options) */
.participants-section { margin-top: 8px; }
.participants-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.participants-label { font-size: 0.82rem; color: var(--text2); }
.participant-list { list-style: none; }
.participant-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 0.85rem;
}
.participant-list li .name {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.participant-list li .p-icon { flex-shrink: 0; }
.participant-list li .host-tag {
  font-size: 0.65rem;
  background: var(--primary);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 700;
}
.participant-list li .you-tag {
  font-size: 0.65rem;
  background: var(--success);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 700;
}
.btn-kick {
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.btn-kick:hover {
  color: var(--danger);
  background: rgba(224,49,49,0.1);
}

.badge {
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* Tab panel */
.panel-tabs {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}
.tab-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
  animation: tab-badge-pulse 1.4s ease-in-out infinite;
}
@keyframes tab-badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.85; }
}
.tab-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--primary-subtle);
  color: var(--primary);
}
.tab-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.tab-pane.active { display: flex; }
.tab-pane[data-pane="participants"] {
  padding: 0;
  display: none;
}
.tab-pane[data-pane="participants"].active {
  display: flex;
  flex-direction: column;
}
.tab-pane[data-pane="participants"] .participant-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}
.tab-pane[data-pane="participants"] .participant-list::-webkit-scrollbar { width: 6px; }
.tab-pane[data-pane="participants"] .participant-list::-webkit-scrollbar-track { background: transparent; }
.tab-pane[data-pane="participants"] .participant-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.tab-pane[data-pane="participants"] .participant-list::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.participant-add-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.participant-add-row .input-large {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
}
.btn-add {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-add:hover { background: var(--primary-hover); }
.chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.chat-msg {
  font-size: 0.82rem;
  line-height: 1.4;
  animation: fadeIn 0.2s ease;
}
.chat-msg .chat-author {
  font-weight: 700;
  color: var(--primary);
  margin-right: 6px;
}
.chat-msg .chat-text { color: var(--text); }
.chat-msg.system-msg {
  color: var(--text3);
  font-size: 0.75rem;
  font-style: italic;
}
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.chat-input-row .input-large {
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* Result overlay */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease;
}

/* ── Fireworks (pyro) ── */
.pyro {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}
.pyro > .before,
.pyro > .after {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 #fff;
  animation: 1s bang ease-out infinite backwards,
             1s gravity ease-in infinite backwards,
             5s position linear infinite backwards;
}
.pyro > .after {
  animation-delay: 1.25s, 1.25s, 1.25s;
  animation-duration: 1.25s, 1.25s, 6.25s;
}
@keyframes gravity {
  to {
    transform: translateY(200px);
    opacity: 0;
  }
}
@keyframes position {
  0%, 19.9%  { margin-top: 10%; margin-left: 40%; }
  20%, 39.9% { margin-top: 40%; margin-left: 30%; }
  40%, 59.9% { margin-top: 20%; margin-left: 70%; }
  60%, 79.9% { margin-top: 30%; margin-left: 20%; }
  80%, 99.9% { margin-top: 30%; margin-left: 80%; }
}
.result-card { position: relative; z-index: 1; }
.result-card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 36px;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
  width: 90%;
}
.result-card h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
  color: var(--primary);
}
.result-name {
  font-size: 2.4rem;
  font-weight: 800;
  background: var(--gradient-party);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 20px;
}
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* Result rankings list */
.result-rankings {
  margin: 0 -8px 16px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 12px;
  text-align: left;
  max-height: 200px;
  overflow-y: auto;
}
.result-rankings .rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  font-size: 0.9rem;
  font-weight: 600;
}
.result-rankings .rank-item + .rank-item {
  border-top: 1px solid var(--border);
}
.result-rankings .rank-num {
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 700;
  width: 28px;
}
.result-rankings .rank-label {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}
.result-rankings .rank-name {
  flex: 1;
  color: var(--text);
}

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 200;
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.toast-error { background: var(--danger); }

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 900px) {
  .room-layout { flex-direction: column; }
  .room-left { min-height: 50vh; }
  .game-area { min-height: 300px; }
  .room-right { width: 100%; min-height: 320px; }
  .invite-compact input { width: 140px; }
}
@media (max-width: 600px) {
  .hero-title { font-size: 2rem; }
  .hero-desc { font-size: 0.92rem; }
  .btn-hero { padding: 14px 32px; font-size: 1rem; }
  .features { grid-template-columns: 1fr 1fr; gap: 10px; }
  .feature-card { padding: 20px 16px; }
  .result-name { font-size: 2rem; }
  .result-card { padding: 28px 20px; }
  .dialog { padding: 20px; max-width: 340px; }
  .invite-compact { display: none; }
}
@media (max-width: 400px) {
  .hero-title { font-size: 1.7rem; }
  .nav { padding: 14px 16px; }
}

/* ═══════════════════════════════════════════
   GACHA (DOM + GSAP, scoped to #gacha-dom)
   ═══════════════════════════════════════════ */
.gacha-root {
  --gvh: 6px; /* JS에서 게임 영역 높이 기준으로 설정 */
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.gacha-root * { box-sizing: border-box; margin: 0; padding: 0; }

.gacha-root .gacha-game-layer {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.gacha-root .gacha-machine-container {
  position: relative;
  white-space: nowrap;
}
.gacha-root .gacha-machine {
  position: relative;
  z-index: 1;
  max-height: calc(var(--gvh) * 80);
  pointer-events: none;
  display: block;
  /* 상단 사인(무지개 장식) 제거 — 머신 외곽선은 유지 */
  clip-path: inset(14.5% 0 0 0);
}
.gacha-root .gacha-title-container { display: none; }
.gacha-root .gacha-title-deco { display: none; }
.gacha-root .gacha-backboard {
  z-index: 0;
  width: calc(var(--gvh) * 15);
  height: calc(var(--gvh) * 13);
  top: 65%;
  left: 48%;
  background-color: #e288bb;
  position: absolute;
}
.gacha-root .gacha-handle {
  z-index: 3;
  position: absolute;
  height: calc(var(--gvh) * 3.9);
  left: 13%;
  top: 70%;
}
.gacha-root .gacha-balls {
  position: absolute;
  top: 22%;
  left: 2%;
  width: 96%;
  height: 34.5%;
}
.gacha-root .gacha-pointer {
  position: absolute;
  height: calc(var(--gvh) * 15);
  top: 75%;
  left: 15%;
  z-index: 5;
  pointer-events: none;
}
.gacha-root .gacha-pointer img {
  height: 100%;
  display: block;
  transform: rotate(-30deg);
  transform-origin: 0% 0%;
  animation: gacha-click 1s ease-in-out infinite both;
}

.gacha-root .gacha-ui-layer {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
}
.gacha-root .gacha-title-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 11;
}
.gacha-root .gacha-title h2 {
  text-align: center;
  font-family: 'M PLUS Rounded 1c', 'Trebuchet MS', sans-serif;
  color: #fff;
  font-size: calc(var(--gvh) * 5);
  font-weight: 700;
  text-shadow:
    0 0 2px #f06e5b, 0 0 2px #f06e5b, 0 0 2px #f06e5b, 0 0 2px #f06e5b,
    0 0 2px #f06e5b, 0 0 2px #f06e5b, 0 0 2px #f06e5b, 0 0 2px #f06e5b,
    1px 1px 2px #f06e5b, -1px 1px 2px #f06e5b, 1px -1px 2px #f06e5b, -1px -1px 2px #f06e5b;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.2));
}
.gacha-root .gacha-prize-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
.gacha-root .gacha-prize-ball-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
.gacha-root .gacha-prize-reward-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}
.gacha-root .gacha-prize-reward-container > * {
  display: flex;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  align-items: center;
  justify-content: center;
}
.gacha-root .gacha-winner {
  font-family: 'M PLUS Rounded 1c', 'Trebuchet MS', sans-serif;
  font-size: calc(var(--gvh) * 8);
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-shadow:
    0 0 3px #ad8bd6, 0 0 3px #ad8bd6, 0 0 3px #ad8bd6, 0 0 3px #ad8bd6,
    0 0 3px #ad8bd6, 0 0 3px #ad8bd6, 0 0 3px #ad8bd6, 0 0 3px #ad8bd6,
    2px 2px 3px #ad8bd6, -2px 2px 3px #ad8bd6, 2px -2px 3px #ad8bd6, -2px -2px 3px #ad8bd6;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.25));
}
.gacha-root .gacha-shine img {
  height: calc(var(--gvh) * 100);
  animation: gacha-spin linear 5s infinite forwards;
}

/* 공 */
.gacha-root .gacha-ball {
  --size: calc(var(--gvh) * 8);
  --outline: #4c3fc2;
  --color1: #2facff;
  --color2: #ff8ff6;

  width: var(--size);
  height: var(--size);
  border-radius: 100%;
  background-color: var(--color1);
  border: solid calc(var(--gvh) * 0.8) var(--outline);
  position: absolute;
  overflow: hidden;
}
.gacha-root .gacha-ball::after {
  content: '';
  display: block;
  position: absolute;
  top: 50%;
  height: 200%;
  width: 200%;
  background-color: var(--color2);
  border-radius: 100%;
  border: inherit;
  transform: translate(-25%, -5%);
}

/* dim 효과 */
.gacha-root.gacha-dim .gacha-game-layer {
  filter: brightness(0.6) saturate(0.8);
  transition: 0.5s linear;
}

.gacha-wiggle { animation: gacha-wiggle 2s ease-in-out infinite both; }

@keyframes gacha-wiggle {
  0% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
  100% { transform: rotate(-5deg); }
}
@keyframes gacha-click {
  0% { transform: rotate(-30deg) translateY(0); }
  80% { transform: rotate(-30deg) translateY(calc(var(--gvh) * 5)); }
  100% { transform: rotate(-30deg) translateY(0); }
}
@keyframes gacha-spin {
  from { transform: rotate(1turn); }
  to { transform: rotate(0turn); }
}
