:root {
  --bg-top: #050d1a;
  --bg-bottom: #0d2238;
  --surface: rgba(15, 31, 51, 0.88);
  --surface-solid: #10233a;
  --border: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #f59e0b;
  --gold-light: #fde047;
  --discord: #5865f2;
  --primary: #dc2626;
  --primary-hover: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 15%, #153454 0%, var(--bg-top) 75%);
  overflow-x: hidden;
}

/* Schneefall */
.snowflakes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -12px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  user-select: none;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translateY(105vh) rotate(360deg);
  }
}

/* Topbar */
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(5, 13, 26, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 2rem;
}

.topbar-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.token-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: var(--gold-light);
  font-size: 0.92rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.user-pill img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.logout-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.logout-link:hover {
  color: #fff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.btn-discord {
  background: var(--discord);
  color: #fff;
}

.btn-discord:hover {
  background: #4752c4;
}

/* Placement Banner */
.placement-banner {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(245, 158, 11, 0.95);
  color: #1e293b;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

/* Tree Stage (3D) */
.tree-stage {
  position: relative;
  z-index: 10;
  width: 100%;
  height: calc(100vh - 74px);
  min-height: 520px;
}

.tree-3d-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
}

.tree-3d-wrap:active {
  cursor: grabbing;
}

.tree-3d-wrap.placing-active {
  cursor: crosshair;
}

.tree-3d-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tree-hud-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(5, 13, 26, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
  pointer-events: none;
}

@media (max-width: 640px) {
  .tree-hud-hint {
    font-size: 0.72rem;
    padding: 6px 12px;
    max-width: 94vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.twinkle {
  animation: twinkleAnim 2.4s ease-in-out infinite;
}
.t2 { animation-delay: 0.8s; }
.t3 { animation-delay: 1.6s; }

@keyframes twinkleAnim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.ornaments-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Einzelne Baum-Elemente */
.tree-item {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease;
  z-index: 2;
}

.tree-item:hover {
  transform: translate(-50%, -50%) scale(1.16);
  z-index: 15;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.45));
}

/* Kugeln */
.bauble {
  position: relative;
  border-radius: 50%;
  border: 3px solid #ef4444;
  background: #1e293b;
  box-shadow: inset -4px -6px 12px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5);
  overflow: visible;
}

.bauble-cap {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 30%;
  min-width: 12px;
  height: 7px;
  background: linear-gradient(90deg, #b45309, #fde047, #b45309);
  border-radius: 3px 3px 0 0;
}

.bauble-cap::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 7px;
  height: 5px;
  border: 2px solid #fde047;
  border-bottom: none;
  border-radius: 50% 50% 0 0;
}

.bauble-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bauble-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 28% 25%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 45%);
  pointer-events: none;
}

.bauble-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Kugelgrößen (responsive mit clamp) */
.size-bauble_sm { width: clamp(28px, 5.5vw, 42px); height: clamp(28px, 5.5vw, 42px); }
.size-bauble_md { width: clamp(38px, 7.5vw, 58px); height: clamp(38px, 7.5vw, 58px); }
.size-bauble_lg { width: clamp(48px, 9.5vw, 74px); height: clamp(48px, 9.5vw, 74px); }
.size-bauble_xl { width: clamp(58px, 11.8vw, 92px); height: clamp(58px, 11.8vw, 92px); }

