/* ===== CSS CUSTOM PROPERTIES (DESIGN TOKENS) ===== */
    :root {
      --ink-blue:      #002147;
      --ink-blue-dark: #001530;
      --ink-blue-mid:  #003070;
      --gold:          #D4AF37;
      --gold-light:    #F0D060;
      --gold-dark:     #A88B1A;
      --white:         #FFFFFF;
      --off-white:     #F5F0E8;
      --text-muted:    rgba(255,255,255,0.55);
      --card-bg:       rgba(0, 33, 71, 0.7);
      --radius-lg:     20px;
      --radius-md:     12px;
      --shadow-gold:   0 0 40px rgba(212, 175, 55, 0.18);
      --transition:    all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* ===== RESET & BASE ===== */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    html { scroll-behavior: smooth; }

    body {
      font-family: 'Poppins', sans-serif;
      background-color: var(--ink-blue-dark);
      color: var(--white);
      min-height: 100dvh;
      overflow-x: hidden;
      /* Subtle grain texture overlay */
      background-image:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(212,175,55,0.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 48, 112, 0.8) 0%, transparent 70%);
    }

    /* ===== DECORATIVE BACKGROUND PATTERN ===== */
    body::before {
      content: '';
      position: fixed;
      inset: 0;
      background-image:
        repeating-linear-gradient(
          45deg,
          transparent,
          transparent 60px,
          rgba(212,175,55,0.025) 60px,
          rgba(212,175,55,0.025) 61px
        );
      pointer-events: none;
      z-index: 0;
    }

    /* ===== LAYOUT WRAPPER ===== */
    .app-wrapper {
      position: relative;
      z-index: 1;
      max-width: 520px;
      margin: 0 auto;
      padding: 24px 16px 48px;
    }

    /* ===== HEADER ===== */
    .site-header {
      text-align: center;
      padding: 32px 0 28px;
    }

    .header-eyebrow {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: var(--gold);
      background: rgba(212,175,55,0.08);
      border: 1px solid rgba(212,175,55,0.25);
      border-radius: 100px;
      padding: 5px 14px;
      margin-bottom: 16px;
    }

    .header-eyebrow::before {
      content: '✦';
      font-size: 9px;
      opacity: 0.8;
    }

    .site-title {
      font-size: clamp(26px, 7vw, 38px);
      font-weight: 900;
      line-height: 1.1;
      letter-spacing: -0.02em;
      color: var(--white);
    }

    .site-title span {
      background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
    }

    .site-subtitle {
      margin-top: 10px;
      font-size: 13px;
      font-weight: 400;
      color: var(--text-muted);
      line-height: 1.6;
    }

    /* ===== CARD ===== */
    .card {
      background: var(--card-bg);
      border: 1px solid rgba(212,175,55,0.2);
      border-radius: var(--radius-lg);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      padding: 24px;
      margin-bottom: 16px;
      box-shadow: var(--shadow-gold), 0 8px 32px rgba(0,0,0,0.4);
    }

    .card-label {
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--gold);
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .card-label::after {
      content: '';
      flex: 1;
      height: 1px;
      background: linear-gradient(90deg, rgba(212,175,55,0.3), transparent);
    }

    /* ===== CANVAS PREVIEW ===== */
    .canvas-container {
      position: relative;
      width: 100%;
      aspect-ratio: 1 / 1;
      border-radius: var(--radius-md);
      overflow: hidden;
      background: var(--ink-blue);
      border: 1.5px solid rgba(212,175,55,0.3);
      /* Display placeholder before generation */
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .canvas-placeholder {
      text-align: center;
      padding: 24px;
      pointer-events: none;
    }

    .canvas-placeholder .placeholder-icon {
      font-size: 48px;
      margin-bottom: 12px;
      opacity: 0.5;
    }

    .canvas-placeholder p {
      font-size: 13px;
      color: var(--text-muted);
      line-height: 1.5;
    }

    /* The actual canvas element fills its container */
    #badgeCanvas {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
      transition: opacity 0.5s ease;
      border-radius: var(--radius-md);
    }

    #badgeCanvas.visible {
      opacity: 1;
    }

    /* ===== INPUT SECTION ===== */
    .input-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .input-label {
      font-size: 12px;
      font-weight: 600;
      color: var(--text-muted);
      letter-spacing: 0.05em;
    }

    .name-input {
      width: 100%;
      background: rgba(0, 21, 48, 0.8);
      border: 1.5px solid rgba(212,175,55,0.25);
      border-radius: var(--radius-md);
      color: var(--white);
      font-family: 'Poppins', sans-serif;
      font-size: 18px;
      font-weight: 600;
      padding: 14px 18px;
      outline: none;
      transition: var(--transition);
      letter-spacing: 0.02em;
    }

    .name-input::placeholder {
      color: rgba(255,255,255,0.25);
      font-weight: 400;
    }

    .name-input:focus {
      border-color: var(--gold);
      background: rgba(0, 21, 48, 1);
      box-shadow: 0 0 0 3px rgba(212,175,55,0.12);
    }

    .input-hint {
      font-size: 11px;
      color: rgba(212,175,55,0.6);
      padding-left: 2px;
    }

    /* ===== BUTTONS ===== */
    .btn-group {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 8px;
    }

    .btn {
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: none;
      border-radius: var(--radius-md);
      font-family: 'Poppins', sans-serif;
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.04em;
      cursor: pointer;
      padding: 14px 10px;
      transition: var(--transition);
      overflow: hidden;
      user-select: none;
      -webkit-user-select: none;
    }

    .btn::after {
      content: '';
      position: absolute;
      inset: 0;
      background: rgba(255,255,255,0);
      transition: background 0.2s;
    }

    .btn:active::after { background: rgba(255,255,255,0.08); }

    /* Primary — Generate */
    .btn-primary {
      background: linear-gradient(135deg, var(--gold-light), var(--gold), var(--gold-dark));
      color: var(--ink-blue-dark);
      box-shadow: 0 4px 20px rgba(212,175,55,0.35);
    }

    .btn-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 28px rgba(212,175,55,0.45);
    }

    .btn-primary:active { transform: translateY(0); }

    /* Secondary — Download */
    .btn-secondary {
      background: transparent;
      color: var(--gold);
      border: 1.5px solid var(--gold-dark);
    }

    .btn-secondary:hover {
      background: rgba(212,175,55,0.08);
      border-color: var(--gold);
      transform: translateY(-2px);
    }

    .btn-secondary:active { transform: translateY(0); }

    .btn-secondary:disabled {
      opacity: 0.35;
      cursor: not-allowed;
      transform: none;
    }

    .btn-icon { font-size: 16px; }

    /* ===== STATUS MESSAGE ===== */
    .status-bar {
      text-align: center;
      font-size: 12px;
      font-weight: 500;
      color: var(--gold);
      min-height: 20px;
      transition: opacity 0.3s;
      opacity: 0;
    }

    .status-bar.show { opacity: 1; }

    /* ===== FOOTER ===== */
    .site-footer {
      text-align: center;
      padding-top: 16px;
      font-size: 11px;
      color: rgba(255,255,255,0.25);
      line-height: 1.6;
    }

    .site-footer strong { color: rgba(212,175,55,0.5); font-weight: 600; }

    /* ===== RIPPLE ANIMATION on generate ===== */
    @keyframes pulse-ring {
      0%   { transform: scale(1);   opacity: 0.6; }
      100% { transform: scale(1.06); opacity: 0; }
    }

    .btn-primary.pulsing::before {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background: rgba(212,175,55,0.35);
      animation: pulse-ring 0.4s ease-out forwards;
    }

    /* ===== RESPONSIVE: Desktop tweaks ===== */
    @media (min-width: 480px) {
      .app-wrapper { padding: 32px 24px 64px; }
      .card { padding: 28px; }
      .btn { font-size: 15px; }
    }
