  :root {
    --panel: #fffaf3; --ink: #5b4b43; --soft: #8c7a70;
    --accent: #f4a261; --accent2: #e76f51; --good: #6bbf8a;
    --gold: #e9b949; --shadow: rgba(91, 75, 67, 0.18);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body {
    height: 100%; font-family: "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--ink); background: #2a3a5c; overflow: hidden;
    user-select: none; -webkit-user-select: none;
  }

  /* sky / celestial */
  #sky { position: fixed; inset: 0; z-index: 0; background: linear-gradient(180deg, #7ec8e3 0%, #cfe8f5 55%, #fce8d2 100%); }
  #stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0; width: 100%; height: 100%; }
  .star { position: absolute; background: #fff; border-radius: 50%; animation: twinkle 3s ease-in-out infinite; }
  @keyframes twinkle { 0%,100% { opacity: 0.35; } 50% { opacity: 1; } }
  #sun { position: fixed; z-index: 0; pointer-events: none; width: 64px; height: 64px; border-radius: 50%; will-change: transform, opacity; }
  #moon { position: fixed; z-index: 1; pointer-events: auto; cursor: pointer; width: 64px; height: 64px; border-radius: 50%; will-change: transform, opacity; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
  #moon * { pointer-events: none; }   /* clicks always land on the moon itself, not its eyes/cheeks */
  #sun { background: radial-gradient(circle at 50% 50%, #fff6d6, #ffd86b 60%, #ffb43d); box-shadow: 0 0 40px 14px rgba(255,210,90,0.55); }
  #moon { background: radial-gradient(circle at 38% 38%, #fdfdff, #d9def0 70%, #b9c2dc); box-shadow: 0 0 34px 12px rgba(216,226,255,0.6), 0 0 80px 30px rgba(186,202,255,0.4); }
  body.night #moon { box-shadow: 0 0 44px 16px rgba(224,232,255,0.75), 0 0 110px 44px rgba(176,198,255,0.5); }
  #moon .eye { position: absolute; width: 7px; height: 10px; background: #6f6885; border-radius: 50%; top: 25px; }
  #moon .eye.l { left: 19px; } #moon .eye.r { left: 38px; }
  #moon .cheek { position: absolute; width: 8px; height: 6px; background: rgba(244,162,97,0.45); border-radius: 50%; top: 33px; }
  #moon .cheek.l { left: 13px; } #moon .cheek.r { left: 43px; }
  #moon .mouth { position: absolute; width: 16px; height: 8px; border: 3px solid #6f6885; border-top: none; border-radius: 0 0 16px 16px; left: 24px; top: 35px; }
  .cloud { position: fixed; top: 0; left: 0; width: 140px; height: 60px; background: rgba(255,255,255,0.75); border-radius: 60px; filter: blur(2px); pointer-events: none; z-index: 0; transition: opacity 1.5s ease, background 1.5s ease; }
  .cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
  .cloud::before { width: 70px; height: 70px; top: -30px; left: 20px; }
  .cloud::after  { width: 90px; height: 90px; top: -40px; right: 20px; }
  body.night .cloud { opacity: 0.25; background: rgba(180,190,220,0.6); }

  h1, h2, #coins, #roof .label, .rbStars, .achName, #miniStat { font-family: "Baloo 2", "Quicksand", sans-serif; }

  /* parallax city skyline behind the tower */
  #skyline { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
  .sky-layer { position: absolute; bottom: 0; left: 0; right: 0; height: 100%; will-change: transform; }
  .sky-layer .bldg { position: absolute; bottom: 0; background: #46588a; border-radius: 4px 4px 0 0; transition: background 1.5s ease, opacity 1.5s ease; }
  .sky-layer .bldg i { position: absolute; width: 6px; height: 8px; background: rgba(255,255,255,0.18); border-radius: 1px; transition: background 1.5s ease; }
  body.night .sky-layer .bldg { background: #1b2640; }
  body.night .sky-layer .bldg i { background: rgba(255,224,140,0.85); }
  #sky-far { filter: blur(1px) brightness(0.8); }
  #sky-near { filter: drop-shadow(0 -5px 15px rgba(0,0,0,0.1)); }

  /* pet yard â€” companions wander a strip near the bottom */
  #petYard {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    z-index: 100; display: none; gap: 10px; padding: 10px;
    background: rgba(255, 255, 255, 0.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1); pointer-events: auto;
  }
  @media (max-width: 860px) { #petYard { bottom: auto; top: 12px; } }

  .pet-pod {
    width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; background: rgba(255, 255, 255, 0.3); border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); cursor: pointer; transition: transform 0.2s;
    animation: petBreathe 4s ease-in-out infinite alternate; will-change: transform;
  }
  .pet-glyph {
    width: 32px; height: 32px;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
  }
  .pet-pod:hover .pet-glyph { filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.7)); }
  .pet-pod:hover { transform: scale(1.1) translateY(-4px); z-index: 10; }
  .pet-pod.tap-animate { animation: petPop 0.4s ease-out; }
  body.reduced .pet-pod { animation: none !important; }

  @keyframes petBreathe {
    from { transform: scale(1); }
    to { transform: scale(1.06); }
  }

  @keyframes petPop {
    0% { transform: scale(1.06); }
    40% { transform: scale(0.85, 1.2); }
    70% { transform: scale(1.2, 0.85); }
    100% { transform: scale(1.06); }
  }

  /* Dynamic Interior Window Glow */
  .floor .window-glow {
    position: absolute;
    left: var(--glow-x, 0);
    top: 0;
    width: var(--glow-w, 100%);
    height: var(--glow-h, 100%);
    background: var(--window-gradient, linear-gradient(135deg, #fffbe6, #ffe0b2)); /* Warm interior light */
    opacity: 0.12; /* Faint by day so the scene art reads clearly */
    mix-blend-mode: soft-light; /* tint the scene like ambient lighting, not a flat wash */
    transition: opacity 0.5s ease, filter 0.3s ease;
    animation: windowPulse var(--window-pulse-duration, 6s) ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 11; /* above the scene art, below the nameplate/buttons */
  }

  body.night .floor .window-glow {
    opacity: 0.5; /* the rooms light up after dark */
    filter: brightness(1.25);
  }

  body.frenzy .floor .window-glow,
  body.prodfrenzy .floor .window-glow {
    opacity: 0.7 !important; /* Much brighter during frenzies */
    filter: brightness(1.5) saturate(1.2);
    animation-duration: 2s !important; /* Faster pulse during frenzy */
  }

  /* pulse brightness instead of scale to prevent edge jitter/fine lines */
  @keyframes windowPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
  }

  body.reduced .floor .window-glow {
    animation: none !important;
  }

  .card.owned { border-color: var(--good); background: linear-gradient(90deg, #f1faf3, #fff); }
  .card .cost.owned { color: var(--good); }
  .petName { font-family: inherit; font-weight: 700; font-size: 14px; color: var(--ink); border: none; border-bottom: 2px dashed rgba(91,75,67,0.25); background: transparent; width: 100%; padding: 2px 0; }

  .balloon { position: fixed; z-index: 40; font-size: 42px; cursor: pointer; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15)); user-select: none; transition: transform 0.2s; pointer-events: auto; }
  .balloon:hover { transform: scale(1.1); }
  .balloon .basket { position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%); font-size: 14px; }

  .petNameWrap { position: relative; display: flex; align-items: center; }
  .petNameWrap span { position: absolute; right: 4px; font-size: 10px; opacity: 0.5; pointer-events: none; }
  .petName:focus { outline: none; border-bottom-color: var(--accent); }

  .mgrControl { margin-top: 8px; font-size: 11px; font-weight: 700; color: var(--soft); display: flex; align-items: center; gap: 5px; }
  .mgrSel { font-family: inherit; font-size: 11px; padding: 2px 4px; border-radius: 4px; border: 1px solid rgba(91,75,67,0.15); background: #fff; cursor: pointer; color: var(--ink); outline: none; }

  .mgr-badge {
    position: absolute; right: 50px; top: 10px; width: 28px; height: 28px; 
    background: #fff; border: 2px solid var(--accent); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 16px;
    box-shadow: 0 2px 6px var(--shadow); z-index: 15; cursor: help;
    animation: mgrBadgePop 0.4s cubic-bezier(0.17, 0.67, 0.83, 0.67);
  }
  @keyframes mgrBadgePop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

  /* tap & confetti particles */
  .particle { position: fixed; z-index: 250; font-size: 18px; pointer-events: none; will-change: transform, opacity; animation: part 0.85s ease-out forwards; }
  .particle.confetti { width: 9px; height: 9px; border-radius: 2px; }
  @keyframes part { 0% { transform: translate(0,0) scale(1) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), calc(var(--dy) + 46px)) scale(0.5) rotate(200deg); opacity: 0; } }
  body.reduced .particle { display: none; }

  #game { position: relative; height: 100%; display: grid; grid-template-columns: 290px 1fr 340px; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .panel { 
    background: var(--panel); 
    display: flex; 
    flex-direction: column; 
    z-index: 10; /* Keep UI above the sky but let tower wings breathe */
    min-height: 0; 
    transition: opacity 0.3s ease;
  }
  /* Slightly transparent panels help you see the tower's 'wings' on smaller screens */
  .panel:not(:hover) { opacity: 0.96; }

  #left  { box-shadow: 4px 0 20px var(--shadow); overflow-y: auto; overflow-x: hidden; }
  #side  { box-shadow: -4px 0 20px var(--shadow); }
  #left::-webkit-scrollbar, #shop::-webkit-scrollbar { width: 8px; }
  #left::-webkit-scrollbar-thumb, #shop::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 8px; }

  /* left panel */
  #stats { padding: 18px 18px 14px; background: linear-gradient(135deg, #fff, #fff3e6); position: relative; }
  #gearBtn { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 20px; cursor: pointer; opacity: 0.75; transition: transform 0.2s, opacity 0.2s; }
  #gearBtn:hover { opacity: 1; transform: rotate(35deg); }
  #stats h1 { font-size: 20px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; }
  #tod { font-size: 12px; color: var(--soft); font-weight: 700; margin-top: 4px; }
  #coins { font-size: 30px; font-weight: 800; color: var(--accent2); margin-top: 6px; line-height: 1.1; }
  #perSec { font-size: 13px; color: var(--good); font-weight: 700; }
  #perClick { font-size: 12px; color: var(--soft); margin-top: 2px; }
  #playersOnline { display: none; font-size: 11.5px; font-weight: 700; color: var(--good); margin-top: 7px; padding: 4px 9px; border-radius: 20px; background: rgba(107,191,138,0.12); width: fit-content; cursor: pointer; transition: background 0.15s, transform 0.12s; }
  #playersOnline:hover { background: rgba(107,191,138,0.22); transform: translateY(-1px); }
  #playersOnline b { color: var(--accent2); }

  /* Community / Hall of Fame leaderboard */
  #leaderboardBody { max-height: 40vh; overflow-y: auto; }
  .lbList { display: flex; flex-direction: column; gap: 4px; }
  .lbRow { display: grid; grid-template-columns: 28px 1fr auto; grid-template-areas: "rank name score" "rank meta meta"; gap: 0 8px; align-items: center; padding: 7px 10px; border-radius: 10px; background: #f4ece2; }
  .lbRow:nth-child(1) { background: linear-gradient(90deg,#fff6da,#ffe9b0); }
  .lbRow:nth-child(2) { background: linear-gradient(90deg,#f4f1ee,#e8e4df); }
  .lbRow:nth-child(3) { background: linear-gradient(90deg,#fbeede,#f3dcc4); }
  .lbRank { grid-area: rank; font-size: 15px; font-weight: 800; color: var(--accent2); text-align: center; }
  .lbName { grid-area: name; font-weight: 800; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lbScore { grid-area: score; font-weight: 800; font-size: 13px; color: var(--gold); white-space: nowrap; }
  .lbMeta { grid-area: meta; font-size: 11px; color: var(--soft); }

  #boosts { padding: 0 16px; }
  .boostChip { display: flex; align-items: center; gap: 6px; margin: 8px 0; background: linear-gradient(90deg,#fff0d6,#ffe0c2); border: 2px solid var(--gold); border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 800; color: var(--accent2); animation: pulseChip 1s ease-in-out infinite; }
  @keyframes pulseChip { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }

  .sectionLabel { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--soft); padding: 14px 18px 6px; border-top: 2px dashed rgba(91,75,67,0.15); margin-top: 8px; }

  /* radio */
  #radio { padding: 2px 16px 6px; }
  #stations { display: flex; flex-wrap: wrap; gap: 6px; }
  .stationChip { font-family: inherit; font-size: 12px; font-weight: 700; border: 2px solid rgba(91,75,67,0.15); background: #fff; color: var(--soft); padding: 6px 9px; border-radius: 20px; cursor: pointer; transition: all 0.12s; }
  .stationChip:hover { border-color: var(--accent); }
  .stationChip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .volRow { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
  .volRow span { font-size: 14px; }
  input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 6px; border-radius: 6px; background: #e6dccf; outline: none; }
  input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 1px 3px var(--shadow); }
  input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }

  #lifetime { padding: 0 18px 6px; }
  .statRow { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; }
  .statRow.clickable { cursor: pointer; border-radius: 4px; padding: 4px 6px; margin: 0 -6px; transition: background 0.2s; }
  .statRow.clickable:hover { background: rgba(91, 75, 67, 0.05); }
  .statRow .k { color: var(--soft); }
  .statRow .v { font-weight: 700; }

  #fullStatsBtn {
    width: calc(100% - 36px); margin: 10px 18px; font-family: inherit; font-size: 11px; font-weight: 700;
    border: none; background: #f0e6dc; color: var(--soft); padding: 7px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
  }
  #fullStatsBtn:hover { background: var(--accent); color: #fff; }

  /* sidebar: a handful of in-progress achievements */
  #achList { padding: 4px 16px 4px; display: flex; flex-direction: column; gap: 7px; }
  .achMini { display: flex; align-items: center; gap: 9px; cursor: help; }
  .achMiniIco { font-size: 20px; flex: none; width: 24px; text-align: center; filter: grayscale(0.4); opacity: 0.85; }
  .achMiniMid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .achMiniName { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .achMini .pbar { margin-top: 0; }
  .achMiniNum { font-size: 10.5px; font-weight: 800; color: var(--soft); flex: none; }
  .achMiniDone { font-size: 12px; font-weight: 700; color: var(--good); text-align: center; padding: 6px 0; }
  #achViewAll { width: calc(100% - 32px); margin: 8px 16px 2px; font-family: inherit; font-size: 12px; font-weight: 800; border: none; background: linear-gradient(135deg, var(--gold), var(--accent)); color: #fff; padding: 8px; border-radius: 9px; cursor: pointer; transition: all 0.15s; box-shadow: 0 2px 8px var(--shadow); }
  #achViewAll:hover { filter: brightness(1.06); transform: translateY(-1px); }

  /* achievements page (modal) */
  .achModalBox { width: min(640px, 94vw); }
  #achModalBody { max-height: 62vh; overflow-y: auto; margin: 4px -6px 4px 0; padding-right: 6px; }
  #achModalBody::-webkit-scrollbar { width: 8px; }
  #achModalBody::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 8px; }
  .achCatHead { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--accent2); margin: 14px 2px 8px; padding-bottom: 5px; border-bottom: 2px dashed rgba(91,75,67,0.15); }
  .achCatHead:first-child { margin-top: 0; }
  .achCatHead span { color: var(--soft); font-size: 11px; }
  .achGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
  @media (max-width: 560px) { .achGrid { grid-template-columns: 1fr; } }
  .achTile { display: flex; gap: 10px; align-items: flex-start; background: #f4ece2; border: 2px solid transparent; border-radius: 12px; padding: 10px; opacity: 0.75; transition: all 0.15s; }
  .achTile.got { opacity: 1; background: linear-gradient(135deg, #fff5e6, #ffe6cf); border-color: rgba(233,185,73,0.5); }
  .achTile.unclaimed { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); animation: pulseChip 1.1s ease-in-out infinite; }
  .achTileIco { font-size: 26px; flex: none; width: 32px; text-align: center; }
  .achTile:not(.got) .achTileIco { filter: grayscale(1); opacity: 0.55; }
  .achTileInfo { flex: 1; min-width: 0; }
  .achTileName { font-size: 13px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 6px; }
  .achClaimTag { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; color: #fff; background: var(--accent2); padding: 1px 6px; border-radius: 8px; }
  .achTileDesc { font-size: 11px; color: var(--soft); margin: 2px 0 5px; }
  .achTileReward { font-size: 11px; font-weight: 700; color: var(--good); }
  .achTileProg { font-size: 10px; font-weight: 800; color: var(--soft); margin-top: 3px; text-align: right; }

  #verLine { text-align: center; font-size: 11px; color: var(--soft); padding: 8px; }
  #verLine a { color: var(--accent2); cursor: pointer; font-weight: 700; text-decoration: none; }
  #verLine a:hover { text-decoration: underline; }

  #leftFooter { position: sticky; bottom: 0; margin-top: auto; background: var(--panel); padding: 12px; border-top: 2px solid rgba(91,75,67,0.12); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; z-index: 3; }
  #leftFooter button { font-family: inherit; font-size: 12px; font-weight: 700; border: none; background: #f0e6dc; color: var(--soft); padding: 8px; border-radius: 8px; cursor: pointer; transition: all 0.12s; }
  #leftFooter button:hover { background: var(--accent); color: #fff; }

  /* next-goal progress */
  #nextAch { padding: 2px 18px 6px; }
  #mainRebirth { padding: 2px 18px 6px; cursor: pointer; border-radius: 8px; transition: background 0.2s; }
  #mainRebirth:hover { background: rgba(91, 75, 67, 0.05); }
  .rbMainTop { display: flex; justify-content: space-between; align-items: baseline; }
  .rbMainStars { font-size: 15px; font-weight: 800; color: var(--accent2); }
  .rbMainGain { font-size: 11px; font-weight: 700; color: var(--good); }
  .naName { font-size: 13px; font-weight: 800; color: var(--ink); }
  .naSub { font-size: 11px; color: var(--soft); margin: 2px 0 5px; }

  /* tower */
  #towerWrap { position: relative; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column-reverse; align-items: center; padding: 30px 0 0 0; scroll-behavior: smooth; height: 100%; min-height: 0; }
  #towerWrap::-webkit-scrollbar { width: 10px; }
  #towerWrap::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }
  .ground { position: relative; z-index: 2; flex: none; width: min(710px, 97%); min-height: 50px; background: linear-gradient(180deg, #b08968, #7d5a3e); border-radius: 0 0 20px 20px; margin-bottom: 90px; transition: filter 1.5s ease; border-top: 6px solid rgba(0,0,0,0.15); box-shadow: 0 12px 24px var(--shadow), inset 0 -6px 0 rgba(0,0,0,0.2); }
  body.night .ground { filter: brightness(0.6); }
  /* Each floor is a detailed, look-at-only room scene (the Build tab handles upgrading). */
  /* base floor width; floors with modular wings grow into the sky via --wing-scale
     (the room keeps its size because scenes.js widens the viewBox to match) */
  .floor { 
    width: min(calc(680px * var(--wing-scale, 1)), 96%); 
    flex: none; 
    background: transparent; 
    border: none; 
    position: relative; 
    overflow: visible; /* Allow wings to have decorative overhangs */
    margin-bottom: 0; /* floors stack seamlessly — no sky peeking through between them */
    transition: box-shadow 0.2s ease, width 0.8s cubic-bezier(.34, 1.56, 0.64, 1); 
    animation: floorIn 0.45s cubic-bezier(.2,1.3,.4,1); 
    z-index: 5; /* Raise tower above the background skyline and buildings */
  }

  body.reduced .floor { transition: none; }
  .floor-scene { display: block; width: 100%; height: auto; aspect-ratio: auto; }
  .floor:first-child { border-radius: 16px 16px 0 0; }
  .floor:first-child .floor-scene { border-radius: 12px 12px 0 0; }
  /* highlight the top edge of each floor to catch the light */
  .floor::before { content: ""; position: absolute; top: 0; left: var(--edge-l, 0); right: var(--edge-r, 0); height: 2px; background: rgba(255,255,255,0.35); z-index: 13; pointer-events: none; }

  /* ✨ prestige glow-up: the tower grows fancier the more Stars you've earned */
  body[data-prestige="1"] .floor::before,
  body[data-prestige="2"] .floor::before,
  body[data-prestige="3"] .floor::before,
  body[data-prestige="4"] .floor::before { height: 3px; background: linear-gradient(90deg, rgba(255,233,168,0.25), #ffd36b, rgba(255,233,168,0.25)); box-shadow: 0 0 7px rgba(255,200,80,0.65); }
  body[data-prestige="2"] .floor-plate .fp-lvl,
  body[data-prestige="3"] .floor-plate .fp-lvl,
  body[data-prestige="4"] .floor-plate .fp-lvl { box-shadow: inset 0 -1px 0 rgba(0,0,0,0.18), 0 0 9px rgba(255,200,80,0.75); }
  body[data-prestige="3"] .floor::before,
  body[data-prestige="4"] .floor::before { background-size: 200% 100%; animation: prestigeShimmer 3s linear infinite; }
  @keyframes prestigeShimmer { to { background-position: 200% 0; } }
  body[data-prestige="4"] #towerWrap { filter: drop-shadow(0 0 16px rgba(255,200,90,0.4)); }
  body.reduced .floor::before { animation: none !important; }

  /* Wing Unlock Animation */
  .wing-unlock-anim {
    animation: wingPop 0.8s cubic-bezier(0.17, 0.89, 0.32, 1.49);
  }
  @keyframes wingPop {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.02); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
  }

  /* nameplate: floor name + level, purely informational */
  .floor-plate { position: absolute; left: 10px; bottom: 10px; z-index: 12; display: flex; align-items: center; gap: 8px; background: rgba(255,251,245,0.92); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); padding: 4px 5px 4px 11px; border-radius: 11px; border-left: 3px solid var(--fc, var(--accent)); box-shadow: 0 3px 9px var(--shadow); pointer-events: auto; cursor: pointer; transition: transform 0.14s ease, box-shadow 0.14s ease; }
  .floor-plate:hover { transform: translateY(-2px); box-shadow: 0 6px 16px var(--shadow); }
  .floor-plate:active { transform: translateY(0); }
  .floor-plate .fp-name { font-weight: 800; font-size: 12.5px; color: var(--ink); white-space: nowrap; letter-spacing: 0.2px; }
  .floor-plate .fp-lvl { font-size: 11px; font-weight: 800; color: #fff; background: var(--fc, var(--accent)); padding: 3px 9px; border-radius: 8px; box-shadow: inset 0 -1px 0 rgba(0,0,0,0.18); }
  .floor-plate::after { content: "›"; font-size: 15px; font-weight: 800; color: var(--fc, var(--accent)); opacity: 0; width: 0; margin-left: -8px; transition: opacity 0.14s ease, width 0.14s ease, margin-left 0.14s ease; }
  .floor-plate:hover::after { opacity: 0.8; width: 8px; margin-left: 0; }

  /* flash a Build-list card when its floor nameplate is clicked */
  .card.cardFlash { animation: cardFlash 1.4s ease; }
  @keyframes cardFlash {
    0% { box-shadow: 0 0 0 0 rgba(233,185,73,0); }
    14% { box-shadow: 0 0 0 4px var(--accent), 0 6px 16px var(--shadow); transform: translateY(-2px) scale(1.02); }
    55% { box-shadow: 0 0 0 3px var(--gold); transform: none; }
    100% { box-shadow: 0 0 0 0 rgba(233,185,73,0); transform: none; }
  }

  /* interactive feature floors (e.g. the Wonder Wheel) keep a tappable widget */
  .floor.interactive { cursor: default; }
  /* Big, central, pulsing call-to-action so the Wonder Wheel is impossible to miss */
  .floor .playBtn { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 14; font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 16px; letter-spacing: 0.3px; border: none; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 12px 30px; border-radius: 28px; cursor: pointer; white-space: nowrap; box-shadow: 0 6px 18px rgba(0,0,0,0.35); transition: transform 0.12s, filter 0.12s; animation: playBtnPulse 1.9s ease-in-out infinite; }
  .floor .playBtn:hover { transform: translateX(-50%) translateY(-2px); filter: brightness(1.08); }
  .floor .playBtn:active { transform: translateX(-50%) translateY(0) scale(0.97); }
  .floor.wheel-open .playBtn { display: none; }
  @keyframes playBtnPulse {
    0%, 100% { box-shadow: 0 6px 18px rgba(0,0,0,0.3), 0 0 0 0 rgba(244,162,97,0.55); }
    50% { box-shadow: 0 8px 22px rgba(0,0,0,0.35), 0 0 0 12px rgba(244,162,97,0); }
  }
  .floor .playBtn.ready { background: linear-gradient(135deg, var(--good), #3fa46a); animation: playBtnReady 1.15s ease-in-out infinite; }
  @keyframes playBtnReady {
    0%, 100% { box-shadow: 0 6px 18px rgba(0,0,0,0.3), 0 0 0 0 rgba(107,191,138,0.65); }
    50% { box-shadow: 0 9px 26px rgba(0,0,0,0.35), 0 0 0 14px rgba(107,191,138,0); }
  }
  body.reduced .floor .playBtn { animation: none; }

  /* free-spin badge: the come-back hook on the Wonder Wheel floor */
  .freeSpinBadge { position: absolute; right: 10px; top: 10px; z-index: 15; font-family: inherit; font-weight: 800; font-size: 11.5px; border: none; background: rgba(255,251,245,0.92); color: var(--ink); padding: 5px 11px; border-radius: 20px; cursor: pointer; box-shadow: 0 3px 9px var(--shadow); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: transform 0.12s; white-space: nowrap; }
  .freeSpinBadge:hover { transform: translateY(-2px); }
  .freeSpinBadge.ready { background: linear-gradient(135deg, var(--good), #9be8b4); color: #134426; animation: pulseChip 0.85s ease-in-out infinite; }
  .floor.wheel-open .freeSpinBadge { display: none; }
  body.reduced .freeSpinBadge.ready { animation: none; }

  /* inline Wonder Wheel panel docked to the bottom of its floor */
  .wheelPanel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(46,33,40,0.93); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 16px 16px 0 0; padding: 12px 14px 14px; box-shadow: 0 -10px 28px rgba(0,0,0,0.45); color: #fff; transform: translateY(103%); opacity: 0; pointer-events: none; transition: transform 0.34s cubic-bezier(.2,1,.3,1), opacity 0.25s; text-align: center; }
  .floor.wheel-open .wheelPanel { transform: translateY(0); opacity: 1; pointer-events: auto; }
  body.reduced .wheelPanel { transition: none; }
  .wheelHead { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 13.5px; position: relative; }
  .wheelHead #casinoCoins { font-weight: 700; color: var(--gold); }
  .wheelClose { position: absolute; right: 0; top: -2px; border: none; background: rgba(255,255,255,0.12); color: #fff; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 13px; font-weight: 800; line-height: 1; transition: background 0.12s; }
  .wheelClose:hover { background: rgba(255,255,255,0.25); }
  .wheelPanel .reels { gap: 8px; margin: 9px 0; }
  .wheelPanel .reels span { width: 52px; height: 52px; font-size: 30px; border-width: 2px; border-radius: 11px; }
  .wheelPanel #casinoResult { color: #fff; min-height: 22px; font-size: 13px; }
  .wheelPanel #casinoResult.win { color: #ffe08a; }
  .wheelPanel .betRow { color: #f3e6da; margin-top: 6px; gap: 6px; }
  .spinRow { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 9px; flex-wrap: wrap; }
  .spinRow #betAmt { font-size: 12px; color: #f3e6da; }
  .spinRow #spinBtn { font-family: inherit; font-weight: 800; font-size: 14px; border: none; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 9px 22px; border-radius: 22px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.35); transition: transform 0.12s, filter 0.12s; }
  .spinRow #spinBtn:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .wheelPanel .casinoStats { color: #d9c9bc; margin-top: 9px; }
  .wheelPanel .payTable { font-size: 10.5px; color: #cdbbae; margin-top: 9px; opacity: 0.85; line-height: 1.5; }

  @keyframes floorIn { from { transform: translateY(20px) scale(0.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

  /* ----- living scenes: small looping animations on scene props ----- */
  /* SVG elements need fill-box so transforms pivot around the prop itself */
  .floor-scene .cz-spin { transform-box: fill-box; transform-origin: center; animation: czSpin 16s linear infinite; }
  @keyframes czSpin { to { transform: rotate(360deg); } }
  .floor-scene .cz-twinkle { animation: czTwinkle 2.6s ease-in-out infinite; }
  @keyframes czTwinkle { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
  .floor-scene .cz-bee { animation: czBee 3.2s ease-in-out infinite; }
  @keyframes czBee { 0% { transform: translate(0,0); } 25% { transform: translate(2px,-1.5px); } 50% { transform: translate(0,-2.6px); } 75% { transform: translate(-2px,-1px); } 100% { transform: translate(0,0); } }
  .floor-scene .cz-flicker { animation: czFlicker 4s ease-in-out infinite; }
  @keyframes czFlicker { 0%, 100% { opacity: 1; } 12% { opacity: 0.6; } 16% { opacity: 0.92; } 55% { opacity: 0.78; } 60% { opacity: 1; } 78% { opacity: 0.65; } 82% { opacity: 0.95; } }
  .floor-scene .cz-flame { transform-box: fill-box; transform-origin: center bottom; animation: czFlame 1.3s ease-in-out infinite; }
  @keyframes czFlame { 0%, 100% { transform: scaleY(1) scaleX(1); opacity: 0.85; } 50% { transform: scaleY(1.22) scaleX(0.9); opacity: 1; } }
  .floor-scene .cz-steam { transform-box: fill-box; transform-origin: center bottom; animation: czSteam 3.4s ease-in-out infinite; }
  @keyframes czSteam { 0% { opacity: 0; transform: translateY(0) scaleY(0.7); } 30% { opacity: 0.5; } 100% { opacity: 0; transform: translateY(-6px) scaleY(1.15); } }
  /* cats: occasional blink (squash the eyes) & a lazy tail flick */
  .floor-scene .cz-blink { transform-box: fill-box; transform-origin: center; animation: czBlink 5.2s ease-in-out infinite; }
  @keyframes czBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
  .floor-scene .cz-tail { transform-box: fill-box; transform-origin: right top; animation: czTail 4.6s ease-in-out infinite; }
  @keyframes czTail { 0%, 55%, 100% { transform: rotate(0deg); } 70% { transform: rotate(-11deg); } 85% { transform: rotate(7deg); } }

  /* lanterns: a soft, subtle breathing glow after dark */
  body.night .floor-scene .cz-lglow { animation: czLampGlow 4.5s ease-in-out infinite; }
  @keyframes czLampGlow { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.48; } }
  /* lamps: a gentle pool of light spilling down out of the shade at night */
  body.night .floor-scene .cz-lampcone { animation: czLampCone 5s ease-in-out infinite; }
  @keyframes czLampCone { 0%, 100% { opacity: 0.12; } 50% { opacity: 0.26; } }

  /* cinema: a slow looping "movie" of three cross-fading frames (a panning bird in frame 1) */
  .floor-scene .cz-reel { transform-box: fill-box; animation: czReel 27s ease-in-out infinite; }
  .floor-scene .cz-reel2 { animation-delay: 9s; }
  .floor-scene .cz-reel3 { animation-delay: 18s; }
  @keyframes czReel { 0%, 30% { opacity: 1; } 35%, 95% { opacity: 0; } 100% { opacity: 1; } }
  .floor-scene .cz-reelpan { transform-box: fill-box; animation: czReelPan 9s linear infinite; }
  @keyframes czReelPan { from { transform: translateX(-11px); } to { transform: translateX(23px); } }
  /* cinema screen: a faint, natural night sheen on the picture */
  body.night .floor-scene .cz-screenglow { animation: czScreenGlow 6s ease-in-out infinite; }
  @keyframes czScreenGlow { 0%, 100% { opacity: 0.08; } 50% { opacity: 0.18; } }
  /* speaker woofers: a slow, subtle pulse */
  .floor-scene .cz-woofer { transform-box: fill-box; transform-origin: center; animation: czWoofer 2.6s ease-in-out infinite; }
  @keyframes czWoofer { 0%, 100% { opacity: 0; transform: scale(0.92); } 50% { opacity: 0.26; transform: scale(1.05); } }

  body.reduced .floor-scene * { animation: none !important; }

  /* fallback floor icon (only used if the scene library fails to load) */
  .floor-svg { width: 44px; height: 44px; margin: 16px; fill: var(--fc); z-index: 2; }
  .card-svg { width: 34px; height: 34px; fill: var(--soft); transition: fill 0.2s; }
  .card:hover .card-svg { fill: var(--accent); }
  .card.dim .card-svg { opacity: 0.5; }

  .payPop { position: absolute; right: 14px; top: 10px; font-size: 13px; font-weight: 800; color: var(--gold); text-shadow: 0 1px 3px rgba(0,0,0,0.45); animation: rise 1.1s ease-out forwards; pointer-events: none; z-index: 13; }
  @keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
  #roof { width: min(560px, 86%); flex: none; min-height: 130px; background: linear-gradient(180deg, var(--accent), var(--accent2)); border-radius: 18px 18px 6px 6px; margin-bottom: -2px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; cursor: pointer; box-shadow: 0 8px 0 rgba(0,0,0,0.08); transition: transform 0.05s ease, box-shadow 1.5s ease; position: relative; z-index: 2; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
  #roof * { pointer-events: none; }   /* taps always register on the roof, never on a child node */
  body.night #roof { box-shadow: 0 8px 0 rgba(0,0,0,0.08), 0 0 34px 6px rgba(244,162,97,0.55); }
  #roof:active { transform: scale(0.97) translateY(2px); }
  #roof .big { font-size: 50px; }
  #roof .label { font-weight: 700; margin-top: 4px; letter-spacing: 0.5px; }
  #roof .hint { font-size: 11px; opacity: 0.85; margin-top: 2px; }
  .clickFloat { position: fixed; pointer-events: none; z-index: 50; font-weight: 800; color: var(--gold); text-shadow: 0 1px 2px rgba(0,0,0,0.2); animation: floatUp 0.9s ease-out forwards; }
  .clickFloat.big { color: var(--accent2); text-shadow: 0 2px 6px rgba(231,111,81,0.6); }
  @keyframes floatUp { from { transform: translateY(0) scale(1); opacity: 1; } to { transform: translateY(-60px) scale(1.4); opacity: 0; } }

  /* TAP FRENZY craziness */
  body.frenzy::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60; animation: frenzyGlow 0.45s ease-in-out infinite alternate; }
  @keyframes frenzyGlow {
    from { box-shadow: inset 0 0 70px 16px rgba(244,162,97,0.35); }
    to   { box-shadow: inset 0 0 130px 34px rgba(231,111,81,0.6); }
  }
  body.frenzy #roof { animation: roofFrenzy 0.32s ease-in-out infinite alternate; }
  @keyframes roofFrenzy { from { transform: scale(1) rotate(-1deg); } to { transform: scale(1.05) rotate(1deg); } }

  /* PRODUCTION FRENZY glow (green, distinct from tap frenzy) */
  body.prodfrenzy::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 59; animation: prodGlow 0.5s ease-in-out infinite alternate; }
  @keyframes prodGlow {
    from { box-shadow: inset 0 0 70px 16px rgba(107,191,138,0.3); }
    to   { box-shadow: inset 0 0 120px 32px rgba(107,191,138,0.55); }
  }

  /* excited moon face during any frenzy */
  body.frenzy #moon .mouth, body.prodfrenzy #moon .mouth { width: 16px; height: 16px; border: none; border-radius: 50%; background: #6f6885; top: 33px; left: 24px; }
  body.frenzy #moon .eye, body.prodfrenzy #moon .eye { height: 5px; top: 28px; }

  /* big frenzy countdown banner */
  #frenzyBanner { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
  .fban { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 18px; color: #fff; padding: 8px 22px; border-radius: 30px; box-shadow: 0 6px 20px rgba(0,0,0,0.28); animation: bannerPulse 0.5s ease-in-out infinite alternate; }
  .fban.prod { background: linear-gradient(90deg, #f4a261, #e76f51); }
  .fban.tap { background: linear-gradient(90deg, #9b6dd6, #6d8bd6); }
  .fban.happy { background: linear-gradient(90deg, #f6a5c0, #ec6f9b); }
  .boostChip.happy { background: linear-gradient(90deg,#ffe0ec,#ffc2d6); border-color: #ec6f9b; color: #c2447a; }
  @keyframes bannerPulse { from { transform: scale(1); } to { transform: scale(1.06); } }
  body.reduced .fban { animation: none; }

  /* "new build available" banner — tucks into the bottom-right, just above the version/changelog corner */
  #updateBanner { position: fixed; right: 10px; bottom: 32px; z-index: 200;
    transform: translateY(14px); opacity: 0; pointer-events: none;
    display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 16px; border-radius: 14px;
    background: linear-gradient(90deg, #6bbf8a, #4aa9a0); color: #fff; box-shadow: 0 6px 22px rgba(0,0,0,0.3);
    font-weight: 700; font-size: 13.5px; transition: transform 0.35s cubic-bezier(.2,.9,.3,1.2), opacity 0.35s ease; max-width: min(360px, 92vw); }
  #updateBanner.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
  #updateBanner .uMsg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #updateBanner button { font-family: inherit; font-weight: 700; border: none; cursor: pointer; border-radius: 20px; padding: 6px 12px; font-size: 13px; }
  #updateRefresh { background: #fff; color: #2a7a5e; }
  #updateRefresh:hover { filter: brightness(1.05); }
  #updateDismiss { background: rgba(255,255,255,0.22); color: #fff; padding: 6px 9px; border-radius: 50%; }

  /* friendly disasters: a soft pop-up card you tap to resolve for a reward */
  .eventCard { position: fixed; left: 50%; top: 60px; transform: translate(-50%, -170%); z-index: 90; display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 16px; padding: 12px 14px; box-shadow: 0 12px 36px rgba(0,0,0,0.35); border: 2px solid var(--gold); max-width: min(420px, 92vw); opacity: 0; transition: transform 0.4s cubic-bezier(.2,1.3,.4,1), opacity 0.3s; }
  .eventCard.show { transform: translate(-50%, 0); opacity: 1; }
  body.reduced .eventCard { transition: opacity 0.2s; }
  .eventCard .evIcon { font-size: 34px; line-height: 1; animation: bonusBob 1.4s ease-in-out infinite; }
  body.reduced .eventCard .evIcon { animation: none; }
  .eventCard .evText { display: flex; flex-direction: column; gap: 1px; }
  .eventCard .evText b { font-size: 14px; color: var(--ink); }
  .eventCard .evText span { font-size: 11.5px; color: var(--soft); }
  .eventCard .evBtn { margin-left: auto; font-family: inherit; font-weight: 800; font-size: 13px; border: none; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 9px 15px; border-radius: 14px; cursor: pointer; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,0.25); transition: transform 0.12s, filter 0.12s; }
  .eventCard .evBtn:hover { transform: translateY(-2px); filter: brightness(1.08); }

  /* escaped apiary bees — buzz around the whole screen until caught */
  .bee { position: fixed; z-index: 110; font-size: 30px; cursor: pointer; user-select: none; -webkit-user-select: none; pointer-events: auto; will-change: left, top, transform; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.28)); }
  .bee:hover { filter: drop-shadow(0 2px 7px rgba(233,185,73,0.9)) brightness(1.1); }
  .beeCaught { animation: beeCaught 0.3s ease forwards; pointer-events: none; }
  @keyframes beeCaught { to { transform: scale(0) rotate(45deg); opacity: 0; } }
  .beeGone { transition: opacity 0.5s ease, transform 0.5s ease; opacity: 0; transform: translateY(-50px) scale(0.5); pointer-events: none; }
  .beeBanner { position: fixed; top: 12px; left: 50%; transform: translate(-50%, -170%); z-index: 85; background: linear-gradient(135deg, #fff3cf, #ffe08a); color: #6b5326; font-size: 13.5px; font-weight: 700; padding: 9px 18px; border-radius: 30px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); border: 2px solid var(--gold); opacity: 0; transition: transform 0.4s cubic-bezier(.2,1.3,.4,1), opacity 0.3s; white-space: nowrap; max-width: 94vw; }
  .beeBanner.show { transform: translate(-50%, 0); opacity: 1; }
  .beeBanner .beeLeft { display: inline-block; background: var(--accent2); color: #fff; padding: 2px 9px; border-radius: 12px; font-weight: 800; margin-left: 4px; }
  body.reduced .beeBanner { transition: opacity 0.2s; }

  /* VIP elevator: a little glass car that zips up the side of the tower */
  .vipElevator { position: fixed; z-index: 46; font-size: 30px; cursor: pointer; pointer-events: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3)); transition: top 3.2s cubic-bezier(.4,0,.5,1); user-select: none; }
  .vipElevator:hover { transform: scale(1.12); }
  .vipElevator.leaving { transition: top 0.7s ease-in, opacity 0.7s; opacity: 0; }

  /* random bonus */
  .bonus { position: fixed; z-index: 45; font-size: 46px; cursor: pointer; filter: drop-shadow(0 0 14px rgba(233,185,73,0.9)); animation: bonusBob 1.3s ease-in-out infinite, bonusIn 0.4s ease; }
  .bonus.out { animation: bonusOut 0.4s ease forwards; }
  @keyframes bonusBob { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12px) rotate(6deg); } }
  @keyframes bonusIn { from { transform: scale(0); } to { transform: scale(1); } }
  @keyframes bonusOut { to { transform: scale(0); opacity: 0; } }

  /* right panel */
  #miniStat { display: none; padding: 12px 16px; background: linear-gradient(135deg,#fff,#fff3e6); font-weight: 800; color: var(--accent2); }
  #miniStat small { display: block; font-size: 11px; color: var(--good); }
  #buyAmt { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: #fff8f0; border-bottom: 2px solid rgba(91,75,67,0.1); flex-wrap: wrap; }
  #buyAmt .bal { font-size: 11px; font-weight: 800; color: var(--soft); text-transform: uppercase; letter-spacing: 0.5px; margin-right: 2px; }
  .amtBtn { flex: 1; min-width: 48px; font-family: inherit; font-size: 12px; font-weight: 800; border: 2px solid rgba(91,75,67,0.15); background: #fff; color: var(--soft); padding: 6px 0; border-radius: 8px; cursor: pointer; transition: all 0.12s; }
  .amtBtn:hover { border-color: var(--accent); }
  .amtBtn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
  .amtBtn[data-amt="max"] { display: none; }
  .tabs { display: flex; border-bottom: 2px solid rgba(91,75,67,0.1); }
  .tab { flex: 1; padding: 13px 4px; text-align: center; cursor: pointer; font-weight: 700; font-size: 12px; white-space: nowrap; color: var(--soft); transition: all 0.15s; }
  .tab.active { color: var(--accent2); box-shadow: inset 0 -3px 0 var(--accent2); background: #fff8f0; }
  #shop { flex: 1; overflow-y: auto; padding: 14px; }
  .card { background: #fff; border: 2px solid rgba(91,75,67,0.1); border-radius: 14px; padding: 13px; margin-bottom: 10px; display: flex; align-items: center; gap: 11px; cursor: pointer; transition: all 0.12s; }
  .card:hover:not(.locked):not(.preview) { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 10px var(--shadow); }
  .card.locked { opacity: 0.55; cursor: not-allowed; }
  .card.dim { opacity: 0.5; }   /* can't afford yet, but still clickable */
  .card.preview { opacity: 0.4; cursor: default; border-style: dashed; }
  .card .ce { font-size: 32px; width: 46px; text-align: center; }
  .card .cinfo { flex: 1; min-width: 0; }
  .card .cname { font-weight: 700; font-size: 14px; }
  .card .cdesc { font-size: 11px; color: var(--soft); margin-top: 2px; }
  .card .cost { font-weight: 800; font-size: 14px; color: var(--gold); white-space: nowrap; }
  .card .cost.cant { color: #c98; }

  /* unified Build tab: click anywhere on a card to build / upgrade that floor */
  /* affordable now â†’ green-highlighted; can't afford yet â†’ grayed out */
  .card.ready { border-color: rgba(107,191,138,0.6); background: linear-gradient(90deg, #f4fbf5, #fff); }
  .card.ready .costAct { color: var(--good); }
  .card.dim { opacity: 1; filter: grayscale(0.85); background: #f3efea; border-color: rgba(91,75,67,0.1); }
  .card.dim .cname, .card.dim .cdesc, .card.dim .costAct { color: #9b8f86; }
  .card.dim .costVal { color: #a99; }
  .card.dim .lvlBadge { background: #b5a79e; }
  .card.dim:hover { transform: none; box-shadow: none; border-color: rgba(91,75,67,0.1); }
  .ownedCard .cdesc, .buildCard .cdesc { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
  .lvlBadge { flex: none; font-size: 11px; font-weight: 800; color: #fff; background: var(--accent2); padding: 2px 9px; border-radius: 20px; line-height: 1.4; }
  .upRate { color: var(--good); font-weight: 700; }
  /* identical right-hand cost column on every card â†’ uniform sizing */
  .card .cost {
    flex: none; align-self: stretch; min-width: 92px; display: flex; flex-direction: column;
    align-items: flex-end; justify-content: center; gap: 2px; text-align: right;
  }
  .cost .costAct { font-size: 10px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; color: var(--soft); white-space: nowrap; }
  .buildCard .cost .costAct { color: var(--good); }
  .cost .costVal { font-size: 14px; font-weight: 800; color: var(--gold); white-space: nowrap; }
  .cost .costVal.cant { color: #c2a07e; }

  /* goal-gradient progress bars */
  .pbar { height: 5px; background: rgba(91,75,67,0.13); border-radius: 4px; margin-top: 7px; overflow: hidden; }
  .pfill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width 0.3s ease; }
  .pbar.ready .pfill { background: linear-gradient(90deg, var(--good), #57b07a); }
  .pbar.starbar { height: 9px; margin: 14px 0 4px; }

  .rebirthBox { text-align: center; padding: 8px 4px; }
  .rbStars { font-size: 26px; font-weight: 800; color: var(--accent2); }
  .rbBonus { font-size: 12.5px; color: var(--good); font-weight: 700; margin-top: 4px; }
  .rebirthBox hr { border: none; border-top: 2px dashed rgba(91,75,67,0.15); margin: 14px 0; }
  .rbGain { font-size: 15px; }
  .rbAfter { font-size: 12.5px; color: var(--soft); margin-top: 4px; }
  .rbWarn { font-size: 11.5px; color: var(--soft); margin: 12px 0; line-height: 1.5; }
  #rebirthBtn { font-family: inherit; font-size: 15px; font-weight: 800; border: none; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; padding: 12px 24px; border-radius: 12px; cursor: pointer; transition: all 0.12s; }
  #rebirthBtn:hover { transform: translateY(-1px); filter: brightness(1.05); }
  #rebirthBtn.dim { background: #d8ccc0; cursor: not-allowed; }
  .rbHint { font-size: 11px; color: var(--soft); margin-top: 12px; line-height: 1.4; }

  #toastContainer { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; z-index: 500; pointer-events: none; }
  .toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 30px; font-size: 13px; font-weight: 600; opacity: 0; transform: translateY(10px); transition: opacity 0.3s, transform 0.3s; pointer-events: auto; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.shake { animation: toastShake 0.4s cubic-bezier(.36,.07,.19,.97) both; }

  @keyframes toastShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
  }

  /* big celebratory announcement banner (frenzies, free spins) */
  .bigAnnounce {
    position: fixed; top: 18px; left: 50%; z-index: 520;
    display: flex; align-items: center; gap: 14px;
    min-width: 280px; max-width: min(460px, 92vw);
    padding: 14px 16px 14px 18px;
    background: linear-gradient(135deg, #fff, #fff3e6);
    border-radius: 18px; border: 2px solid var(--gold);
    box-shadow: 0 14px 40px rgba(0,0,0,0.32);
    transform: translate(-50%, -170%); opacity: 0;
    transition: transform 0.45s cubic-bezier(.2,1.3,.4,1), opacity 0.3s, filter 0.12s;
  }
  .bigAnnounce.show { transform: translate(-50%, 0); opacity: 1; }
  .bigAnnounce.clickable { cursor: pointer; }
  .bigAnnounce.clickable:hover { filter: brightness(1.04); }
  .baIcon { font-size: 40px; line-height: 1; flex: none; animation: bonusBob 1.4s ease-in-out infinite; }
  .baText { flex: 1; min-width: 0; }
  .baTitle { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 18px; color: var(--accent2); line-height: 1.12; }
  .baSub { font-size: 12px; color: var(--soft); font-weight: 600; margin-top: 2px; }
  .baCta { flex: none; font-family: inherit; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); padding: 9px 14px; border-radius: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.22); animation: pulseChip 1s ease-in-out infinite; white-space: nowrap; }
  .baClose { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.3); opacity: 0.85; }
  .baClose:hover { opacity: 1; }
  .bigAnnounce.ba-prod { border-color: var(--accent); }
  .bigAnnounce.ba-tap { border-color: #9b6dd6; background: linear-gradient(135deg, #fff, #f1ecfb); }
  .bigAnnounce.ba-tap .baTitle { color: #7a4fc0; }
  .bigAnnounce.ba-spin, .bigAnnounce.ba-free { border-color: var(--good); background: linear-gradient(135deg, #fff, #eef9f1); }
  .bigAnnounce.ba-spin .baTitle, .bigAnnounce.ba-free .baTitle { color: #2f9e63; }
  .bigAnnounce.ba-coin { border-color: var(--gold); }
  body.reduced .bigAnnounce { transition: opacity 0.2s; }
  body.reduced .baIcon, body.reduced .baCta { animation: none; }

  /* modals */
  #modal, #settings, #changelog, #achPop, #achModal, #communityModal, #namePop, #howto, #casino, #statsModal, #sharePop { position: fixed; inset: 0; z-index: 200; background: rgba(40,30,25,0.55); display: none; align-items: center; justify-content: center; }
  #modal.show, #settings.show, #changelog.show, #achPop.show, #achModal.show, #communityModal.show, #namePop.show, #howto.show, #casino.show, #statsModal.show, #sharePop.show { display: flex; }
  #shareBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 4px; }
  .shareBtn { font-family: inherit; font-size: 13.5px; font-weight: 700; border: 2px solid rgba(91,75,67,0.15); background: #fff; color: var(--ink); padding: 11px 8px; border-radius: 12px; cursor: pointer; transition: all 0.12s; display: flex; align-items: center; justify-content: center; gap: 6px; }
  .shareBtn:hover { transform: translateY(-1px); filter: brightness(1.03); border-color: var(--accent); }
  .shareBtn.fb { background: #1877f2; color: #fff; border-color: #1877f2; }
  .shareBtn.x { background: #14171a; color: #fff; border-color: #14171a; }
  .shareBtn.wa { background: #25d366; color: #fff; border-color: #25d366; }
  .shareBtn.copy { background: var(--accent); color: #fff; border-color: var(--accent); }

  /* casino */
  .casinoBox { text-align: center; }
  .reels { display: flex; justify-content: center; gap: 12px; margin: 16px 0; }
  .reels span { width: 76px; height: 76px; display: flex; align-items: center; justify-content: center; font-size: 44px; background: linear-gradient(180deg, #fff, #fff3e6); border: 3px solid var(--gold); border-radius: 14px; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.06); }
  #casinoResult { font-size: 14px; font-weight: 700; min-height: 38px; display: flex; align-items: center; justify-content: center; color: var(--ink); }
  .betRow { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
  .betRow > span { font-size: 12px; font-weight: 800; color: var(--soft); }
  .betBtn { font-family: inherit; font-size: 13px; font-weight: 800; border: 2px solid rgba(91,75,67,0.15); background: #fff; color: var(--soft); padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: all 0.12s; }
  .betBtn:hover { border-color: var(--accent); }
  .betBtn.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }
  #betAmt { font-size: 13px; font-weight: 700; color: var(--accent2); margin-top: 8px; }
  .casinoStats { font-size: 11.5px; color: var(--soft); margin-top: 12px; }
  .payTable { font-size: 11px; color: var(--soft); margin-top: 8px; line-height: 1.5; }
  /* win celebration */
  .reels span.win { border-color: var(--good); animation: reelWin 0.5s ease-in-out infinite alternate; box-shadow: 0 0 18px 4px rgba(107,191,138,0.7); }
  @keyframes reelWin { from { transform: scale(1); } to { transform: scale(1.12); } }
  #casinoResult.win { color: var(--accent2); font-size: 17px; animation: winPop 0.45s cubic-bezier(.2,1.5,.4,1); }
  @keyframes winPop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.18); } 100% { transform: scale(1); opacity: 1; } }
  #namePop { z-index: 210; }
  #nameInput { width: 100%; border: 2px solid rgba(91,75,67,0.2); border-radius: 10px; padding: 12px; font-family: inherit; font-size: 16px; color: var(--ink); text-align: center; }
  #howtoBody { max-height: 56vh; overflow-y: auto; font-size: 13px; line-height: 1.55; color: var(--ink); }
  #howtoBody h3 { font-size: 14px; margin: 14px 0 4px; color: var(--accent2); }
  #howtoBody h3:first-child { margin-top: 0; }
  #howtoBody p { margin: 0 0 4px; }

  #verCorner { position: fixed; bottom: 6px; right: 10px; z-index: 90; font-size: 11px; color: var(--soft); background: rgba(255,250,243,0.8); padding: 3px 9px; border-radius: 10px; box-shadow: 0 1px 4px var(--shadow); }
  #verCorner a { color: var(--accent2); cursor: pointer; font-weight: 700; text-decoration: none; }
  #verCorner a:hover { text-decoration: underline; }

  #tooltip { position: fixed; z-index: 300; background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 600; padding: 6px 10px; border-radius: 8px; max-width: 220px; pointer-events: none; opacity: 0; transition: opacity 0.12s; transform: translateX(-50%); }
  #tooltip.show { opacity: 1; }
  body.tips-off #tooltip { display: none !important; }
  /* a deliberate "look here" reminder bubble that points at a button with a little caret */
  #tooltip.pointing { background: var(--accent); box-shadow: 0 8px 22px rgba(0,0,0,0.32); max-width: 240px; }
  #tooltip.pointing::after { content: ""; position: absolute; left: var(--caret-x, 50%); transform: translateX(-50%); width: 0; height: 0; border: 6px solid transparent; }
  #tooltip.pointing.below::after { bottom: 100%; border-bottom-color: var(--accent); }
  #tooltip.pointing.above::after { top: 100%; border-top-color: var(--accent); }
  body.tips-off #tooltip.pointing { display: block !important; }

  .modalBox { background: var(--panel); border-radius: 18px; padding: 22px; width: min(460px, 92vw); box-shadow: 0 18px 50px rgba(0,0,0,0.35); }
  .modalBox h2 { font-size: 18px; margin-bottom: 6px; }
  .modalBox p { font-size: 12.5px; color: var(--soft); margin-bottom: 12px; }
  #saveText { width: 100%; height: 130px; resize: none; border: 2px solid rgba(91,75,67,0.2); border-radius: 10px; padding: 10px; font-family: monospace; font-size: 11px; color: var(--ink); background: #fff; }
  .modalBtns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  .modalBtns button { flex: 1; min-width: 90px; font-family: inherit; font-size: 13px; font-weight: 700; border: none; padding: 10px; border-radius: 10px; cursor: pointer; transition: all 0.12s; background: #f0e6dc; color: var(--soft); }
  .modalBtns button.primary { background: var(--accent); color: #fff; }
  .modalBtns button:hover { filter: brightness(1.05); transform: translateY(-1px); }

  .setRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; border-bottom: 1px solid rgba(91,75,67,0.1); }
  .setRow:last-of-type { border-bottom: none; }
  .setRow .lab { font-size: 14px; font-weight: 700; }
  .setRow .sub { font-size: 11.5px; color: var(--soft); margin-top: 2px; }
  .setRow .ctrl { flex: none; display: flex; align-items: center; gap: 8px; min-width: 130px; justify-content: flex-end; }
  .toggle { width: 48px; height: 27px; border-radius: 20px; background: #d8ccc0; position: relative; cursor: pointer; transition: background 0.2s; flex: none; }
  .toggle.on { background: var(--good); }
  .toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
  .toggle.on::after { left: 24px; }
  .muted { color: #b7a99d; }

  #clBody { max-height: 52vh; overflow-y: auto; }
  .clEntry { margin-bottom: 14px; }
  .clVer { font-weight: 800; color: var(--accent2); font-size: 14px; margin-bottom: 4px; }
  .clEntry ul { margin: 0 0 0 18px; }
  .clEntry li { font-size: 12.5px; color: var(--ink); margin: 2px 0; }

  /* achievement popup */
  .achCard { background: var(--panel); border-radius: 20px; padding: 26px 24px; width: min(380px, 90vw); text-align: center; box-shadow: 0 18px 50px rgba(0,0,0,0.4); animation: bonusIn 0.35s cubic-bezier(.2,1.3,.4,1); }
  .achBurst { font-size: 64px; animation: pulseChip 1.1s ease-in-out infinite; }
  .achTitle { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--gold); margin-top: 6px; }
  .achName { font-size: 22px; font-weight: 800; color: var(--accent2); margin-top: 4px; }
  .achDesc { font-size: 13px; color: var(--soft); margin-top: 4px; }
  .achReward { font-size: 13.5px; font-weight: 700; margin: 14px 0 4px; }
  .achBtns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
  #achClaim { font-family: inherit; font-size: 15px; font-weight: 800; border: none; background: var(--accent); color: #fff; padding: 12px 26px; border-radius: 12px; cursor: pointer; transition: all 0.12s; }
  #achClaimAll { font-family: inherit; font-size: 13px; font-weight: 700; border: none; background: #f0e6dc; color: var(--soft); padding: 12px 18px; border-radius: 12px; cursor: pointer; transition: all 0.12s; }
  #achClaim:hover, #achClaimAll:hover { filter: brightness(1.05); transform: translateY(-1px); }
  #achQueueNote { font-size: 11px; color: var(--soft); margin-top: 8px; height: 14px; }

  @media (max-width: 860px) {
    #game { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    #left { display: none; }
    #side { max-height: 48vh; }
    #miniStat { display: block; }
  }