/* Stil-Varianten */
.style-red { border-color: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.35), 0 4px 12px rgba(0, 0, 0, 0.5); }
.style-gold { border-color: #f59e0b; box-shadow: 0 0 12px rgba(245, 158, 11, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5); }
.style-ice { border-color: #38bdf8; box-shadow: 0 0 12px rgba(56, 189, 248, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5); }
.style-emerald { border-color: #10b981; box-shadow: 0 0 12px rgba(16, 185, 129, 0.4), 0 4px 12px rgba(0, 0, 0, 0.5); }
.style-purple { border-color: #c084fc; box-shadow: 0 0 12px rgba(192, 132, 252, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5); }
.style-star {
  border-color: #fde047;
  box-shadow: 0 0 16px rgba(253, 224, 71, 0.75), 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Weihnachtskarten am Baum */
.tree-card {
  position: relative;
  width: clamp(46px, 8.2vw, 66px);
  padding: 5px 5px 6px;
  border-radius: 8px;
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 100%);
  color: #1e293b;
  border: 2px solid #f59e0b;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
  text-align: center;
  transform-origin: top center;
}

.tree-card.style-red { border-color: #dc2626; background: linear-gradient(160deg, #fef2f2 0%, #fee2e2 100%); }
.tree-card.style-ice { border-color: #0284c7; background: linear-gradient(160deg, #f0f9ff 0%, #e0f2fe 100%); }
.tree-card.style-emerald { border-color: #059669; background: linear-gradient(160deg, #ecfdf5 0%, #d1fae5 100%); }
.tree-card.style-purple { border-color: #9333ea; background: linear-gradient(160deg, #faf5ff 0%, #f3e8ff 100%); }

.card-string {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 10px;
  background: #fde047;
}

.tree-card-thumb {
  width: 100%;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 3px;
}

.tree-card-icon {
  font-size: 1rem;
  line-height: 1.1;
}

.tree-card-title {
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Platzhalter (wartend auf Freigabe) */
.bauble-pending {
  width: clamp(32px, 6vw, 46px);
  height: clamp(32px, 6vw, 46px);
  border-radius: 50%;
  border: 2px dashed rgba(253, 224, 71, 0.75);
  background: rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fde047;
  font-weight: 700;
  font-size: 0.95rem;
  animation: pulseWait 2s ease-in-out infinite;
}

@keyframes pulseWait {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
}

.modal-preview-card {
  width: min(520px, 100%);
  text-align: center;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: #fff;
}

.floating-close {
  position: absolute;
  top: 12px;
  right: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.field-label:first-child {
  margin-top: 0;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.input-field {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.type-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.type-option {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: 0.84rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.type-option.active {
  border-color: var(--gold);
  background: rgba(245, 158, 11, 0.16);
}

.type-option .type-cost {
  display: block;
  color: var(--gold-light);
  font-weight: 700;
  margin-top: 2px;
}

.preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.live-preview-box {
  width: 100%;
  min-height: 200px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: radial-gradient(circle, #143627 0%, #091a16 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.preview-bauble {
  position: relative;
  border-radius: 50%;
  border: 4px solid #ef4444;
  background: #1e293b;
  transition: width 0.2s ease, height 0.2s ease;
}

.preview-bauble.size-bauble_sm { width: 64px; height: 64px; }
.preview-bauble.size-bauble_md { width: 88px; height: 88px; }
.preview-bauble.size-bauble_lg { width: 112px; height: 112px; }
.preview-bauble.size-bauble_xl { width: 136px; height: 136px; }

.preview-placeholder-text {
  font-size: 0.75rem;
  color: var(--muted);
}

.preview-card {
  position: relative;
  width: 180px;
  padding: 12px;
  border-radius: 10px;
  background: #fffbeb;
  color: #1e293b;
  border: 3px solid #f59e0b;
  text-align: center;
}

.card-thumb-wrap img {
  width: 100%;
  max-height: 90px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
}

.card-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.card-text {
  font-size: 0.8rem;
  color: #475569;
  word-break: break-word;
}

.pos-info {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px 0 6px;
}

.alert-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.55);
  color: #fecaca;
  font-size: 0.88rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Vergrößerte Vorschau Modal */
.preview-modal-body {
  padding-top: 8px;
}

.preview-enlarged-bauble {
  width: min(320px, 72vw);
  height: min(320px, 72vw);
  margin: 14px auto 18px;
  border-radius: 50%;
  border: 5px solid #f59e0b;
  overflow: hidden;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.55);
}

.preview-enlarged-bauble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-enlarged-card {
  margin: 12px auto 18px;
  padding: 20px;
  border-radius: 14px;
  background: linear-gradient(160deg, #fffbeb 0%, #fef3c7 100%);
  color: #1e293b;
  border: 3px solid #f59e0b;
  text-align: center;
}

.preview-enlarged-card img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.preview-enlarged-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.preview-enlarged-message {
  margin: 0 0 14px;
  font-size: 0.98rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-author {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  color: var(--muted);
}

.preview-author img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  padding: 12px 20px;
  border-radius: 10px;
  background: #0f172a;
  border: 1px solid var(--gold);
  color: #fff;
  font-size: 0.92rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.hidden {
  display: none !important;
}

