 #gameContainer {
     width: 100%;
     height: 100%;
     position: relative;
 }

 #canvas {
     display: block;
     width: 100%;
     height: 100%;
 }

  /* ===== Loading Screen ===== */
  #loadingScreen {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 99999;
      display: flex;
      align-items: center;
      justify-content: center;
      background: radial-gradient(ellipse at top, #c9a25a 0%, #8a6630 55%, #5e4420 100%);
      transition: opacity 0.6s ease;
      opacity: 1;
  }

 #loadingScreen.loading-hidden {
     opacity: 0;
     pointer-events: none;
 }

 .loading-content {
     background:
         radial-gradient(ellipse at 20% 15%, rgba(255, 248, 220, 0.5), transparent 55%),
         linear-gradient(135deg, var(--parch-light) 0%, var(--parch) 45%, var(--parch-dark) 100%);
     border: 2px solid var(--parch-shadow);
     box-shadow: 0 10px 26px rgba(40, 24, 6, 0.55), inset 0 0 30px rgba(120, 80, 30, 0.25), inset 0 0 2px rgba(255, 248, 220, 0.6);
     color: var(--ink);
     border-radius: 14px;
     padding: 40px 46px 32px;
     width: min(86vw, 460px);
     text-align: center;
 }

 .loading-title {
     font-family: 'Cinzel', serif;
     font-size: 26px;
     color: var(--crimson);
     text-transform: uppercase;
     letter-spacing: 2px;
     margin-bottom: 8px;
 }

 .loading-subtitle {
     font-size: 15px;
     font-style: italic;
     color: var(--ink-soft);
     margin-bottom: 34px;
 }

 .loading-bar-track {
     position: relative;
     width: 100%;
     height: 14px;
     margin: 0 auto;
     border-radius: 8px;
     background: var(--parch-shadow);
     border: 1px solid var(--ink-soft);
     box-shadow: inset 0 2px 5px rgba(40, 24, 6, 0.5);
     overflow: visible;
 }

 .loading-bar-fill {
     position: absolute;
     top: 0;
     left: 0;
     height: 100%;
     width: 0%;
     border-radius: 8px;
     background: linear-gradient(90deg, var(--sage), var(--sage-light));
     box-shadow: 0 0 10px rgba(124, 154, 76, 0.7);
     transition: width 0.1s linear;
 }

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

 .loading-mana {
     position: absolute;
     top: 50%;
     width: 10px;
     height: 10px;
     margin-left: -5px;
     transform: translateY(-50%);
     border-radius: 50%;
     background: radial-gradient(circle at 35% 30%, #cfe8ff, #4488ff 60%, #1a4f9c);
     box-shadow: 0 0 8px 2px rgba(68, 136, 255, 0.85);
     animation: mana-twinkle 1.1s ease-in-out infinite;
     transition: left 0.4s ease;
 }

 .loading-mana.collected {
     animation: none;
     transform: translateY(-50%) scale(0);
     opacity: 0;
     transition: transform 0.35s ease, opacity 0.35s ease, left 0.4s ease;
 }

 #beginJourneyBtn,
 #backToMenuBtn,
 #backToCharacterBtn {
     margin: auto;
 }

 .svg-container {
     position: absolute;
     width: 0;
     height: 0;
     overflow: hidden;
 }

 .final_score {
     position: relative;
     margin-bottom: 36px;
     padding: 2px;
     border-radius: 14px;
     background: linear-gradient(-30deg,
             rgba(196, 144, 48, 0.5),
             transparent,
             rgba(196, 144, 48, 0.5));
     z-index: 0;
     box-shadow: 0 10px 26px rgba(40, 24, 6, 0.55), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
 }

 .final_score::before {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: 14px;
     border: 2px solid rgba(196, 144, 48, 0.8);
     filter: url(#electric-displace);
     z-index: 1;
     pointer-events: none;
 }

 .final_score::after {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: 14px;
     border: 2px solid rgba(255, 215, 0, 0.6);
     filter: blur(4px);
     z-index: 0;
     pointer-events: none;
 }

 .final-score-inner {
     position: relative;
     z-index: 2;
     background:
         radial-gradient(ellipse at 20% 15%, rgba(255, 248, 220, 0.5), transparent 55%),
         linear-gradient(135deg, var(--parch-light) 0%, var(--parch) 45%, var(--parch-dark) 100%);
     border-radius: 12px;
     padding: 16px 24px;
     font-size: 22px;
     line-height: 1.8;
     color: var(--ink);
     box-shadow: inset 0 0 30px rgba(120, 80, 30, 0.25), inset 0 0 2px rgba(255, 248, 220, 0.6);
 }

 .final-score-content {
     position: relative;
     z-index: 3;
 }

 .final-score-inner::before {
     content: "";
     position: absolute;
     inset: -2px;
     border-radius: 12px;
     opacity: 0.6;
     mix-blend-mode: overlay;
     transform: scale(1.05);
     filter: blur(12px);
     background: linear-gradient(-30deg,
             rgba(255, 255, 255, 0.8),
             transparent 30%,
             transparent 70%,
             rgba(255, 255, 255, 0.8));
     pointer-events: none;
     z-index: 1;
 }

 .final-score-inner::after {
     content: "";
     position: absolute;
     inset: -2px;
     border-radius: 12px;
     opacity: 0.4;
     mix-blend-mode: overlay;
     transform: scale(1.05);
     filter: blur(12px);
     background: linear-gradient(-30deg,
             rgba(255, 255, 255, 0.6),
             transparent 30%,
             transparent 70%,
             rgba(255, 255, 255, 0.6));
     pointer-events: none;
     z-index: 1;
     animation: shimmer 3s ease-in-out infinite;
 }

 #saveGameContainer {
     display: none;
     margin-bottom: 20px;
     border: 2px solid var(--gold-light);
     padding: 15px;
     border-radius: 8px;
     background: rgba(0, 0, 0, 0.2);
 }

 #saveGameContainer h3 {
     margin-top: 0;
     font-size: 20px;
     color: var(--ink);

 }

 @keyframes shimmer {

     0%,
     100% {
         opacity: 0.3;
     }

     50% {
         opacity: 0.6;
     }
 }

 @keyframes mana-twinkle {

     0%,
     100% {
         opacity: 0.8;
         transform: translateY(-50%) scale(0.9);
     }

     50% {
         opacity: 1;
         transform: translateY(-50%) scale(1.15);
     }
 }

 .loading-character {
     position: absolute;
     bottom: 100%;
     left: 6%;
     width: 26px;
     height: 32px;
     margin-left: -13px;
     margin-bottom: -4px;
     transform: translate(0, 0) scaleX(1);
 }

 .lc-head {
     position: absolute;
     top: 0;
     left: 50%;
     width: 14px;
     height: 14px;
     margin-left: -7px;
     border-radius: 50%;
     background: #ffdbac;
     border: 1px solid var(--ink-soft);
 }

 .lc-body {
     position: absolute;
     top: 12px;
     left: 50%;
     width: 18px;
     height: 14px;
     margin-left: -9px;
     border-radius: 5px 5px 3px 3px;
     background: var(--crimson-light);
     border: 1px solid var(--ink-soft);
 }

 .lc-leg {
     position: absolute;
     top: 24px;
     width: 5px;
     height: 9px;
     border-radius: 2px;
     background: var(--ink-soft);
     transform-origin: top center;
 }

 .lc-leg-l {
     left: 6px;
     animation: lc-walk-l 0.4s ease-in-out infinite;
 }

 .lc-leg-r {
     right: 6px;
     animation: lc-walk-r 0.4s ease-in-out infinite;
 }

 @keyframes lc-walk-l {

     0%,
     100% {
         transform: rotate(28deg);
     }

     50% {
         transform: rotate(-28deg);
     }
 }

 @keyframes lc-walk-r {

     0%,
     100% {
         transform: rotate(-28deg);
     }

     50% {
         transform: rotate(28deg);
     }
 }

 .loading-percent {
     margin-top: 16px;
     font-family: 'Cinzel', serif;
     font-size: 14px;
     letter-spacing: 1px;
     color: var(--ink-soft);
 }

 /* Shared parchment panel look */
 .hud,
 .health-bar-container,
 .wealth-bar-container,
 .mobile-controls,
 .modal,
 .about-panel {
     background:
         radial-gradient(ellipse at 20% 15%, rgba(255, 248, 220, 0.5), transparent 55%),
         linear-gradient(135deg, var(--parch-light) 0%, var(--parch) 45%, var(--parch-dark) 100%);
     border: 2px solid var(--parch-shadow);
     box-shadow: 0 10px 26px rgba(40, 24, 6, 0.55), inset 0 0 30px rgba(120, 80, 30, 0.25), inset 0 0 2px rgba(255, 248, 220, 0.6);
     color: var(--ink);
 }

 .hud {
     position: absolute;
     top: 20px;
     left: 20px;
     border-radius: 10px;
     padding: 16px 20px;
     z-index: 30;
     font-size: 19px;
     min-width: 220px;
 }

 .hud-item {
     margin-bottom: 8px;
     font-weight: 700;
     font-size: 18px;
     letter-spacing: 0.3px;
     color: var(--ink);
     font-family: 'Cinzel', serif;
 }

 .hud-time {
     font-family: 'Cinzel', serif;
     font-size: 23px;
     font-weight: 700;
     color: var(--crimson);
     margin-bottom: 8px;
     border-bottom: 1px solid var(--parch-shadow);
     padding-bottom: 6px;
 }

 .hud-sickness {
     display: none !important;
 }

 .hud-mana {
     font-family: 'Cinzel', serif;
     font-size: 19px;
     font-weight: 700;
     color: var(--sage);
     margin-top: 4px;
 }

 .hud-location,
 #location-display {
     display: none !important;
 }

 /* Status bars (Wellbeing + Wealth) */
 .status-bars {
     position: absolute;
     bottom: 30px;
     left: 50%;
     transform: translateX(-50%);
     display: flex;
     flex-direction: column;
     gap: 12px;
     width: min(380px, 88vw);
     z-index: 40;
 }

 .health-bar-container,
 .wealth-bar-container {
     border-radius: 10px;
     padding: 12px 18px;
     border: 2px solid var(--ink-soft);
 }

 .health-bar-label,
 .wealth-bar-label {
     text-align: center;
     font-family: 'Cinzel', serif;
     font-size: 15px;
     margin-bottom: 8px;
     font-weight: 700;
     letter-spacing: 0.4px;
 }

 .health-bar-label {
     color: var(--crimson);
 }

 .wealth-bar-label {
     color: var(--gold);
 }

 .health-bar,
 .wealth-bar {
     width: 100%;
     height: 22px;
     background: rgba(59, 42, 22, 0.25);
     border: 2px solid var(--ink-soft);
     border-radius: 6px;
     overflow: hidden;
     box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.35);
 }

 .health-bar-fill {
     height: 100%;
     transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
     background: linear-gradient(90deg, #6f8a3f, #91ab53);
 }

 .wealth-bar-fill {
     height: 100%;
     transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
     background: linear-gradient(90deg, var(--gold), var(--gold-light));
     box-shadow: 0 0 10px rgba(184, 134, 47, 0.6);
 }

 .location-popup {
     position: absolute;
     bottom: 130px;
     left: 20px;
     z-index: 30;
     border-radius: 6px;
     padding: 10px 16px;
     display: none;
 }

 .location-popup.active {
     display: block;
     animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
 }

 .location-popup-content {
     font-family: 'Cinzel', serif;
     font-size: 14px;
     color: var(--ink);
     text-transform: uppercase;
     letter-spacing: 1px;
 }

 .mobile-controls {
     position: absolute;
     top: 50%;
     right: 30px;
     transform: translateY(-50%);
     z-index: 30;
     display: grid;
     grid-template-columns: repeat(3, 60px);
     grid-template-rows: repeat(3, 60px);
     gap: 8px;
     padding: 12px;
     border-radius: 10px;
 }

 /* Small screens */
 @media (max-width: 600px) {
     .mobile-controls {
         grid-template-columns: repeat(3, 60px);
         grid-template-rows: repeat(3, 60px);
         justify-items: center;
         left: 15px;
         top: 50%;
         transform: translateY(-50%);
         width: auto;
         height: auto;
     }

     .mobile-controls>div {
         display: none;
     }
 }

 .arrow-btn {
     width: 60px;
     height: 60px;
     border-radius: 6px;
     border: 2px solid var(--ink-soft);
     background: linear-gradient(145deg, #8a6125, #5e4118);
     color: var(--parch-light);
     font-size: 24px;
     font-weight: 700;
     cursor: pointer;
     user-select: none;
     box-shadow: 0 5px 0 #4a3414, 0 7px 16px rgba(0, 0, 0, 0.4);
     transition: all 0.1s ease;
     display: flex;
     align-items: center;
     justify-content: center;
     font-family: 'Cinzel', serif;
 }

 #difficultyModal {
     height: 90vh;
     width: 84vw;
     text-align: center;
     overflow-y: auto;
     scrollbar-width: thin;
     scrollbar-color: var(--parch-shadow) transparent;
 }

 #difficultyModal::-webkit-scrollbar {
     width: 6px;
 }

 #difficultyModal::-webkit-scrollbar-track {
     background: transparent;
 }

 #difficultyModal::-webkit-scrollbar-thumb {
     background: var(--parch-shadow);
     border-radius: 3px;
 }

 #difficultyModal::-webkit-scrollbar-thumb:hover {
     background: var(--ink-soft);
 }

 .btn-jump {
     background: linear-gradient(145deg, #c49030, #8a6125);
     color: #3d2a06;
     border-color: #6d4d1f;
 }

 .arrow-btn:active {
     transform: translateY(4px);
     box-shadow: 0 1px 0 #4a3414, 0 3px 8px rgba(0, 0, 0, 0.3);
 }

 .modal {
     display: none;
     position: absolute;
     top: 50%;
     left: 50%;
     transform: translate(-50%, -50%) scale(1);
     padding: 40px 50px;
     border-radius: 6px;
     text-align: center;
     z-index: 100;
     max-width: 620px;
     width: 90vw;
     max-height: 90vh;
     overflow-y: auto;
     -webkit-overflow-scrolling: touch;
     border: 3px solid var(--ink-soft);
     outline: 1px solid var(--gold);
     outline-offset: -8px;
     animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
 }

 .modal.active {
     display: block !important;
 }

 @keyframes modalPop {
     from {
         opacity: 0;
         transform: translate(-50%, -50%) scale(0.92);
     }

     to {
         opacity: 1;
         transform: translate(-50%, -50%) scale(1);
     }
 }

 .modal h1 {
     font-family: 'Cinzel Decorative', serif;
     font-size: 44px;
     margin-bottom: 22px;
     color: var(--crimson);
     text-shadow: 0 2px 0 rgba(255, 248, 220, 0.4);
     letter-spacing: 1px;
 }

 .modal h2 {
     font-family: 'Cinzel Decorative', serif;
     font-size: 30px;
     margin-bottom: 26px;
     color: var(--ink-soft);
 }

 .modal p {
     font-size: 19px;
     margin-bottom: 22px;
     line-height: 1.65;
     color: var(--ink);
     font-style: italic;
 }

 .modal button {
     padding: 14px 38px;
     font-family: 'Cinzel', serif;
     font-size: 19px;
     border: none;
     border-radius: 4px;
     cursor: pointer;
     font-weight: 700;
     margin: 8px;
     transition: all 0.2s ease;
     box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3), 0 7px 16px rgba(0, 0, 0, 0.3);
     text-transform: uppercase;
     letter-spacing: 1px;
     position: relative;
 }

 .modal button:active {
     transform: translateY(3px);
     box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.3);
 }

 .btn-primary {
     background: linear-gradient(135deg, var(--crimson-light), var(--crimson));
     color: var(--parch-light);
     font-size: 20px;
     padding: 16px 44px;
     border: 1px solid var(--gold);
 }

 .btn-primary:hover {
     background: linear-gradient(135deg, #b8453a, var(--crimson-light));
     transform: translateY(-2px);
 }

 .btn-difficulty {
     color: var(--ink);
     margin: 10px 6px;
     padding: 28px 20px;
     border-radius: 12px;
     font-size: 18px;
     width: 100%;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     gap: 10px;
     border: 2px solid var(--ink-soft);
     box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3), 0 12px 24px rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.15), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
     transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
     cursor: pointer;
     min-height: 140px;
     position: relative;
     overflow: hidden;
 }

 .btn-difficulty::after {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: inherit;
     border: 2px solid rgba(196, 144, 48, 0.8);
     filter: url(#electric-displace);
     z-index: -1;
     pointer-events: none;
 }

 .btn-difficulty::before {
     content: '';
     position: absolute;
     top: 0;
     left: -100%;
     width: 100%;
     height: 100%;
     background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
     transition: left 0.5s ease;
 }

 .btn-difficulty:hover::before {
     left: 100%;
 }

 .btn-difficulty.single {
     background: linear-gradient(160deg, #a8c98a 0%, #7d9e5a 50%, #5c7a3d 100%);
     color: #1a2810;
     border-color: #3d5228;
     transform: scale(0.95);
 }

 .btn-difficulty.couple {
     background: linear-gradient(160deg, #f0c060 0%, #d4952a 50%, #b87820 100%);
     color: #3d2a06;
     border-color: #8a5a18;
     transform: scale(1);
 }

 .btn-difficulty.family {
     background: linear-gradient(160deg, #e8786a 0%, #c43d35 50%, #8b2520 100%);
     color: var(--parch-light);
     border-color: #6a1a16;
     transform: scale(1.05);
     box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35), 0 16px 32px rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.2), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
 }

 .btn-difficulty:hover {
     transform: translateY(-8px) scale(var(--hover-scale, 1));
 }

 .btn-difficulty.single:hover {
     --hover-scale: 1;
 }

 .btn-difficulty.couple:hover {
     --hover-scale: 1.02;
 }

 .btn-difficulty.family:hover {
     --hover-scale: 1.08;
 }

 .btn-difficulty:active {
     transform: translateY(-2px);
     box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.3);
 }

 .difficulty-icon {
     font-size: 28px;
     filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
     transition: transform 0.3s ease;
 }

 .btn-difficulty:hover .difficulty-icon {
     transform: scale(1.2) rotate(5deg);
 }

 .difficulty-name {
     font-size: 24px;
     font-family: 'Cinzel', serif;
     font-weight: 700;
     letter-spacing: 2px;
     text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
 }

 .difficulty-quota {
     font-size: 15px;
     opacity: 0.9;
     font-weight: 700;
     font-family: 'Cinzel', serif;
     letter-spacing: 1px;
 }

 .difficulty-desc {
     font-size: 13px;
     opacity: 0.85;
     font-weight: 500;
     font-family: 'EB Garamond', Georgia, serif;
     font-style: italic;
 }

 .btn-secondary {
     background: rgba(59, 42, 22, 0.08);
     color: var(--ink);
     border: 2px solid var(--ink-soft);
     box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15), 0 7px 16px rgba(0, 0, 0, 0.2);
 }

 .btn-secondary:hover {
     background: rgba(59, 42, 22, 0.16);
     transform: translateY(-2px);
 }

 .character-selector {
     margin-bottom: 20px;
     padding-bottom: 24px;
     border-bottom: 2px solid rgba(90, 63, 34, 0.35);
 }

 .character-btn {
     position: relative;
     z-index: 0;
     padding: 16px 24px;
     font-family: 'Cinzel', serif;
     font-size: 16px;
     background: rgba(59, 42, 22, 0.06);
     color: var(--ink);
     border: 2px solid var(--ink-soft);
     border-radius: 8px;
     cursor: pointer;
     font-weight: 700;
     text-transform: capitalize;
     margin: 6px;
     transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
     box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
     letter-spacing: 0.5px;
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 6px;
     min-width: 90px;
 }

 .character-btn::before {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: inherit;
     border: 2px solid rgba(196, 144, 48, 0.8);
     filter: url(#electric-displace);
     z-index: -1;
     pointer-events: none;
 }

 .character-btn::after {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: inherit;
     border: 2px solid rgba(255, 215, 0, 0.6);
     filter: blur(4px);
     z-index: -2;
     pointer-events: none;
 }

 .char-icon {
     font-size: 24px;
     filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
 }

 .char-name {
     font-size: 14px;
     letter-spacing: 0.5px;
 }

 .character-btn:hover {
     background: rgba(59, 42, 22, 0.14);
     transform: translateY(-4px);
     box-shadow: 0 7px 0 rgba(0, 0, 0, 0.18), 0 10px 20px rgba(0, 0, 0, 0.15);
 }

 .character-btn.selected {
     background: linear-gradient(160deg, var(--gold-light) 0%, #c49030 100%);
     border-color: var(--ink-soft);
     color: #3d2a06;
     box-shadow: 0 6px 0 #8a6125, 0 10px 24px rgba(184, 134, 47, 0.35);
     transform: translateY(-3px);
 }

 .character-btn.selected .char-icon {
     transform: scale(1.15);
 }

 .difficulty-selector {
     margin-bottom: 24px;
 }

 .character-buttons,
 .difficulty-buttons {
     display: grid;
     grid-template-columns: 1fr 1fr 1fr;
     gap: 20px;
     width: 100%;
     margin: 0;
 }

 .tribe-buttons {
     display: grid;
     grid-template-columns: repeat(4, 1fr);
     gap: 12px;
     width: 100%;
     margin: 0;
 }

 /* Small screens: 12 tribes as a 3x4 grid. */
 @media (max-width: 768px) {
     .tribe-buttons {
         grid-template-columns: repeat(3, 1fr);
     }
 }

 /* Very small screens: 12 tribes as a 2x6 grid. */
 @media (max-width: 480px) {
     .tribe-buttons {
         grid-template-columns: repeat(2, 1fr);
     }
 }

 .tribe-btn {
     --tribe-color: var(--gold);
     position: relative;
     z-index: 0;
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 3px;
     padding: 12px 8px;
     background: rgba(59, 42, 22, 0.08);
     border: 2px solid var(--ink-soft);
     border-radius: 10px;
     color: var(--ink);
     font-family: 'Cinzel', serif;
     cursor: pointer;
     box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15), 0 6px 12px rgba(0, 0, 0, 0.15), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
     transition: all 0.25s ease;
     min-width: 0;
 }

 .tribe-btn::before {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: inherit;
     border: 2px solid rgba(196, 144, 48, 0.8);
     filter: url(#electric-displace);
     z-index: -1;
     pointer-events: none;
 }

 .tribe-btn::after {
     content: "";
     position: absolute;
     inset: 0;
     border-radius: inherit;
     border: 2px solid rgba(255, 215, 0, 0.6);
     filter: blur(4px);
     z-index: -2;
     pointer-events: none;
 }

 .tribe-btn.selected {
     background: linear-gradient(160deg, var(--gold-light) 0%, #c49030 100%);
     border-color: var(--ink-soft);
     color: #3d2a06;
     box-shadow: 0 6px 0 #8a6125, 0 10px 24px rgba(184, 134, 47, 0.35), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
     transform: translateY(-3px);
 }

 .tribe-btn:hover {
     background: rgba(59, 42, 22, 0.14);
     transform: translateY(-4px);
     box-shadow: 0 7px 0 rgba(0, 0, 0, 0.18), 0 10px 20px rgba(0, 0, 0, 0.15), 0 0 10px rgba(196, 144, 48, 0.4), 0 0 20px rgba(255, 215, 0, 0.2);
 }

 .tribe-swatch {
     width: 22px;
     height: 22px;
     border-radius: 50%;
     border: 2px solid rgba(0, 0, 0, 0.25);
     box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
 }

 .tribe-name {
     font-size: 14px;
     letter-spacing: 0.5px;
     font-weight: 600;
 }

 .tribe-epithet {
     font-size: 11px;
     font-style: italic;
     opacity: 0.85;
 }

 .tribe-quota {
     font-size: 11px;
     letter-spacing: 0.5px;
     opacity: 0.9;
 }

 .section-title {
     font-family: 'Cinzel', serif;
     font-size: 18px;
     font-weight: 600;
     color: var(--ink-soft);
     text-transform: uppercase;
     letter-spacing: 3px;
     margin-bottom: 18px;
     text-align: center;
     position: relative;
 }

 .section-title::after {
     content: '';
     display: block;
     width: 60px;
     height: 2px;
     background: linear-gradient(90deg, transparent, var(--gold), transparent);
     margin: 8px auto 0;
 }

 .section-divider {
     display: flex;
     align-items: center;
     justify-content: center;
     gap: 14px;
     margin: 24px 0;
 }

 .divider-line {
     flex: 1;
     height: 1px;
     background: linear-gradient(90deg, transparent, var(--ink-soft), transparent);
     opacity: 0.5;
 }

 .divider-icon {
     font-size: 18px;
     opacity: 0.7;
 }

 #difficultyModal .btn-secondary {
     background: linear-gradient(160deg, rgba(59, 42, 22, 0.1) 0%, rgba(59, 42, 22, 0.2) 100%);
     color: var(--ink);
     border: 2px solid var(--ink-soft);
     box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15), 0 6px 12px rgba(0, 0, 0, 0.15);
     transition: all 0.25s ease;
     letter-spacing: 1px;
 }

 .btn-back {
     display: flex;
     align-items: center;
     gap: 8px;
     font-family: 'Cinzel', serif;
     font-weight: 600;
     text-transform: uppercase;
     font-size: 14px;
     letter-spacing: 2px;
     margin: 8px auto;
     width: fit-content;
 }

 .back-icon {
     font-size: 16px;
     transition: transform 0.25s ease;
 }

 #difficultyModal .btn-secondary:hover {
     background: linear-gradient(160deg, rgba(59, 42, 22, 0.18) 0%, rgba(59, 42, 22, 0.28) 100%);
     transform: translateY(-3px);
     box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2), 0 10px 20px rgba(0, 0, 0, 0.18);
 }

 #difficultyModal .btn-secondary:hover .back-icon {
     transform: translateX(-4px);
 }

 .difficulty-header {
     text-align: center;
     margin-bottom: 8px;
 }

 .difficulty-header h2 {
     font-family: 'Cinzel Decorative', serif;
     font-size: 28px;
     color: var(--crimson);
     text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
     letter-spacing: 2px;
     margin: 0 0 8px 0;
 }

 .difficulty-subtitle {
     font-family: 'EB Garamond', Georgia, serif;
     font-size: 16px;
     font-style: italic;
     color: var(--ink-soft);
     opacity: 0.9;
     margin: 0;
 }

 .difficulty-buttons button,
 .character-buttons button {
     width: 100%;
     box-sizing: border-box;
     min-width: 0;

 }

 .stats-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 16px;
     margin-bottom: 26px;
     font-size: 17px;
     background: rgba(59, 42, 22, 0.07);
     padding: 20px;
     border-radius: 6px;
     border: 1px solid var(--parch-shadow);
 }

 .stat-item {
     font-family: 'Cinzel', serif;
     font-size: 16px;
     line-height: 1.6;
     color: var(--ink);
 }

 .day-number {
     color: var(--crimson);
     font-family: 'Cinzel', serif;
 }

 .mana-count {
     color: var(--sage);
     font-family: 'Cinzel', serif;
 }

 .btn-continue {
     background: linear-gradient(135deg, var(--sage-light), var(--sage));
     color: var(--parch-light);
     font-size: 20px;
     padding: 16px 44px;
     border: 1px solid #3f4a28;
 }

 .btn-continue:hover {
     background: linear-gradient(135deg, #8da062, var(--sage-light));
     transform: translateY(-2px);
 }

 .btn-gameover {
     background: linear-gradient(135deg, var(--crimson-light), var(--crimson));
     color: var(--parch-light);
 }

 .btn-gameover:hover {
     background: linear-gradient(135deg, #b8453a, var(--crimson-light));
     transform: translateY(-2px);
 }

 .controls-top-right {
     position: absolute;
     top: 20px;
     right: 20px;
     z-index: 50;
     display: flex;
     flex-direction: column;
     gap: 12px;
 }

 .icon-btn {
     width: 48px;
     height: 48px;
     border-radius: 50%;
     border: 2px solid var(--ink-soft);
     background: linear-gradient(135deg, var(--parch-light), var(--parch-dark));
     color: var(--ink);
     font-size: 18px;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: all 0.2s ease;
     box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
 }

 .icon-btn:hover {
     transform: translateY(-2px) scale(1.06);
 }

 .about-panel {
     position: absolute;
     top: 0;
     right: -440px;
     width: 400px;
     height: 100%;
     border-left: 3px solid var(--ink-soft);
     z-index: 145;
     transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
     padding: 40px 30px;
     border-radius: 0;
     max-height: 100vh;
     overflow-y: auto;
 }

 .about-panel.open {
     right: 0;
 }

 .about-panel h2 {
     font-family: 'Cinzel Decorative', serif;
     font-size: 24px;
     color: var(--crimson);
     margin-bottom: 22px;
     text-transform: uppercase;
     letter-spacing: 2px;
 }

 .about-panel p {
     font-size: 17px;
     line-height: 1.7;
     margin-bottom: 16px;
     color: var(--ink);
 }

 .about-panel .close-btn {
     position: absolute;
     top: 16px;
     right: 16px;
     background: var(--parch-dark);
     border: 2px solid var(--ink-soft);
     color: var(--ink);
     width: 40px;
     height: 40px;
     border-radius: 50%;
     cursor: pointer;
     font-size: 16px;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: all 0.2s;
 }

 .about-panel .close-btn:hover {
     background: var(--crimson);
     color: var(--parch-light);
     transform: rotate(90deg);
 }

 .icon-btn:active {
     transform: scale(0.95);
 }

 .modal h3 {
     font-family: 'Cinzel', serif;
     font-size: 20px;
     color: var(--ink-soft);
     margin-bottom: 16px;
 }

 @keyframes bounceIn {
     0% {
         transform: scale(0.4);
         opacity: 0;
     }

     60% {
         transform: scale(1.1);
     }

     100% {
         transform: scale(1);
         opacity: 1;
     }
 }

 @keyframes pulse {

     0%,
     100% {
         transform: scale(1);
     }

     50% {
         transform: scale(1.06);
     }
 }

 @keyframes glowPulse {

     0%,
     100% {
         text-shadow: 0 0 4px rgba(184, 134, 47, 0.3);
     }

     50% {
         text-shadow: 0 0 14px rgba(184, 134, 47, 0.8);
     }
 }

 @keyframes shake {

     0%,
     100% {
         transform: translateX(0);
     }

     20% {
         transform: translateX(-4px);
     }

     40% {
         transform: translateX(4px);
     }

     60% {
         transform: translateX(-4px);
     }

     80% {
         transform: translateX(4px);
     }
 }

 @keyframes floatUp {
     0% {
         transform: translateY(0) scale(1);
         opacity: 1;
     }

     100% {
         transform: translateY(-40px) scale(1.2);
         opacity: 0;
     }
 }

 @keyframes starBurst {
     0% {
         transform: scale(0) rotate(0deg);
         opacity: 1;
     }

     50% {
         transform: scale(1.3) rotate(180deg);
         opacity: 0.8;
     }

     100% {
         transform: scale(0) rotate(360deg);
         opacity: 0;
     }
 }

 @keyframes rainbowShift {
     0% {
         filter: sepia(0.2);
     }

     50% {
         filter: sepia(0.6) saturate(1.4);
     }

     100% {
         filter: sepia(0.2);
     }
 }

 @keyframes popIn {
     0% {
         transform: scale(0) translateY(20px);
         opacity: 0;
     }

     60% {
         transform: scale(1.05) translateY(-5px);
     }

     100% {
         transform: scale(1) translateY(0);
         opacity: 1;
     }
 }

 @keyframes fadeInUp {
     0% {
         transform: translateY(20px);
         opacity: 0;
     }

     100% {
         transform: translateY(0);
         opacity: 1;
     }
 }

 #difficultyModal.active .difficulty-header {
     animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
 }

 #difficultyModal.active .character-selector {
     animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.15s forwards;
     opacity: 0;
 }

 #difficultyModal.active .difficulty-selector {
     animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.3s forwards;
     opacity: 0;
 }

 #difficultyModal.active .btn-back {
     animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.45s forwards;
     opacity: 0;
 }

 .hud-item.updated {
     animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
 }

 .hud-time.updated {
     animation: glowPulse 0.6s ease-out;
 }

 .hud-sickness.warning {
     animation: shake 0.5s ease-in-out;
 }

 .health-bar-fill.pulse,
 .wealth-bar-fill.pulse {
     animation: pulse 0.4s ease-in-out;
 }

 .score-pop {
     position: absolute;
     font-family: 'Cinzel', serif;
     font-size: 26px;
     font-weight: 700;
     color: var(--gold);
     text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
     pointer-events: none;
     z-index: 40;
     animation: floatUp 1s ease-out forwards;
 }

 .star-burst {
     position: absolute;
     width: 30px;
     height: 30px;
     pointer-events: none;
     z-index: 40;
     animation: starBurst 0.8s ease-out forwards;
 }

 .star-burst::before {
     content: '✦';
     font-size: 28px;
     color: var(--gold);
     position: absolute;
     top: 50%;
     left: 50%;
     transform: translate(-50%, -50%);
 }

 .location-flash {
     animation: rainbowShift 1s linear;
 }

 .mobile-controls button:active {
     transform: scale(0.9);
     transition: transform 0.1s;
 }

 .btn-difficulty.pop-in {
     animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
 }

 .character-btn.pop-in {
     animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
 }

 .market-btn {
     position: absolute;
     top: 50%;
     left: 50%;
     transform: translateX(-50%);
     margin-top: 60px;
     z-index: 30;
 }

 .market-trigger-btn {
     position: absolute;
     top: 20px;
     left: 50%;
     transform: translateX(-50%);
     z-index: 30;
     font-family: 'Cinzel', serif;
     font-size: 15px;
     font-weight: 700;
     padding: 10px 22px;
     border-radius: 6px;
     cursor: pointer;
     letter-spacing: 0.5px;
     background: linear-gradient(135deg, var(--gold-light), var(--gold));
     color: #3d2a06;
     border: 2px solid var(--ink-soft);
     box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25), 0 7px 16px rgba(0, 0, 0, 0.3);
     transition: all 0.2s ease;
 }

 .market-trigger-btn:hover {
     transform: translateX(-50%) translateY(-2px);
 }

 @media (max-width: 768px) {

     .character-buttons,
     .difficulty-buttons {
         grid-template-columns: 1fr;
     }
 }

 @media (max-width: 768px) {
     .hud {
         top: 10px;
         left: 10px;
         padding: 10px 14px;
         font-size: 16px;
         min-width: 160px;
     }

     .hud-time {
         font-size: 18px;
         margin-bottom: 6px;
     }

     .hud-item {
         font-size: 14px;
         margin-bottom: 6px;
     }

     .hud-mana,
     .hud-location {
         font-size: 14px;
     }

     .status-bars {
         bottom: 14px;
         width: 92vw;
     }

     .market-trigger-btn {
         font-size: 13px;
         padding: 8px 16px;
     }

     .modal {
         padding: 26px 18px;
         width: 92vw;
     }

     .modal h1 {
         font-size: 30px;
     }

     .modal h2 {
         font-size: 23px;
     }

     .stats-grid {
         grid-template-columns: 1fr;
         gap: 12px;
     }

     .btn-primary,
     .btn-difficulty,
     .btn-continue,
     .btn-gameover,
     .btn-secondary {
         font-size: 16px;
         padding: 12px 26px;
         margin: 6px;
     }

     .character-btn {
         font-size: 14px;
         padding: 9px 18px;
         margin: 6px;
     }

     #difficultyModal.active {
         display: flex !important;
         flex-direction: column;
         gap: 16px;
         align-items: center;
         max-height: 90vh;
         overflow-y: auto;
         border: 3px solid rgba(139, 115, 85, 0.6);
     }

     #difficultyModal.active {
         box-shadow: 0 0 60px rgba(90, 63, 34, 0.3), inset 0 0 30px rgba(120, 80, 30, 0.1);
     }

     #difficultyModal h2 {
         flex-shrink: 0;
         margin: 0;
     }

     .modal-scroll {
         flex: 1 1 auto;
         overflow-y: auto;
         padding-right: 8px;
         width: 100%;
     }

     #difficultyModal .btn-secondary {
         flex-shrink: 0;
         align-self: center;
         margin-top: auto;
         margin-bottom: 8px;
     }

     #difficultyModal h2 {
         font-size: 20px;
     }

     .difficulty-header h2 {
         font-size: 22px;
     }

     .character-buttons,
     .difficulty-buttons {
         grid-template-columns: 1fr;
         gap: 12px;
         margin: auto;
         grid-auto-columns: min-content;
         width: fit-content;
     }

     .btn-difficulty {
         min-height: 120px;
     }

     .difficulty-icon {
         font-size: 24px;
     }

     .difficulty-desc {
         font-size: 12px;
     }
 }

 .market-status {
     margin: 14px 0;
     padding: 12px 16px;
     border-radius: 8px;
     border: 2px solid var(--ink-soft);
     background: rgba(59, 42, 22, 0.15);
     font-family: 'Cinzel', serif;
     font-size: 15px;
     text-align: center;
 }

 .market-status-shortage {
     border-color: var(--crimson);
     background: rgba(122, 33, 24, 0.12);
     color: var(--crimson);
 }

 .market-status-glut {
     border-color: var(--sage);
     background: rgba(92, 107, 62, 0.12);
     color: var(--sage);
 }

 .market-status-surplus {
     border-color: var(--gold);
     background: rgba(184, 134, 47, 0.12);
     color: var(--gold);
 }

 .market-status-balanced {
     border-color: var(--ink-soft);
     color: var(--ink);
 }

 /* ===== Wilderness Economy: narrative toasts ===== */
 .narrative-toasts {
     position: fixed;
     top: 84px;
     left: 50%;
     transform: translateX(-50%);
     display: flex;
     flex-direction: column;
     align-items: center;
     gap: 8px;
     z-index: 210;
     pointer-events: none;
     width: min(560px, 92vw);
 }

 .narrative-toast {
     font-family: 'EB Garamond', Georgia, serif;
     font-style: italic;
     font-size: 17px;
     color: var(--parch-light);
     background: rgba(20, 12, 4, 0.82);
     border: 1px solid var(--gold);
     border-radius: 8px;
     padding: 10px 20px;
     text-align: center;
     box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
     opacity: 0;
     transform: translateY(-8px);
     transition: opacity 0.5s ease, transform 0.5s ease;
 }

 .narrative-toast.show {
     opacity: 1;
     transform: translateY(0);
 }

 /* ===== Wilderness Economy: evening temptations ===== */
 #eveningModal {
     max-height: 90vh;
     overflow-y: auto;
 }

 .evening-narrative {
     font-style: italic;
     color: var(--ink-soft);
     margin-bottom: 22px;
 }

 .evening-option {
     border: 2px solid var(--ink-soft);
     border-radius: 8px;
     padding: 16px 20px;
     margin-bottom: 18px;
     background: rgba(59, 42, 22, 0.12);
     text-align: left;
 }

 .evening-option-muted {
     opacity: 0.6;
 }

 .evening-option-title {
     font-family: 'Cinzel', serif;
     font-size: 20px;
     font-weight: 700;
     color: var(--crimson);
     margin-bottom: 8px;
 }

 .evening-option-title .fa-crown {
     color: var(--gold);
 }

 .evening-option-title .fa-staff-snake {
     color: var(--sage);
 }

 .evening-option-desc {
     font-size: 16px;
     line-height: 1.6;
     color: var(--ink);
     margin-bottom: 14px;
 }

 .evening-cost {
     color: var(--gold);
     font-weight: 700;
 }

 .evening-risk {
     color: var(--crimson);
     font-weight: 700;
 }

 .evening-option .btn-primary {
     margin: 0;
 }

 .evening-option .btn-primary:disabled {
     background: linear-gradient(135deg, #9a9384, #7c7568);
     border-color: var(--parch-shadow);
     cursor: not-allowed;
     box-shadow: none;
     opacity: 0.85;
 }

 /* ===== Wilderness Economy: faith side panel ===== */
 .faith-stats {
     margin-top: 8px;
 }

 .faith-row {
     display: flex;
     justify-content: space-between;
     align-items: baseline;
     gap: 12px;
     padding: 9px 4px;
     border-bottom: 1px dashed var(--parch-shadow);
     font-family: 'Cinzel', serif;
     font-size: 16px;
     color: var(--ink);
 }

 .faith-row span:last-child {
     font-weight: 700;
     color: var(--crimson);
 }

 /* ===== Wilderness Economy: game-over faith summary ===== */
 .gameover-faith {
     margin: 8px 0 24px;
     padding: 16px 20px;
     border: 2px solid var(--gold);
     border-radius: 8px;
     background: rgba(59, 42, 22, 0.12);
 }

 .gameover-faith-rating {
     font-family: 'Cinzel', serif;
     font-size: 20px;
     color: var(--gold);
     margin-bottom: 12px;
 }

 .gameover-faith-rating span {
     font-weight: 700;
     color: var(--crimson);
 }

 .gameover-faith-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 6px 18px;
     font-size: 15px;
     color: var(--ink);
     text-align: left;
 }