/* Crownline Defenders - Stylesheet */
    @font-face {
      font-family: 'PlexThai';
      src: url('../fonts/plex-thai-400.woff2') format('woff2');
      font-weight: 400; font-style: normal;
    }
    @font-face {
      font-family: 'PlexThai';
      src: url('../fonts/plex-thai-600.woff2') format('woff2');
      font-weight: 600; font-style: normal;
    }
    @font-face {
      font-family: 'PlexThai';
      src: url('../fonts/plex-thai-700.woff2') format('woff2');
      font-weight: 700; font-style: normal;
    }

    :root {
      --primary-gold: #f59e0b;
      --primary-cyan: #38bdf8;
      --danger-red: #ef4444;
      --success-green: #10b981;
      --bg-dark: #0f172a;
      --glass-panel: rgba(15, 23, 42, 0.90);
      --border-light: rgba(255, 255, 255, 0.2);
    }

    * {
      box-sizing: border-box;
      margin: 0; padding: 0;
      user-select: none;
      -webkit-user-select: none;
      -webkit-touch-callout: none;
    }

    html, body {
      width: 100%; height: 100%;
      margin: 0; padding: 0;
      overflow: hidden;
      background: #24421d;
      font-family: 'Prompt', 'PlexThai', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      touch-action: none;
      position: fixed; inset: 0;
    }

    #game-container {
      position: fixed; inset: 0;
      width: 100%; height: 100%;
      z-index: 1; overflow: hidden;
    }

    canvas {
      display: block;
      width: 100% !important; height: 100% !important;
      touch-action: none;
    }

    /* HUD Overlay */
    #hud {
      position: fixed; inset: 0;
      pointer-events: none;
      z-index: 10;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      padding: 8px 10px 10px 10px;
      box-sizing: border-box;
      overflow: hidden;
    }

    .top-header {
      display: flex;
      flex-direction: column;
      gap: 5px;
      width: 100%;
    }
    .top-row-1, .top-row-2 {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
    }

    .logo-box {
      display: flex;
      align-items: center;
      gap: 5px;
      flex-shrink: 0;
    }
    .logo-title {
      font-size: 15px;
      font-weight: 900;
      color: #ffd700;
      text-shadow: 0 2px 6px rgba(0,0,0,0.8), 0 0 8px rgba(255,215,0,0.4);
      letter-spacing: 0.5px;
      display: flex;
      align-items: center;
      gap: 2px;
    }
    .logo-target {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 14px; height: 14px;
    }
    .logo-target svg { width: 100%; height: 100%; }

    .icon-btn {
      pointer-events: auto;
      width: 28px; height: 28px;
      background: rgba(30, 41, 59, 0.92);
      border: 1px solid rgba(255,255,255,0.3);
      border-radius: 50%;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      backdrop-filter: blur(6px);
      transition: transform 0.1s;
      flex-shrink: 0;
    }
    .icon-btn svg { width: 14px; height: 14px; fill: #fff; }
    .icon-btn:active { transform: scale(0.92); }

    .score-badge {
      background: var(--glass-panel);
      border: 1.5px solid #f59e0b;
      color: #fbbf24;
      padding: 3px 8px;
      border-radius: 12px;
      font-size: 11px;
      font-weight: 900;
      box-shadow: 0 4px 10px rgba(0,0,0,0.6);
      display: flex;
      align-items: center;
      gap: 4px;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .score-badge svg { width: 12px; height: 12px; fill: #fbbf24; }

    .coin-badge {
      background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
      border: 2px solid #ffd700;
      color: #ffd700;
      padding: 4px 12px;
      border-radius: 14px;
      font-size: 13px;
      font-weight: 900;
      box-shadow: 0 4px 12px rgba(255, 215, 0, 0.35), 0 2px 6px rgba(0,0,0,0.7);
      display: flex;
      align-items: center;
      gap: 6px;
      white-space: nowrap;
      flex-shrink: 0;
      letter-spacing: 0.5px;
    }
    .coin-badge svg { width: 15px; height: 15px; fill: #ffd700; }

    .stage-wave-group {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-shrink: 0;
    }
    .stage-badge-btn {
      pointer-events: auto;
      background: linear-gradient(135deg, #1e40af, #3b82f6);
      border: 1px solid #93c5fd;
      color: #fff;
      padding: 3px 8px;
      border-radius: 10px;
      font-size: 9.5px;
      font-weight: 800;
      box-shadow: 0 2px 6px rgba(0,0,0,0.4);
      white-space: nowrap;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-family: inherit;
      transition: transform 0.15s;
    }
    .stage-badge-btn:hover {
      transform: scale(1.04);
      box-shadow: 0 0 10px rgba(56,189,248,0.6);
    }
    .wave-badge {
      background: var(--glass-panel);
      border: 1.5px solid #38bdf8;
      color: #fff;
      padding: 2px 6px;
      border-radius: 10px;
      font-size: 9.5px;
      font-weight: 800;
      box-shadow: 0 4px 10px rgba(0,0,0,0.6);
      display: flex;
      align-items: center;
      gap: 4px;
      white-space: nowrap;
    }
    .wave-progress-bar {
      width: 36px; height: 4px;
      background: rgba(255,255,255,0.2);
      border-radius: 2px;
      overflow: hidden;
    }
    .wave-progress-fill {
      height: 100%; width: 0%;
      background: linear-gradient(90deg, #00d2ff, #00ff88);
      transition: width 0.25s ease;
    }

    .top-right-group {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-shrink: 0;
    }
    .btn-talent {
      pointer-events: auto;
      background: linear-gradient(135deg, #059669, #10b981);
      border: 1.5px solid #a7f3d0;
      color: #fff;
      padding: 3px 7px;
      border-radius: 10px;
      font-size: 9.5px;
      font-weight: 800;
      box-shadow: 0 3px 8px rgba(16,185,129,0.5);
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 3px;
      white-space: nowrap;
      font-family: inherit;
    }
    .btn-talent svg { width: 10px; height: 10px; fill: #ffd700; }
    .btn-talent .talent-badge-count {
      background: #ef4444;
      color: #fff;
      font-size: 8px;
      padding: 0 4px;
      border-radius: 8px;
      font-weight: 900;
      border: 1px solid #fff;
    }

    .squad-chips {
      display: flex;
      gap: 3px;
      flex-shrink: 0;
    }
    .chip {
      background: rgba(15, 23, 42, 0.88);
      border: 1px solid rgba(255,255,255,0.25);
      color: #f1f5f9;
      padding: 2px 5px;
      border-radius: 6px;
      font-size: 9px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 3px;
    }
    .chip svg { width: 9px; height: 9px; fill: currentColor; }

    /* ==========================================================================
       SYNERGY HUD BAR & BADGES (v3.1.0)
       ========================================================================== */
    .synergy-hud-bar {
      display: flex;
      gap: 3px;
      align-items: center;
      margin-left: 4px;
    }
    .synergy-badge {
      display: flex;
      align-items: center;
      gap: 2px;
      padding: 2px 5px;
      border-radius: 6px;
      background: rgba(15, 23, 42, 0.85);
      border: 1px solid rgba(255, 255, 255, 0.15);
      font-size: 8.5px;
      font-weight: 700;
      color: #94a3b8;
      cursor: pointer;
      user-select: none;
      transition: all 0.25s ease;
    }
    .synergy-badge .syn-icon {
      font-size: 9px;
    }
    .synergy-badge.tier-1 {
      border-color: #38bdf8;
      color: #e0f2fe;
      background: rgba(14, 116, 144, 0.4);
      box-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
    }
    .synergy-badge.tier-2 {
      border-color: #fbbf24;
      color: #fef08a;
      background: linear-gradient(135deg, rgba(217, 119, 6, 0.45), rgba(180, 83, 9, 0.55));
      box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
      animation: synPulse 1.8s infinite alternate;
    }
    .synergy-badge.alliance-active {
      border-color: #ec4899;
      color: #fbcfe8;
      background: linear-gradient(135deg, rgba(236, 72, 153, 0.45), rgba(168, 85, 247, 0.5));
      box-shadow: 0 0 12px rgba(236, 72, 153, 0.7);
      animation: synPulse 1.5s infinite alternate;
    }
    @keyframes synPulse {
      0% { transform: scale(1); }
      100% { transform: scale(1.06); filter: brightness(1.2); }
    }

    /* Boss Alert Banner */
    #boss-alert {
      position: absolute;
      top: 85px; left: 50%;
      transform: translateX(-50%) scale(0.8);
      background: linear-gradient(90deg, rgba(220,38,38,0.95), rgba(153,27,27,0.95));
      border: 2px solid #f87171;
      color: #fff;
      padding: 5px 16px;
      border-radius: 18px;
      font-size: 12px;
      font-weight: 900;
      text-shadow: 0 2px 4px #000;
      box-shadow: 0 0 20px rgba(239,68,68,0.8);
      opacity: 0;
      pointer-events: none;
      transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      white-space: nowrap;
      z-index: 20;
    }
    #boss-alert.show {
      opacity: 1;
      transform: translateX(-50%) scale(1);
    }

    /* Floating In-Game Toast Message */
    #toast-msg {
      position: absolute;
      top: 125px; left: 50%;
      transform: translateX(-50%);
      background: var(--glass-panel);
      border: 1.5px solid #ffd700;
      color: #ffd700;
      padding: 4px 14px;
      border-radius: 14px;
      font-size: 11px;
      font-weight: 700;
      opacity: 0;
      transition: opacity 0.25s;
      pointer-events: none;
      z-index: 15;
      white-space: nowrap;
    }

    /* Virtual Joystick Overlay */
    #joystick-zone {
      position: absolute;
      bottom: 12px; left: 10px;
      width: 105px; height: 105px;
      pointer-events: auto;
      z-index: 12;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
    }
    #joystick-base {
      width: 90px; height: 90px;
      background: radial-gradient(circle, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 70%, rgba(255,255,255,0.28) 100%);
      border: 2px solid rgba(255,255,255,0.45);
      border-radius: 50%;
      position: relative;
      box-shadow: 0 4px 15px rgba(0,0,0,0.5);
      pointer-events: auto;
      touch-action: none;
    }
    #joystick-stick {
      width: 40px; height: 40px;
      background: radial-gradient(circle, #ffffff 0%, #94a3b8 100%);
      border: 2px solid #fff;
      border-radius: 50%;
      position: absolute;
      top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0 3px 8px rgba(0,0,0,0.6);
      pointer-events: none;
    }
    .dock-label {
      position: absolute;
      bottom: -2px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 9px;
      font-weight: 800;
      color: rgba(255,255,255,0.72);
      pointer-events: none;
      text-shadow: 0 1px 2px #000;
    }
    #aim-zone {
      position: absolute;
      bottom: 12px;
      right: 10px;
      width: 105px;
      height: 105px;
      z-index: 12;
      display: flex;
      align-items: center;
      justify-content: center;
      touch-action: none;
      pointer-events: auto;
    }
    #aim-base {
      width: 90px;
      height: 90px;
      background: radial-gradient(circle, rgba(56,189,248,0.22) 0%, rgba(15,23,42,0.2) 70%, rgba(56,189,248,0.35) 100%);
      border: 2px solid rgba(125,211,252,0.7);
      border-radius: 50%;
      position: relative;
      box-shadow: 0 4px 15px rgba(0,0,0,0.5);
      touch-action: none;
    }
    #aim-stick {
      width: 40px;
      height: 40px;
      background: radial-gradient(circle, #e0f2fe 0%, #0284c7 100%);
      border: 2px solid #fff;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      pointer-events: none;
    }
    .btn-tactile {
      pointer-events: auto;
      position: absolute;
      width: 52px;
      height: 52px;
      border-radius: 50%;
      border: 2px solid #64748b;
      background: rgba(15, 23, 42, 0.88);
      color: #fff;
      z-index: 16;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-family: inherit;
      cursor: pointer;
      touch-action: manipulation;
    }
    .btn-tactile.ready {
      border-color: #38bdf8;
      box-shadow: 0 0 12px rgba(56,189,248,0.65);
    }
    #btn-dash { right: 124px; bottom: 78px; }
    #btn-emp { right: 124px; bottom: 16px; }
    .tact-icon { font-size: 16px; line-height: 1; pointer-events: none; }
    .tact-text { font-size: 8px; font-weight: 900; pointer-events: none; }
    .btn-ultimate { right: 186px; bottom: 36px; }

    .bottom-bar {
      display: flex;
      justify-content: flex-end;
      align-items: flex-end;
      width: 100%;
      padding-bottom: 2px;
    }
    .tips-box {
      background: var(--glass-panel);
      padding: 4px 8px;
      border-radius: 8px;
      color: #94a3b8;
      font-size: 8.5px;
      border: 1px solid rgba(255,255,255,0.18);
      text-align: right;
      max-width: 150px;
      line-height: 1.3;
      box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    }
    .ad-tag {
      font-size: 7.5px;
      color: rgba(255,255,255,0.45);
      margin-top: 2px;
    }

    /* Modal Overlay & Cards */
    .modal-overlay {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.85);
      backdrop-filter: blur(8px);
      z-index: 200;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }
    .modal-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-card {
      background: linear-gradient(180deg, #1e293b, #0f172a);
      border: 2px solid #38bdf8;
      border-radius: 20px;
      padding: 16px;
      width: 90%;
      max-width: 360px;
      text-align: center;
      box-shadow: 0 10px 30px rgba(0,0,0,0.9), 0 0 20px rgba(56,189,248,0.3);
      color: #fff;
      max-height: 88vh;
      overflow-y: auto;
    }
    .modal-card h2 {
      font-size: 18px;
      margin-bottom: 3px;
      color: #ffd700;
      text-shadow: 0 2px 6px rgba(0,0,0,0.6);
      font-weight: 900;
    }
    .modal-subtitle {
      font-size: 10.5px;
      color: #94a3b8;
      margin-bottom: 8px;
    }

    /* Stage Cards in Map */
    .stage-card {
      background: rgba(30, 41, 59, 0.9);
      border: 1.5px solid rgba(255,255,255,0.16);
      border-radius: 12px;
      padding: 9px 10px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      transition: border-color 0.2s, transform 0.2s;
    }
    .stage-card.cleared {
      border-color: #f59e0b;
      background: linear-gradient(180deg, rgba(30,41,59,0.95), rgba(15,23,42,0.95));
    }
    .stage-card.current {
      border-color: #38bdf8;
      box-shadow: 0 0 12px rgba(56,189,248,0.45);
      background: linear-gradient(180deg, rgba(30,58,138,0.35), rgba(15,23,42,0.95));
    }
    .stage-card.locked {
      opacity: 0.55;
      border-color: rgba(255,255,255,0.08);
      background: rgba(15, 23, 42, 0.85);
    }
    .stage-card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .stage-card-title {
      font-size: 11.5px;
      font-weight: 900;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 5px;
    }
    .stage-card-stars {
      color: #facc15;
      font-size: 11px;
      letter-spacing: 1px;
      font-weight: 900;
    }
    .stage-card-desc {
      font-size: 9px;
      color: #94a3b8;
      line-height: 1.3;
    }
    .stage-card-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 8.5px;
      color: #cbd5e1;
      padding-top: 4px;
      border-top: 1px solid rgba(255,255,255,0.1);
    }
    .stage-boss-pill {
      background: rgba(220, 38, 38, 0.25);
      border: 1px solid #ef4444;
      color: #fca5a5;
      padding: 1px 5px;
      border-radius: 6px;
      font-weight: 800;
    }
    .btn-stage-action {
      font-family: inherit;
      font-size: 9.5px;
      font-weight: 800;
      padding: 4px 8px;
      border-radius: 8px;
      cursor: pointer;
      white-space: nowrap;
      border: none;
      transition: transform 0.1s;
    }
    .btn-stage-action:active { transform: scale(0.94); }
    .btn-stage-action.play {
      background: linear-gradient(180deg, #0284c7, #0369a1);
      border: 1px solid #38bdf8;
      color: #fff;
    }
    .btn-stage-action.replay {
      background: linear-gradient(180deg, #d97706, #b45309);
      border: 1px solid #fbbf24;
      color: #fff;
    }
    .btn-stage-action:disabled {
      background: #334155;
      border: 1px solid #475569;
      color: #64748b;
      cursor: not-allowed;
    }

    /* Talent Grid */
    .talent-grid {
      display: flex;
      flex-direction: column;
      gap: 6px;
      margin: 8px 0;
      text-align: left;
    }
    .talent-item {
      background: rgba(30, 41, 59, 0.88);
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 10px;
      padding: 6px 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
    }
    .talent-info { flex: 1; }
    .talent-name {
      font-size: 10.5px;
      font-weight: 800;
      color: #fff;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .talent-desc {
      font-size: 8.5px;
      color: #94a3b8;
      margin-top: 1px;
      line-height: 1.2;
    }
    .talent-level {
      font-size: 9px;
      font-weight: 800;
      color: #38bdf8;
    }
    .btn-upgrade-talent {
      background: linear-gradient(180deg, #10b981, #059669);
      border: 1px solid #6ee7b7;
      color: #fff;
      padding: 4px 6px;
      border-radius: 6px;
      font-size: 9px;
      font-weight: 800;
      cursor: pointer;
      white-space: nowrap;
      font-family: inherit;
    }
    .btn-upgrade-talent:disabled {
      background: #475569;
      border-color: #64748b;
      color: #94a3b8;
      cursor: not-allowed;
    }

    .talent-header-points {
      background: rgba(16, 185, 129, 0.2);
      border: 1.5px solid #10b981;
      padding: 4px 8px;
      border-radius: 10px;
      font-size: 11px;
      font-weight: 800;
      color: #6ee7b7;
      margin-bottom: 6px;
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }

    .modal-stats {
      background: rgba(0,0,0,0.4);
      border-radius: 12px;
      padding: 8px 12px;
      margin: 10px 0;
      font-size: 11px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      text-align: left;
    }
    .modal-stats div {
      display: flex;
      justify-content: space-between;
      color: #94a3b8;
    }
    .modal-stats span:last-child {
      font-weight: 800;
      color: #fff;
    }

    .modal-actions {
      display: flex;
      gap: 6px;
      margin-top: 10px;
    }
    .btn-main {
      background: linear-gradient(180deg, #0284c7, #0369a1);
      border: 2px solid #38bdf8;
      color: #fff;
      padding: 7px 12px;
      border-radius: 18px;
      font-size: 12px;
      font-weight: 800;
      cursor: pointer;
      box-shadow: 0 4px 12px rgba(2,132,199,0.5);
      flex: 1;
      font-family: inherit;
    }
    .btn-main:active { transform: scale(0.96); }
    .btn-secondary {
      background: rgba(51, 65, 85, 0.9);
      border: 1.5px solid rgba(255,255,255,0.25);
      color: #cbd5e1;
      padding: 7px 12px;
      border-radius: 18px;
      font-size: 11px;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
    }

    
    /* King's Ultimate Ability Button */
    .btn-ultimate {
      pointer-events: auto;
      position: absolute;
      bottom: 36px;
      right: 186px;
      width: 58px;
      height: 58px;
      background: linear-gradient(135deg, #1e293b, #0f172a);
      border: 2px solid #64748b;
      border-radius: 50%;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 14px rgba(0,0,0,0.6);
      overflow: hidden;
      transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
      z-index: 15;
    }
    .btn-ultimate:active {
      transform: scale(0.92);
    }
    .btn-ultimate.ready {
      border-color: #ffd700;
      box-shadow: 0 0 18px rgba(255, 215, 0, 0.8), inset 0 0 10px rgba(255, 215, 0, 0.5);
      animation: ultPulse 1.2s infinite alternate;
    }
    @keyframes ultPulse {
      0% { transform: scale(1); box-shadow: 0 0 12px rgba(255,215,0,0.6); }
      100% { transform: scale(1.08); box-shadow: 0 0 22px rgba(255,215,0,0.95); }
    }
    .ult-fill {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      width: 100%;
      height: 0%;
      background: linear-gradient(180deg, #f59e0b, #d97706);
      opacity: 0.45;
      transition: height 0.2s ease;
      pointer-events: none;
    }
    .btn-ultimate.ready .ult-fill {
      background: linear-gradient(180deg, #ffd700, #f59e0b);
      opacity: 0.8;
    }
    .ult-content {
      position: relative;
      z-index: 2;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      pointer-events: none;
    }
    .ult-icon {
      font-size: 17px;
      line-height: 1;
    }
    .ult-text {
      font-size: 8px;
      font-weight: 900;
      color: #fff;
      margin-top: 1px;
    }

    /* 2D Floating Damage Popup */
    #damage-text-layer {
      position: fixed; inset: 0;
      pointer-events: none;
      z-index: 11;
      overflow: hidden;
    }
    .dmg-popup {
      position: absolute;
      font-size: 13px;
      font-weight: 900;
      color: #fff;
      text-shadow: 0 1px 3px #000, 0 0 6px rgba(255,50,50,0.8);
      transform: translate(-50%, -50%);
      animation: floatUp 0.65s cubic-bezier(0.25, 1, 0.5, 1) forwards;
      pointer-events: none;
      font-family: inherit;
    }
    .dmg-popup.crit {
      font-size: 16px;
      color: #ffea00;
      text-shadow: 0 1px 4px #000, 0 0 10px #ff3b30;
    }
    @keyframes floatUp {
      0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
      30% { transform: translate(-50%, -16px) scale(1.15); }
      100% { opacity: 0; transform: translate(-50%, -32px) scale(0.85); }
    }

    /* Tactical Formation Switcher */
    .formation-selector {
      position: fixed;
      bottom: 96px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      gap: 6px;
      padding: 4px 6px;
      background: rgba(15, 23, 42, 0.88);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 20px;
      backdrop-filter: blur(8px);
      z-index: 14;
      pointer-events: auto;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    }
    .btn-formation {
      background: rgba(30, 41, 59, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 14px;
      padding: 4px 8px;
      display: flex;
      align-items: center;
      gap: 4px;
      color: #94a3b8;
      cursor: pointer;
      font-size: 11px;
      font-family: inherit;
      font-weight: 600;
      transition: all 0.15s ease;
      white-space: nowrap;
    }
    .btn-formation .f-icon {
      font-size: 13px;
    }
    .btn-formation .f-label {
      font-size: 11px;
    }
    .btn-formation:hover {
      background: rgba(51, 65, 85, 0.9);
      color: #e2e8f0;
    }
    .btn-formation.active {
      background: linear-gradient(135deg, rgba(245, 158, 11, 0.9), rgba(217, 119, 6, 0.9));
      border-color: #fde047;
      color: #ffffff;
      font-weight: 800;
      box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
      transform: scale(1.04);
    }
    .btn-formation:active {
      transform: scale(0.95);
    }

    /* Roguelite Relic Selection Card */
    .relic-card {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      background: rgba(30, 41, 59, 0.95);
      border: 1.5px solid rgba(255, 255, 255, 0.18);
      border-radius: 12px;
      cursor: pointer;
      text-align: left;
      transition: all 0.18s cubic-bezier(0.25, 1, 0.5, 1);
      box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    }
    .relic-card:hover {
      background: rgba(51, 65, 85, 0.98);
      border-color: #f59e0b;
      transform: translateY(-2px) scale(1.01);
      box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
    }
    .relic-card:active {
      transform: scale(0.98);
    }
    .relic-icon-box {
      width: 42px;
      height: 42px;
      flex-shrink: 0;
      border-radius: 10px;
      background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.15));
      border: 1px solid rgba(245, 158, 11, 0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 22px;
    }
    .relic-info {
      display: flex;
      flex-direction: column;
      gap: 3px;
      flex: 1;
    }
    .relic-name {
      font-size: 13.5px;
      font-weight: 700;
      color: #ffd700;
    }
    .relic-desc {
      font-size: 11px;
      color: #cbd5e1;
      line-height: 1.4;
    }
    .relic-badge {
      font-size: 9px;
      font-weight: 800;
      padding: 2px 6px;
      border-radius: 6px;
      text-transform: uppercase;
      align-self: flex-start;
      margin-top: 2px;
    }
    .relic-badge.combat { background: rgba(239, 68, 68, 0.25); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.5); }
    .relic-badge.defense { background: rgba(56, 189, 248, 0.25); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.5); }
    .relic-badge.utility { background: rgba(52, 211, 153, 0.25); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.5); }
    .relic-badge.economy { background: rgba(251, 191, 36, 0.25); color: #fde047; border: 1px solid rgba(251, 191, 36, 0.5); }

    /* Online Leaderboard Modal UI */
    .leaderboard-tabs {
      display: flex;
      gap: 8px;
      margin: 8px 0 10px 0;
    }
    .tab-btn {
      flex: 1;
      padding: 7px 10px;
      background: rgba(30, 41, 59, 0.85);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 8px;
      color: #94a3b8;
      font-size: 12px;
      font-weight: 700;
      font-family: inherit;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .tab-btn:hover {
      background: rgba(51, 65, 85, 0.95);
      color: #f1f5f9;
    }
    .tab-btn.active {
      background: linear-gradient(180deg, #f59e0b, #d97706);
      border-color: #fde047;
      color: #ffffff;
      box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
    }
    .player-profile-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 10px;
      background: rgba(15, 23, 42, 0.7);
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 8px;
      margin-bottom: 8px;
      font-size: 11.5px;
      color: #cbd5e1;
    }
    .btn-xs {
      background: rgba(56, 189, 248, 0.2);
      border: 1px solid rgba(56, 189, 248, 0.5);
      color: #38bdf8;
      border-radius: 6px;
      padding: 3px 8px;
      font-size: 10px;
      font-weight: 700;
      cursor: pointer;
      font-family: inherit;
    }
    .btn-xs:hover {
      background: rgba(56, 189, 248, 0.4);
      color: #fff;
    }
    .leaderboard-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 50vh;
      overflow-y: auto;
      margin: 8px 0 14px 0;
    }
    .leaderboard-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 10px;
      background: rgba(30, 41, 59, 0.75);
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 8px;
      font-size: 12px;
      text-align: left;
    }
    .leaderboard-row.rank-1 {
      background: linear-gradient(90deg, rgba(245, 158, 11, 0.22), rgba(30, 41, 59, 0.85));
      border-color: rgba(245, 158, 11, 0.6);
    }
    .leaderboard-row.rank-2 {
      background: linear-gradient(90deg, rgba(226, 232, 240, 0.18), rgba(30, 41, 59, 0.85));
      border-color: rgba(226, 232, 240, 0.5);
    }
    .leaderboard-row.rank-3 {
      background: linear-gradient(90deg, rgba(217, 119, 6, 0.18), rgba(30, 41, 59, 0.85));
      border-color: rgba(217, 119, 6, 0.5);
    }
    .lb-rank {
      font-size: 12px;
      font-weight: 800;
      color: #94a3b8;
      width: 32px;
      flex-shrink: 0;
    }
    .rank-1 .lb-rank { color: #fde047; font-size: 13px; }
    .rank-2 .lb-rank { color: #e2e8f0; font-size: 13px; }
    .rank-3 .lb-rank { color: #fbbf24; font-size: 13px; }
    .lb-name-box {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 1px;
      overflow: hidden;
    }
    .lb-name {
      font-weight: 700;
      color: #f8fafc;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .lb-meta {
      font-size: 9.5px;
      color: #94a3b8;
    }
    .lb-score {
      font-size: 13px;
      font-weight: 900;
      color: #4ade80;
      flex-shrink: 0;
    }

    /* Main Menu Screen UI */
    .main-menu-screen {
      position: fixed;
      inset: 0;
      width: 100%;
      height: 100%;
      z-index: 100;
      display: none;
      align-items: center;
      justify-content: center;
      background: radial-gradient(circle at center, rgba(15, 23, 42, 0.78) 0%, rgba(2, 6, 23, 0.94) 100%);
      backdrop-filter: blur(10px);
      padding: 12px 10px;
      box-sizing: border-box;
      pointer-events: auto;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    .main-menu-screen.active {
      display: flex;
      animation: fadeInMenu 0.3s ease-out forwards;
    }
    @keyframes fadeInMenu {
      from { opacity: 0; transform: scale(0.96); }
      to { opacity: 1; transform: scale(1); }
    }
    .main-menu-card {
      width: 100%;
      max-width: 440px;
      margin: auto;
      max-height: min(94vh, 740px);
      overflow-y: auto;
      background: rgba(15, 23, 42, 0.94);
      border: 1.5px solid rgba(245, 158, 11, 0.45);
      border-radius: 18px;
      padding: 14px 16px 12px 16px;
      box-shadow: 0 10px 32px rgba(0,0,0,0.85), 0 0 24px rgba(245, 158, 11, 0.2);
      display: flex;
      flex-direction: column;
      gap: 8px;
      text-align: center;
      scrollbar-width: thin;
      scrollbar-color: rgba(245, 158, 11, 0.4) transparent;
    }
    .main-menu-card::-webkit-scrollbar {
      width: 5px;
    }
    .main-menu-card::-webkit-scrollbar-thumb {
      background: rgba(245, 158, 11, 0.4);
      border-radius: 4px;
    }
    .menu-header {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 2px;
    }
    .menu-crown {
      font-size: 22px;
      filter: drop-shadow(0 2px 8px rgba(255, 215, 0, 0.6));
      animation: crownFloat 2s infinite ease-in-out;
    }
    @keyframes crownFloat {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-5px); }
    }
    .menu-title {
      font-size: 22px;
      font-weight: 900;
      color: #ffd700;
      letter-spacing: 1px;
      text-shadow: 0 2px 8px rgba(0,0,0,0.9), 0 0 12px rgba(255,215,0,0.5);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 2px;
    }
    /* ---- Brand lockup (final concept C "Vanguard Chevron") ----
       Size rules from the brand pack: Thai lockup only when >= 480px wide,
       English wordmark >= 240px, below that the badge alone. */
    .brand-lockup { display: flex; justify-content: center; align-items: center; margin: 2px 0; }
    .brand-lockup img { display: none; height: auto; max-width: none; }
    .brand-lockup .brand-wordmark-en { display: block; width: 260px; }
    .menu-thai-name {
      font-size: 12px;
      font-weight: 800;
      color: #22D3EE;
      margin: 3px 0 1px;
    }
    @media (max-width: 299px) { /* card too narrow for a 240px wordmark */
      .brand-lockup .brand-wordmark-en { display: none; }
      .brand-lockup .brand-badge { display: block; width: 64px; }
    }
    @media (min-width: 1024px) and (min-height: 720px) { /* room for the 480px Thai lockup */
      .main-menu-card { max-width: 560px; }
      .brand-lockup .brand-wordmark-en { display: none; }
      .brand-lockup .brand-wordmark-th { display: block; width: 480px; }
      .menu-thai-name { display: none; } /* already in the Thai lockup */
    }
    /* HUD: badge on phones/tablets, English wordmark (240px) on wide screens */
    .logo-title .hud-badge { display: block; width: 28px; height: 28px; }
    .logo-title .hud-wordmark { display: none; }
    @media (min-width: 1024px) {
      .logo-title .hud-badge { display: none; }
      .logo-title .hud-wordmark { display: block; width: 240px; height: auto; }
    }
    .menu-tagline {
      font-size: 9px;
      font-weight: 800;
      color: #38bdf8;
      letter-spacing: 0.8px;
    }
    .menu-profile-box {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 7px 12px;
      background: rgba(30, 41, 59, 0.85);
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 10px;
      font-size: 11.5px;
      color: #cbd5e1;
    }
    .menu-profile-info {
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .menu-profile-stats {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 11px;
      color: #facc15;
    }
    .menu-btn-group {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .btn-menu {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      background: rgba(30, 41, 59, 0.9);
      border: 1px solid rgba(255, 255, 255, 0.15);
      border-radius: 12px;
      cursor: pointer;
      color: #f1f5f9;
      text-align: left;
      font-family: inherit;
      transition: all 0.15s ease;
      box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    }
    .btn-menu:hover {
      background: rgba(51, 65, 85, 0.98);
      border-color: #38bdf8;
      transform: translateX(4px);
    }
    .btn-menu:active {
      transform: scale(0.98);
    }
    .btn-menu .m-icon {
      font-size: 20px;
      width: 28px;
      text-align: center;
      flex-shrink: 0;
    }
    .btn-menu .m-text {
      display: flex;
      flex-direction: column;
      gap: 1px;
    }
    .btn-menu .m-text b {
      font-size: 13.5px;
      font-weight: 800;
    }
    .btn-menu .m-text small {
      font-size: 10px;
      color: #94a3b8;
    }
    .btn-menu-play {
      background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
      border-color: #fde047;
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
    }
    .btn-menu-play:hover {
      background: linear-gradient(135deg, #fbbf24, #d97706);
      border-color: #ffffff;
      transform: translateX(4px) scale(1.02);
    }
    .btn-menu-continue {
      background: linear-gradient(135deg, rgba(16, 185, 129, 0.9), rgba(5, 150, 105, 0.9));
      border-color: #34d399;
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    }
    .btn-menu-continue:hover {
      background: linear-gradient(135deg, #34d399, #059669);
      transform: translateX(4px) scale(1.02);
    }
    .menu-footer {
      font-size: 9.5px;
      color: #64748b;
      margin-top: 4px;
    }

    /* Stats Grid */
    .stat-card {
      background: rgba(30, 41, 59, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 10px;
      padding: 10px 8px;
      text-align: center;
      display: flex;
      flex-direction: column;
      gap: 3px;
    }
    .stat-card-title {
      font-size: 10px;
      color: #94a3b8;
      font-weight: 700;
    }
    .stat-card-val {
      font-size: 16px;
      font-weight: 900;
    }

    /* Guide items */
    .guide-scroll-container {
      display: flex;
      flex-direction: column;
      gap: 10px;
      max-height: 58vh;
      overflow-y: auto;
      margin: 12px 0;
    }
    .guide-item {
      background: rgba(30, 41, 59, 0.8);
      border: 1px solid rgba(255, 255, 255, 0.1);
      border-radius: 10px;
      padding: 10px 12px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      font-size: 11.5px;
      line-height: 1.5;
    }
    .guide-item-header {
      font-size: 12.5px;
      font-weight: 800;
      color: #ffd700;
    }
    .guide-item-body {
      color: #cbd5e1;
    }

    /* Mode Selection Cards */
    .mode-select-btn {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 14px;
      background: rgba(30, 41, 59, 0.95);
      border: 1.5px solid rgba(255, 255, 255, 0.16);
      border-radius: 14px;
      cursor: pointer;
      text-align: left;
      transition: all 0.18s cubic-bezier(0.25, 1, 0.5, 1);
      box-shadow: 0 4px 10px rgba(0,0,0,0.3);
      font-family: inherit;
    }
    .mode-select-btn:hover {
      background: rgba(51, 65, 85, 0.98);
      border-color: #ffd700;
      transform: translateY(-2px) scale(1.01);
      box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35);
    }
    .mode-select-btn:active {
      transform: scale(0.98);
    }
    .mode-icon-box {
      width: 44px;
      height: 44px;
      flex-shrink: 0;
      border-radius: 12px;
      border: 1px solid rgba(255, 255, 255, 0.25);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
    }
    .mode-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      flex: 1;
    }
    .mode-title {
      font-size: 14px;
      font-weight: 800;
      color: #ffd700;
    }
    .mode-desc {
      font-size: 11px;
      color: #cbd5e1;
      line-height: 1.35;
    }
    .mode-tag {
      font-size: 9px;
      font-weight: 800;
      padding: 2px 6px;
      border-radius: 6px;
      align-self: flex-start;
      margin-top: 3px;
    }

    /* Responsive PC & Large Screen Optimization */
    @media (min-width: 768px) {
      #hud {
        padding: 16px 22px 20px 22px;
      }
      .top-header {
        gap: 12px;
      }
      .logo-title {
        font-size: 20px;
        letter-spacing: 0.8px;
      }
      .logo-target {
        width: 18px;
        height: 18px;
      }
      .icon-btn {
        width: 38px;
        height: 38px;
      }
      .icon-btn svg {
        width: 18px;
        height: 18px;
      }
      .score-badge {
        font-size: 15px;
        padding: 6px 14px;
        border-radius: 16px;
        gap: 6px;
      }
      .score-badge svg {
        width: 16px;
        height: 16px;
      }
      .coin-badge {
        font-size: 19px;
        padding: 8px 20px;
        border-radius: 18px;
        border-width: 2.5px;
        gap: 10px;
        box-shadow: 0 4px 18px rgba(255, 215, 0, 0.45);
      }
      .coin-badge svg {
        width: 22px;
        height: 22px;
      }
      .stage-wave-group {
        gap: 8px;
      }
      .stage-badge-btn {
        font-size: 13px;
        padding: 6px 14px;
        border-radius: 14px;
        gap: 6px;
      }
      .wave-badge {
        font-size: 13px;
        padding: 5px 12px;
        border-radius: 14px;
        gap: 8px;
      }
      .wave-progress-bar {
        width: 55px;
        height: 6px;
        border-radius: 3px;
      }
      .btn-talent {
        font-size: 13px;
        padding: 6px 14px;
        border-radius: 14px;
        gap: 6px;
      }
      .btn-talent svg {
        width: 14px;
        height: 14px;
      }
      .btn-talent .talent-badge-count {
        font-size: 11px;
        padding: 1px 6px;
        border-radius: 10px;
      }
      .squad-chips {
        gap: 6px;
      }
      .chip {
        font-size: 13px;
        padding: 5px 10px;
        border-radius: 10px;
        gap: 5px;
      }
      .chip svg {
        width: 14px;
        height: 14px;
      }
      #btn-ultimate {
        width: 64px;
        height: 64px;
        bottom: 48px;
        right: 200px;
      }
      #aim-zone, #joystick-zone {
        width: 120px;
        height: 120px;
      }
      #btn-dash { right: 140px; bottom: 96px; width: 58px; height: 58px; }
      #btn-emp { right: 140px; bottom: 24px; width: 58px; height: 58px; }
      #ult-icon svg {
        width: 34px;
        height: 34px;
      }
      #ult-text {
        font-size: 13px;
      }
      .formation-selector {
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        gap: 10px;
        padding: 6px 12px;
        border-radius: 24px;
        background: rgba(15, 23, 42, 0.94);
        border: 1.5px solid rgba(255, 255, 255, 0.28);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
      }
      .btn-formation {
        padding: 8px 14px;
        border-radius: 12px;
        font-size: 13px;
      }
      .btn-formation .f-icon {
        font-size: 16px;
      }
      .btn-formation .f-label {
        font-size: 12px;
      }
      #toast-msg {
        font-size: 15px;
        padding: 10px 22px;
        border-radius: 16px;
        top: 85px;
      }
      #boss-alert {
        font-size: 16px;
        padding: 8px 26px;
        top: 100px;
      }
    }


/* ==========================================================================
   HERO COMMANDER SELECTOR & TROOP COUNTER STYLES (PHASE 1)
   ========================================================================== */
.menu-hero-select-card {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 8px 10px;
  margin: 2px 0 4px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.menu-section-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 5px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.hero-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.hero-card-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1.5px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 4px 2px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.hero-card-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(245, 158, 11, 0.6);
  transform: translateY(-2px);
}

.hero-card-btn.active {
  background: linear-gradient(145deg, rgba(30, 58, 138, 0.9), rgba(59, 130, 246, 0.4));
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
  transform: translateY(-2px);
}

.hero-avatar {
  font-size: 1.15rem;
  line-height: 1;
}

.hero-card-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-card-meta b {
  font-size: 0.70rem;
  color: #ffffff;
}

.tag-infantry { color: #38bdf8; font-size: 0.72rem; }
.tag-archer { color: #4ade80; font-size: 0.72rem; }
.tag-cavalry { color: #fbbf24; font-size: 0.72rem; }

.hero-perk-box {
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  border-left: 3px solid #ffd700;
}

/* In-game Tactical HUD Badge */
.tactical-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transition: transform 0.15s ease;
  user-select: none;
}

.tactical-badge:hover {
  transform: scale(1.05);
  border-color: #ffd700;
}

.hud-troop-tag {
  font-weight: 700;
  font-size: 0.78rem;
  color: #38bdf8;
}

.hud-counter-hint {
  font-size: 0.72rem;
  color: #fcd34d;
  font-weight: 600;
}

/* Troop Guide Modal */
.troop-guide-card {
  max-width: 520px;
  width: 92%;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  border: 2px solid #ffd700;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(245, 158, 11, 0.25);
  padding: 18px;
  color: #f8fafc;
}

.counter-diagram-flex {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 8px;
  margin: 14px 0 18px 0;
}

.c-node {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.c-node.node-inf { border-color: #38bdf8; background: rgba(30, 58, 138, 0.3); }
.c-node.node-arc { border-color: #4ade80; background: rgba(6, 78, 59, 0.3); }
.c-node.node-cav { border-color: #fbbf24; background: rgba(120, 53, 15, 0.3); }

.cn-icon { font-size: 1.8rem; }
.cn-edge { font-size: 0.72rem; color: #ffd700; font-weight: 700; }

.troop-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.troop-matrix-table th {
  background: rgba(51, 65, 85, 0.8);
  color: #ffd700;
  padding: 8px;
  text-align: left;
  border-bottom: 2px solid rgba(245, 158, 11, 0.4);
}

.troop-matrix-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================================
   HERO HUD STATUS CARD (Phase 1 — GAP 2)
   แสดงแม่ทัพ + สายทหาร + counter indicator บน HUD ระหว่างต่อสู้
   ============================================================ */
.hud-hero-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(15,23,42,0.92) 0%, rgba(30,41,59,0.95) 100%);
  border: 1px solid rgba(251,191,36,0.35);
  border-radius: 10px;
  padding: 4px 9px 4px 6px;
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  min-width: 120px;
  cursor: default;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.hud-hero-status.advantage {
  border-color: rgba(56,189,248,0.7);
  box-shadow: 0 0 12px rgba(56,189,248,0.35), 0 2px 12px rgba(0,0,0,0.45);
}
.hud-hero-status.disadvantage {
  border-color: rgba(239,68,68,0.7);
  box-shadow: 0 0 12px rgba(239,68,68,0.3), 0 2px 12px rgba(0,0,0,0.45);
}
.hud-hero-avatar {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.2));
}
.hud-hero-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.hud-hero-name {
  font-size: 10px;
  font-weight: 700;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.hud-troop-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hud-troop-badge {
  font-size: 9px;
  font-weight: 600;
  color: #94a3b8;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}
.hud-counter-indicator {
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.3s, opacity 0.3s;
  opacity: 0;
}
.hud-counter-indicator.visible {
  opacity: 1;
}
.hud-counter-indicator.advantage { color: #38bdf8; }
.hud-counter-indicator.disadvantage { color: #ef4444; }

    .menu-sub-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
    }
    .menu-sub-grid .btn-menu {
      padding: 7px 10px;
      gap: 6px;
      border-radius: 10px;
    }
    .menu-sub-grid .btn-menu .m-icon {
      font-size: 15px;
      width: 20px;
    }
    .menu-sub-grid .btn-menu .m-text b {
      font-size: 11px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .menu-sub-grid .btn-menu .m-text small {
      display: none;
    }

/* Screen-Space Boss Health Bar (Top HUD) */
#boss-hud-bar-container {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: min(92vw, 420px);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 6px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65), 0 0 16px rgba(245, 158, 11, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 25;
}
#boss-hud-bar-container.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.boss-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 800;
}
.boss-hud-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fbbf24;
}
.boss-hud-name {
  color: #f8fafc;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px #000;
}
.boss-hud-hp-text {
  font-size: 11px;
  font-weight: 700;
  color: #fca5a5;
  font-variant-numeric: tabular-nums;
}
.boss-hud-bar-track {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(30, 41, 59, 0.95);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.boss-hud-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #dc2626, #b91c1c);
  border-radius: 5px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}
.boss-hud-bar-ghost {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: rgba(254, 202, 202, 0.35);
  border-radius: 5px;
  transition: width 0.5s ease-out;
}

/* ==========================================================================
   ASCENDED RELIC EVOLUTION STYLES
   ========================================================================== */
.relic-card.evolution-card {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(239, 68, 68, 0.28)) !important;
  border: 2px solid #fbbf24 !important;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.5), inset 0 0 12px rgba(251, 191, 36, 0.3) !important;
  animation: evoCardPulse 1.8s infinite alternate ease-in-out;
}

@keyframes evoCardPulse {
  0% { transform: scale(1.0); box-shadow: 0 0 16px rgba(245, 158, 11, 0.4); }
  100% { transform: scale(1.02); box-shadow: 0 0 26px rgba(245, 158, 11, 0.75); }
}

.relic-badge.ascended {
  background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  border: 1px solid #fef08a !important;
}

/* ==========================================================================
   ROYAL CITADEL & IDLE ECONOMY STYLES
   ========================================================================== */
.citadel-treasury-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(192, 132, 252, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 10px 0 14px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.treasury-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: #cbd5e1;
}

.treasury-item .t-value {
  color: #ffd700;
  font-size: 1.1rem;
  font-weight: 700;
}

.treasury-item.idle-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.t-idle {
  color: #4ade80;
  font-weight: 700;
  font-size: 0.95rem;
}

.btn-claim-idle {
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid #6ee7b7;
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Prompt', sans-serif;
}

.btn-claim-idle:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.btn-claim-idle:disabled {
  background: #334155;
  border-color: #475569;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.citadel-buildings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
}

.citadel-building-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  transition: all 0.2s ease;
}

.citadel-building-card:hover {
  border-color: rgba(192, 132, 252, 0.5);
  background: rgba(30, 41, 59, 0.85);
}

.building-icon-box {
  font-size: 2.0rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.9);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.building-info {
  flex: 1;
  text-align: left;
}

.building-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.building-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #f8fafc;
}

.building-lvl-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.building-lvl-badge.max {
  background: rgba(245, 158, 11, 0.25);
  color: #ffd700;
  border-color: #ffd700;
}

.building-desc {
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.3;
  margin-bottom: 3px;
}

.building-current-bonus {
  font-size: 0.74rem;
  color: #a7f3d0;
}

.building-current-bonus b {
  color: #34d399;
}

.building-action {
  flex-shrink: 0;
}

.btn-upgrade-citadel {
  background: #1e293b;
  border: 1px solid #64748b;
  color: #94a3b8;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Prompt', sans-serif;
  cursor: not-allowed;
  transition: all 0.2s ease;
  min-width: 76px;
  line-height: 1.2;
}

.btn-upgrade-citadel.active {
  background: linear-gradient(135deg, #a855f7, #6366f1);
  border-color: #c084fc;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.4);
}

.btn-upgrade-citadel.active:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.6);
}

.btn-upgrade-citadel small {
  color: #ffd700;
  font-size: 0.7rem;
}
