*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --border:    #222222;
  --text:      #e9e6e6;
  --muted:     #666666;
  --glow:      rgba(233, 230, 230, 0.35);
  --red:       #ff4444;
  --green:     #44ff88;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh; /* mobile browser chrome aware */
  letter-spacing: 0.01em;
  padding: 40px 24px;
}

/* ─── Card ─────────────────────────────────────────────────────────────────── */

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

/* ─── Logo ─────────────────────────────────────────────────────────────────── */

.logo {
  width: 52px;
  height: 52px;
  opacity: 0.9;
}

/* ─── Copy ─────────────────────────────────────────────────────────────────── */

.copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.copy .title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.copy .subtitle {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  transition: opacity 0.6s ease, max-height 0.6s ease;
  overflow: hidden;
  max-height: 2em;
}

.copy .subtitle.gone {
  opacity: 0;
  max-height: 0;
}

/* ─── Input ────────────────────────────────────────────────────────────────── */

.input-wrap {
  width: 100%;
}

.code-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.2em;
  text-align: center;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
  caret-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.code-input::placeholder {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  font-family: 'Inter', sans-serif;
}

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  width: 100%;
  padding: 14px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:hover  { background: var(--surface); border-color: #444; }
.btn:active { background: #1a1a1a; }

.btn.pulsing {
  animation: pulse-glow 2.6s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%   { box-shadow: 0 0 0px   0px var(--glow); border-color: #2a2a2a; }
  50%  { box-shadow: 0 0 18px 4px var(--glow);  border-color: #888;    }
  100% { box-shadow: 0 0 0px   0px var(--glow); border-color: #2a2a2a; }
}

.btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

.btn-join {
  font-size: 13px;
  background: var(--surface);
  border-color: #444;
}

/* ─── Icon copy button ─────────────────────────────────────────────────────── */

.icon-copy-btn {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  line-height: 0;
}

.icon-copy-btn:hover  { color: var(--text); }
.icon-copy-btn:active { color: var(--text); }

.icon-copy-btn.copied {
  animation: flash-green 1s ease-out forwards;
}

@keyframes flash-green {
  0%   { color: #2d9e5f; }
  60%  { color: #2d9e5f; }
  100% { color: var(--muted); }
}

/* Sparkle particles */
.sparkle {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2d9e5f;
  pointer-events: none;
  animation: sparkle-fly 0.7s ease-out forwards;
}

@keyframes sparkle-fly {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ─── Message ──────────────────────────────────────────────────────────────── */

.message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.message.error   { color: var(--red); }

/* ─── Success section ──────────────────────────────────────────────────────── */

.success-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

/* TG link block */
.tg-link-block {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tg-link-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
}

/* Row: URL text + clipboard icon */
.tg-link-row,
.referral-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0; /* prevents flex overflow */
}

.tg-link-url {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--text);
  word-break: break-all;
  text-align: left;
  line-height: 1.5;
}

/* ─── Divider ──────────────────────────────────────────────────────────────── */

.divider {
  width: 100%;
  height: 1px;
  background: var(--border);
}

/* ─── Referral block ───────────────────────────────────────────────────────── */

.referral-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.referral-url-box {
  flex: 1;
  min-width: 0;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--muted);
  word-break: break-all;
  text-align: left;
  line-height: 1.5;
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ─── Mobile ───────────────────────────────────────────────────────────────── */

@media (max-width: 400px) {
  body {
    padding: 32px 20px;
    align-items: flex-start;
    padding-top: max(60px, 15vh);
  }

  .card {
    gap: 24px;
  }

  .tg-link-url,
  .referral-url-box {
    font-size: 10px;
  }
}
