  :root{
    --bg-deep: #0c1712;
    --bg-mid: #14251c;
    --panel: #182a20;
    --panel-edge: #2a4234;
    --ink: #e9f2ea;
    --ink-dim: #9db3a5;
    --gold: #d9c27a;

    --c-green: #4fbf6c;
    --c-green-dim: #1f3b28;
    --c-red: #e05a4e;
    --c-red-dim: #3b201f;
    --c-blue: #4f9ee0;
    --c-blue-dim: #1f2f3b;
    --c-violet: #a86fe0;
    --c-violet-dim: #2c1f3b;

    --wood-light: #8a6339;
    --wood-mid: #5c3d24;
    --wood-dark: #38230f;
    --wood-edge: #23150a;

    --c-viridian: #3fae82;
    --c-viridian-dim: #1c3b30;
  }

  *{ box-sizing: border-box; }

  #game-screen{
    width:100%;
    margin:0;
    min-height:100vh;
    display:flex;
    flex-direction:column;
    align-items:center;
    background:
      radial-gradient(ellipse at 50% -10%, var(--bg-mid), var(--bg-deep) 60%);
    font-family: 'Georgia', 'Iowan Old Style', serif;
    color: var(--ink);
    padding: 32px 16px 60px;
    overflow-x:hidden;
  }

  .game-title-logo{
    margin: 0 0 10px;
    width: 100%;
    max-width: 880px;
    display: flex;
    justify-content: center;
  }

  .game-title-logo img{
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5));
  }

  .vault{
    position:relative;
    margin: 18px 0 48px;
    padding: 24px 28px 18px;
    border-radius: 16px;
    background:
      repeating-linear-gradient(95deg, rgba(255,255,255,0.045) 0px, rgba(255,255,255,0.045) 2px, transparent 2px, transparent 7px),
      linear-gradient(160deg, var(--wood-light), var(--wood-mid) 55%, var(--wood-dark));
    border: 4px solid var(--wood-edge);
    box-shadow:
      0 14px 32px rgba(0,0,0,0.45),
      inset 0 0 0 2px rgba(255,255,255,0.07),
      inset 0 2px 8px rgba(0,0,0,0.4);
  }

  .vault-title{
    position:absolute;
    top: -15px;
    left:50%;
    transform: translateX(-50%);
    background: var(--wood-edge);
    color: var(--gold);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    font-weight:bold;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 7px 20px;
    border-radius: 999px;
    border: 2px solid rgba(0,0,0,0.35);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    white-space:nowrap;
  }

  .vault-body{
    display:flex;
    align-items:stretch;
    justify-content:center;
    flex-wrap:wrap;
    gap: 18px;
  }

  .vault-group{
    display:flex;
    align-items:center;
    gap: 10px;
    flex-wrap:wrap;
    justify-content:center;
  }

  .vault-divider{
    width:2px;
    align-self:stretch;
    background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,0.3), rgba(255,255,255,0));
  }

  .vault-item{
    display:flex;
    align-items:center;
    gap: 8px;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(0,0,0,0.35);
    border-radius: 999px;
    padding: 4px 14px 4px 4px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  }

  .vault-item--info{
    position:relative;
    cursor:help;
  }

  .vault-icon{
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius:50%;
    background: rgba(255,255,255,0.08);
    padding: 3px;
    flex-shrink:0;
  }

  .vault-count{
    font-variant-numeric: tabular-nums;
    font-weight: bold;
    min-width: 3ch;
    text-align:right;
    font-family: 'Trebuchet MS', sans-serif;
  }

  .vault-rate{
    font-size: 0.65rem;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
  }

  .section-label{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin: 40px 0 18px;
  }

  .tool-shop{
    max-width: 460px;
  }

  /* Deep black + gold metallic treatment for the main currency vault —
     visually distinct from the wood-styled Tool Shop, ~20% larger throughout. */
  .main-vault{
    padding: 29px 34px 22px;
    border-width: 5px;
    border-color: #3a3320;
    background:
      repeating-linear-gradient(95deg, rgba(217,194,122,0.035) 0px, rgba(217,194,122,0.035) 2px, transparent 2px, transparent 7px),
      radial-gradient(ellipse at 30% -20%, rgba(217,194,122,0.09), transparent 55%),
      linear-gradient(160deg, #1c1c1e, #101011 55%, #030303);
    box-shadow:
      0 18px 42px rgba(0,0,0,0.65),
      0 0 0 1px rgba(217,194,122,0.32),
      inset 0 0 0 2px rgba(217,194,122,0.14),
      inset 0 2px 12px rgba(0,0,0,0.65);
  }

  .main-vault .vault-title{
    background: linear-gradient(160deg, #2b2717, #050504);
    border-color: rgba(217,194,122,0.55);
    font-size: 0.86rem;
    padding: 8px 24px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.6), 0 0 14px rgba(217,194,122,0.28);
  }

  .main-vault .vault-body{ gap: 22px; }

  .main-vault .vault-item{
    padding: 5px 17px 5px 5px;
    border-color: rgba(217,194,122,0.3);
    background: rgba(217,194,122,0.06);
  }

  .main-vault .vault-icon{
    width: 36px;
    height: 36px;
    background: rgba(217,194,122,0.14);
  }

  .main-vault .vault-count{
    font-size: 1.15rem;
  }

  .main-vault .vault-rate{
    font-size: 0.78rem;
  }

  .main-vault .vault-divider{
    background: linear-gradient(rgba(217,194,122,0), rgba(217,194,122,0.45), rgba(217,194,122,0));
  }

  .tool-shop-items{
    display:flex;
    gap: 16px;
    justify-content:center;
    flex-wrap:wrap;
  }

  .tool-shop-item{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 6px;
    width: 110px;
    background: rgba(0,0,0,0.22);
    border: 1px solid rgba(0,0,0,0.35);
    border-radius: 12px;
    padding: 12px 10px;
    cursor: pointer;
    color: var(--ink);
    font-family: 'Trebuchet MS', sans-serif;
    transition: border-color 0.12s ease, opacity 0.12s ease, transform 0.08s ease;
  }

  .tool-shop-item:hover:not(:disabled){ border-color: var(--gold); }
  .tool-shop-item:active:not(:disabled){ transform: scale(0.96); }
  .tool-shop-item:disabled{ opacity: 0.4; cursor: not-allowed; }

  .tool-shop-item img{
    width: 48px;
    height: 48px;
    object-fit: contain;
  }

  .tool-shop-item-name{
    font-size: 0.74rem;
    font-weight: bold;
    text-align:center;
  }

  .tool-shop-item-cost{
    display:flex;
    align-items:center;
    gap: 5px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
  }

  .tool-shop-item-cost img{
    width: 16px;
    height: 16px;
  }

  .grove{
    display:grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 24px 48px;
    max-width: 1200px;
    width:100%;
  }

  .shop{
    display:grid;
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    gap: 14px;
    max-width: 1000px;
    width:100%;
  }

  @media (max-width: 980px){
    .shop{ grid-template-columns: repeat(2, 1fr); }
  }

  @media (max-width: 640px){
    .grove{ grid-template-columns: repeat(2, 1fr); }
  }

  .tree-card{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 12px;
  }

  .tree-shop-box{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 12px;
    padding: 12px 10px 14px;
    min-width: 0;
  }

  .tree-shop-title{
    text-align:center;
    font-weight:bold;
    font-size: 0.7rem;
    color: var(--ink-dim);
  }

  .tier-grid{
    display:flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content:center;
  }

  .tree-btn{
    position:relative;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    border: 2px solid var(--edge);
    background:
      radial-gradient(circle at 35% 30%, var(--glow) 0%, transparent 60%),
      var(--dim);
    cursor: pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    transition: transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 6px 18px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.03);
    -webkit-tap-highlight-color: transparent;
    padding: 0;
  }

  .tree-btn img{
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    pointer-events:none;
    user-select:none;
  }

  .tree-btn:hover{
    box-shadow: 0 8px 26px rgba(0,0,0,0.5), 0 0 0 4px var(--ring);
    border-color: var(--main);
  }

  .tree-btn:active{
    transform: scale(0.92);
  }

  .tree-card.locked .tree-btn{
    filter: grayscale(0.6);
    opacity: 0.6;
    pointer-events:none;
    cursor: not-allowed;
  }

  .tree-card.locked .tree-btn:active{
    transform: none;
  }

  .tree-card.locked .tree-total{
    opacity: 0.5;
  }

  .tree-orbit-wrap{
    position:relative;
    width: 240px;
    height: 240px;
    display:flex;
    align-items:center;
    justify-content:center;
  }

  .tree-orbit-wrap .tree-btn{
    position:relative;
    z-index:2;
  }

  .orbit-slot{
    position:absolute;
    top:50%;
    left:50%;
    width:0;
    height:0;
    animation: orbit-spin 60s linear infinite;
    pointer-events:none;
  }

  @keyframes orbit-spin{
    from{ transform: rotate(0deg); }
    to{ transform: rotate(360deg); }
  }

  .orbit-icon{
    position:absolute;
    top:-13px;
    left: 82px;
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
    animation: orbit-counter-spin 60s linear infinite;
  }

  @keyframes orbit-counter-spin{
    from{ transform: rotate(0deg); }
    to{ transform: rotate(-360deg); }
  }

  .tree-name{
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--ink);
    text-align:center;
    line-height:1.25;
  }

  .tree-essence{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--ink-dim);
    text-align:center;
  }

  .tree-total{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.8rem;
    color: var(--main);
    font-variant-numeric: tabular-nums;
  }

  .t-green{ --main: var(--c-green); --dim: var(--c-green-dim); --edge:#2f5a3c; --glow: rgba(79,191,108,0.35); --ring: rgba(79,191,108,0.25); }
  .t-red{ --main: var(--c-red); --dim: var(--c-red-dim); --edge:#5c352f; --glow: rgba(224,90,78,0.35); --ring: rgba(224,90,78,0.25); }
  .t-blue{ --main: var(--c-blue); --dim: var(--c-blue-dim); --edge:#2f4a5c; --glow: rgba(79,158,224,0.35); --ring: rgba(79,158,224,0.25); }
  .t-violet{ --main: var(--c-violet); --dim: var(--c-violet-dim); --edge:#4a2f5c; --glow: rgba(168,111,224,0.35); --ring: rgba(168,111,224,0.25); }
  .t-viridian{ --main: var(--c-viridian); --dim: var(--c-viridian-dim); --edge:#1f4a3a; --glow: rgba(63,180,130,0.35); --ring: rgba(63,180,130,0.25); }

  .float-pop{
    position:absolute;
    left:50%;
    top: 8px;
    transform: translateX(-50%);
    font-family: 'Trebuchet MS', sans-serif;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--main);
    text-shadow: 0 0 12px var(--glow);
    pointer-events:none;
    animation: floatUp 0.9s ease-out forwards;
  }

  @keyframes floatUp{
    0%   { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
    15%  { opacity: 1; transform: translate(-50%, -10px) scale(1.05); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
  }

  .float-pop.currency-gold{ color: var(--gold); text-shadow: 0 0 12px rgba(217,194,122,0.55); }
  .float-pop.currency-viridianCoin{ color: var(--c-viridian); text-shadow: 0 0 12px rgba(63,174,130,0.55); }

  .coin-burst{
    position:absolute;
    width: 22px;
    height: 22px;
    pointer-events:none;
    animation: coinBurst 0.9s ease-out forwards;
  }

  @keyframes coinBurst{
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9) translateY(-48px); }
  }

  .tier-tile-wrap{
    position:relative;
  }

  .tier-tile{
    position:relative;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 2px solid var(--edge);
    background: radial-gradient(circle at 35% 30%, var(--glow) 0%, transparent 60%), var(--dim);
    cursor: pointer;
    padding: 0;
    display:flex;
    align-items:center;
    justify-content:center;
    transition: border-color 0.12s ease, opacity 0.12s ease, transform 0.08s ease;
  }

  .tier-tile img{
    width: 76%;
    height: 76%;
    object-fit: contain;
    pointer-events:none;
  }

  .tier-tile:hover:not(:disabled){ border-color: var(--gold); }
  .tier-tile:active:not(:disabled){ transform: scale(0.93); }

  .tier-tile.locked{
    filter: grayscale(0.75);
    opacity: 0.6;
  }

  .tier-tile:disabled{
    cursor: not-allowed;
    opacity: 0.35;
  }

  .tier-lvl-badge{
    position:absolute;
    bottom: -7px;
    left:50%;
    transform: translateX(-50%);
    background: var(--panel-edge);
    color: var(--ink);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.56rem;
    font-weight:bold;
    padding: 1px 6px;
    border-radius: 999px;
    white-space:nowrap;
    pointer-events:none;
  }

  .tier-owned-badge{
    position:absolute;
    top: -7px;
    right: -7px;
    background: rgba(0,0,0,0.7);
    color: var(--ink);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.58rem;
    font-weight:bold;
    padding: 1px 6px;
    border-radius: 999px;
    pointer-events:none;
  }

  .tier-popover{
    position:absolute;
    bottom: calc(100% + 12px);
    left:50%;
    transform: translateX(-50%) translateY(4px);
    background: #0e1c14;
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.68rem;
    white-space:nowrap;
    opacity: 0;
    pointer-events:none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    box-shadow: 0 8px 18px rgba(0,0,0,0.5);
    z-index: 3;
  }

  .tier-popover::after{
    content:'';
    position:absolute;
    top:100%;
    left:50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--gold);
  }

  .tier-tile-wrap:hover .tier-popover,
  .tier-tile-wrap:focus-within .tier-popover,
  .craft-icon-frame-wrap:hover .tier-popover,
  .craft-icon-frame-wrap:focus-within .tier-popover,
  .module-equip-slot-wrap:hover .tier-popover,
  .module-equip-slot-wrap:focus-within .tier-popover,
  .vault-item--info:hover .tier-popover,
  .vault-item--info:focus .tier-popover,
  .vault-item--info:focus-within .tier-popover{
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .tier-popover--below{
    top: calc(100% + 12px);
    bottom:auto;
  }

  .tier-popover--below::after{
    top:auto;
    bottom:100%;
    border-top-color:transparent;
    border-bottom-color:var(--gold);
  }

  .tier-popover-name{ font-weight:bold; color: var(--ink); margin-bottom: 3px; }
  .tier-popover-mult{ color: var(--main); margin-bottom: 2px; }
  .tier-popover-cost{ display:flex; align-items:center; gap: 5px; color: var(--gold); }
  .tier-popover-cost img{ width: 13px; height: 13px; object-fit: contain; }

  .craft-grid{
    display:grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 22px;
    max-width: 1160px;
    width:100%;
  }

  @media (max-width: 900px){
    .craft-grid{ grid-template-columns: repeat(2, 1fr); }
  }

  .craft-card{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 10px;
    background: var(--panel);
    border: 2px solid var(--panel-edge);
    border-radius: 16px;
    padding: 18px 12px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.03);
    transition: opacity 0.15s ease;
  }

  .craft-icon-frame{
    width: 96px;
    height: 130px;
    border-radius: 12px;
    border: 2px solid var(--edge, var(--panel-edge));
    background:
      radial-gradient(circle at 35% 25%, var(--glow, rgba(255,255,255,0.06)) 0%, transparent 65%),
      var(--dim, var(--bg-deep));
    display:flex;
    align-items:center;
    justify-content:center;
  }

  .craft-icon-frame img{
    width: 76%;
    height: 86%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  }

  .craft-card.unavailable .craft-icon-frame{
    filter: grayscale(1);
    opacity: 0.7;
  }

  .craft-card.locked .craft-icon-frame{
    filter: grayscale(0.6);
    opacity: 0.65;
  }

  .craft-normal{
    text-align:center;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 8px;
  }

  .craft-normal[hidden]{
    display:none;
  }

  .craft-cost-graphic{
    display:flex;
    align-items:center;
    justify-content:center;
    gap: 6px;
    transition: opacity 0.15s ease;
  }

  .craft-cost-graphic .craft-cost-amount{
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }

  .craft-cost-graphic .craft-cost-x{
    font-size: 0.9rem;
    color: var(--ink-dim);
  }

  .craft-cost-icon{
    width: 30px;
    height: 30px;
    object-fit: contain;
  }

  .craft-cost-graphic.insufficient{
    opacity: 0.45;
  }

  .craft-unlock{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 8px;
    margin-top: 2px;
  }

  .craft-unlock[hidden]{
    display:none;
  }

  .unlock-btn{
    padding: 8px 22px;
    border-radius: 999px;
    border: 2px solid var(--gold);
    background: rgba(217,194,122,0.12);
    color: var(--gold);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.74rem;
    font-weight: bold;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease, opacity 0.15s ease;
  }

  .unlock-btn:hover:not(:disabled){ background: rgba(217,194,122,0.24); }
  .unlock-btn:active:not(:disabled){ transform: scale(0.95); }
  .unlock-btn:disabled{ opacity: 0.4; cursor: not-allowed; }

  .unlock-cost{
    display:flex;
    align-items:center;
    justify-content:center;
    gap: 6px;
    font-family: 'Trebuchet MS', sans-serif;
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--ink-dim);
  }

  .unlock-cost-icon{
    width: 22px;
    height: 22px;
    object-fit: contain;
  }

  .tree-unlock{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 8px;
    margin-top: 2px;
  }

  .tree-unlock[hidden]{
    display:none;
  }

  .craft-name{
    font-weight: bold;
    font-size: 0.92rem;
    text-align:center;
  }

  .craft-cost{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.74rem;
    color: var(--ink-dim);
    text-align:center;
  }

  .craft-btn{
    margin-top: 2px;
    padding: 8px 20px;
    border-radius: 999px;
    border: 2px solid var(--panel-edge);
    background: var(--bg-mid);
    color: var(--ink);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
  }

  .craft-btn:hover:not(:disabled){ border-color: var(--gold); }
  .craft-btn:active:not(:disabled){ transform: scale(0.95); }
  .craft-btn:disabled{ opacity: 0.35; cursor: not-allowed; }

  .craft-unavailable-label{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-dim);
    border: 1px dashed var(--panel-edge);
    padding: 6px 16px;
    border-radius: 999px;
    margin-top: 2px;
  }

  .craft-brewing{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 6px;
    margin-top: 2px;
  }

  .craft-brewing[hidden]{
    display:none;
  }

  .craft-brewing-label{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
  }

  .craft-ring{
    position:relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(var(--gold) calc(var(--p, 0) * 1%), rgba(255,255,255,0.08) 0);
  }

  .craft-ring::before{
    content:'';
    position:absolute;
    inset: 7px;
    border-radius: 50%;
    background: var(--panel);
  }

  .craft-pct{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink-dim);
  }

  .craft-ghost-slots{
    display:flex;
    gap: 6px;
    flex-wrap:wrap;
    justify-content:center;
    margin-top: 2px;
  }

  .ghost-slot{
    position:relative;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 2px dashed rgba(233,242,234,0.28);
    background: rgba(0,0,0,0.22);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor: default;
    transition: border-color 0.12s ease, background 0.12s ease;
  }

  .ghost-slot img{
    width: 74%;
    height: 74%;
    object-fit: contain;
    pointer-events:none;
  }

  .ghost-slot.empty img{
    opacity: 0.32;
    filter: grayscale(1);
  }

  .ghost-slot.filled{
    border-style: solid;
    border-color: var(--gold);
    background: rgba(217,194,122,0.14);
    cursor: pointer;
  }

  .ghost-slot.drag-over{
    border-color: var(--gold);
    background: rgba(217,194,122,0.28);
  }

  .ghost-slot.reject{
    border-color: var(--c-red);
    background: rgba(224,90,78,0.22);
  }

  .recipe-craft-btn{
    margin-top: 4px;
    padding: 8px 20px;
    border-radius: 999px;
    border: 2px solid var(--panel-edge);
    background: var(--bg-mid);
    color: var(--ink);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.08s ease, opacity 0.15s ease;
  }

  .recipe-craft-btn:hover:not(:disabled){ border-color: var(--gold); }
  .recipe-craft-btn:active:not(:disabled){ transform: scale(0.95); }
  .recipe-craft-btn:disabled{ opacity: 0.35; cursor: not-allowed; }

  .viridian-unlock{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 6px;
    margin-top: 2px;
  }

  .viridian-unlock[hidden]{ display:none; }

  .viridian-progress{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.64rem;
    color: var(--ink-dim);
    text-align:center;
    line-height:1.5;
  }

  .viridian-progress-line.met{ color: var(--c-viridian); }

  .craft-grid-divider{
    display:flex;
    align-items:center;
    gap: 14px;
    max-width: 1160px;
    width:100%;
    margin: 4px 0;
  }

  .craft-grid-divider::before,
  .craft-grid-divider::after{
    content:'';
    flex:1;
    height:1px;
    background: linear-gradient(90deg, transparent, rgba(217,194,122,0.4), transparent);
  }

  .craft-grid-divider span{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold);
    white-space:nowrap;
  }

  .craft-icon-frame-wrap{
    position:relative;
  }

  .module-slots{
    display:flex;
    gap: 6px;
    justify-content:center;
    margin-top: 2px;
  }

  .module-equip-slot-wrap{
    position:relative;
  }

  .module-equip-slot{
    position:relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px dashed rgba(217,194,122,0.3);
    background: rgba(0,0,0,0.22);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor: default;
    transition: border-color 0.12s ease, background 0.12s ease;
  }

  .module-equip-slot img{
    width: 74%;
    height: 74%;
    object-fit: contain;
    pointer-events:none;
  }

  .module-equip-slot.empty img{
    opacity: 0.25;
    filter: grayscale(1);
  }

  .module-equip-slot.filled{
    border-style: solid;
    border-color: var(--gold);
    background: rgba(217,194,122,0.14);
    cursor: pointer;
  }

  .module-equip-slot.filled.disabled-module{
    border-color: var(--ink-dim);
    opacity: 0.55;
  }

  .module-equip-slot.drag-over{
    border-color: var(--gold);
    background: rgba(217,194,122,0.3);
  }

  .module-equip-uses{
    position:absolute;
    bottom: -6px;
    right: -6px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.56rem;
    font-weight:bold;
    color: var(--ink);
    background: rgba(0,0,0,0.65);
    padding: 0 4px;
    border-radius: 7px;
    pointer-events:none;
  }

  .autocraft-mini{
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display:flex;
    flex-direction:column;
    gap: 6px;
    width:100%;
  }

  .autocraft-mini[hidden]{ display:none; }

  .autocraft-row{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    gap: 3px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.66rem;
    width:100%;
  }

  .autocraft-row label{ color: var(--ink-dim); }

  .autocraft-row input,
  .autocraft-row select{
    background: var(--bg-deep);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 4px 6px;
    font-family: inherit;
    font-size: 0.72rem;
    width: 100%;
    box-sizing: border-box;
  }

  .autocraft-hint{ font-size: 0.58rem; color: var(--ink-dim); opacity: 0.7; }

  .autocraft-cycles-done{ color: var(--ink-dim); font-size: 0.66rem; }
  .autocraft-reserved-label{ color: var(--ink-dim); font-size: 0.64rem; }

  .autocraft-reserved-grid{
    display:flex;
    flex-wrap:wrap;
    gap: 4px 8px;
  }

  .autocraft-reserved-grid .debug-field input{ width: 40px; }

  .pending-rewards{
    margin: 4px 0 20px;
    padding: 12px 18px;
    max-width: 1080px;
    width:100%;
    border-radius: 12px;
    border: 2px dashed var(--gold);
    background: rgba(217,194,122,0.08);
    display:flex;
    align-items:center;
    gap: 14px;
    flex-wrap:wrap;
    justify-content:center;
  }

  .pending-rewards[hidden]{ display:none; }

  .pending-rewards-label{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    color: var(--gold);
  }

  .pending-rewards-items{
    display:flex;
    gap: 8px;
    flex-wrap:wrap;
  }

  .milestone-toast{
    position:fixed;
    top: 18px;
    left:50%;
    transform: translateX(-50%) translateY(-20px);
    background: #0e1c14;
    border: 2px solid var(--gold);
    color: var(--gold);
    font-family: 'Trebuchet MS', sans-serif;
    font-weight:bold;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    padding: 12px 26px;
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    opacity: 0;
    z-index: 50;
    transition: opacity 0.35s ease, transform 0.35s ease;
  }

  .milestone-toast.show{
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  .inventory-frame{
    margin: 6px 0 24px;
    padding: 24px;
    max-width: 1080px;
    width:100%;
    border-radius: 18px;
    border: 3px solid var(--gold);
    background:
      repeating-linear-gradient(115deg, rgba(255,255,255,0.025) 0px, rgba(255,255,255,0.025) 2px, transparent 2px, transparent 6px),
      linear-gradient(160deg, #3c3c40, #232326 55%, #131315);
    box-shadow:
      0 0 0 1px rgba(217,194,122,0.28),
      0 16px 34px rgba(0,0,0,0.5),
      inset 0 0 26px rgba(0,0,0,0.55);
  }

  .inventory-grid{
    display:grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 14px;
  }

  @media (max-width: 720px){
    .inventory-grid{ grid-template-columns: repeat(4, 1fr); }
  }

  .inventory-slot{
    position:relative;
    aspect-ratio: 1;
    border-radius: 12px;
    border: 2px solid rgba(217,194,122,0.3);
    background: rgba(0,0,0,0.35);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
    display:flex;
    align-items:center;
    justify-content:center;
    transition: border-color 0.12s ease, background 0.12s ease;
  }

  .inventory-slot[draggable="true"]{
    cursor: grab;
  }

  .inventory-slot.dragging{
    opacity: 0.4;
  }

  .inventory-slot.drag-over{
    border-color: var(--gold);
    background: rgba(217,194,122,0.14);
  }

  .inventory-slot img{
    width: 72%;
    height: 72%;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
    pointer-events:none;
  }

  .slot-count{
    position:absolute;
    bottom: 5px;
    right: 7px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--ink);
    background: rgba(0,0,0,0.55);
    padding: 1px 6px;
    border-radius: 8px;
  }

  .inventory-caption{
    margin-top: 14px;
    text-align:center;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    color: var(--ink-dim);
    opacity: 0.8;
  }

  .market-row{
    display:flex;
    flex-wrap: wrap;
    justify-content:center;
    align-items:flex-start;
    gap: 36px;
    width:100%;
    max-width: 1080px;
    margin-bottom: 24px;
  }

  .sell-panel{
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap: 10px;
  }

  .sell-dropzone{
    position:relative;
    width: 220px;
    aspect-ratio: 774 / 822;
    background-image: url('../assets/SHOP_PLACE.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }

  .sell-dropzone.drag-over{
    filter: drop-shadow(0 0 14px rgba(217,194,122,0.65));
  }

  .sell-hint{
    position:absolute;
    inset: 12% 14%;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.7rem;
    color: rgba(233,242,234,0.4);
    letter-spacing: 0.04em;
    padding: 8px;
    pointer-events:none;
  }

  .sell-hint[hidden]{ display:none; }

  .sell-items{
    position:absolute;
    inset: 12% 14%;
    display:flex;
    flex-wrap:wrap;
    align-content:center;
    justify-content:center;
    gap: 8px;
    padding: 6px;
  }

  .sell-chip{
    position:relative;
    width: 42px;
    height: 42px;
  }

  .sell-chip img{
    width:100%;
    height:100%;
    object-fit:contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  }

  .sell-chip .slot-count{
    font-size: 0.62rem;
    padding: 0 4px;
    bottom: -2px;
    right: -4px;
  }

  .sell-label{
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.2em;
    color: var(--gold);
    text-transform: uppercase;
  }

  .sell-total{
    display:flex;
    align-items:center;
    gap: 8px;
    font-family: 'Trebuchet MS', sans-serif;
    font-weight: bold;
    font-size: 1rem;
    color: var(--ink);
    min-height: 26px;
  }

  .sell-total-line{
    display:flex;
    align-items:center;
    gap: 5px;
  }

  .sell-total-icon{
    width: 22px;
    height: 22px;
    object-fit: contain;
  }

  .sell-total-empty{
    color: var(--ink-dim);
    font-weight: normal;
    font-size: 0.8rem;
  }

  .sell-btn{
    padding: 9px 28px;
    border-radius: 999px;
    border: 2px solid var(--gold);
    background: rgba(217,194,122,0.14);
    color: var(--gold);
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease, opacity 0.15s ease;
  }

  .sell-btn:hover:not(:disabled){ background: rgba(217,194,122,0.26); }
  .sell-btn:active:not(:disabled){ transform: scale(0.96); }
  .sell-btn:disabled{ opacity: 0.35; cursor: not-allowed; }

  .board-panel{
    position:relative;
    width: 520px;
    max-width: 100%;
    aspect-ratio: 3 / 2;
    background-image: url('../assets/SHOP_BOARD.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
  }

  .board-price{
    position:absolute;
    left: 58.4635%;
    width: 16.4063%;
    height: 7.8125%;
    display:flex;
    align-items:center;
    justify-content:center;
    gap: 5px;
    font-family: 'Trebuchet MS', sans-serif;
    font-weight:bold;
    font-size: 0.82rem;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
  }

  .board-price:nth-child(1){ top: 21.7773%; }
  .board-price:nth-child(2){ top: 34.2773%; }
  .board-price:nth-child(3){ top: 46.7773%; }
  .board-price:nth-child(4){ top: 59.2773%; }
  .board-price:nth-child(5){ top: 71.7773%; }

  .board-price img{
    width: 18px;
    height: 18px;
    object-fit: contain;
  }

  .board-price-unavailable{
    color: rgba(233,242,234,0.35);
    font-size: 0.7rem;
    font-weight:normal;
    text-transform:uppercase;
    letter-spacing:0.05em;
  }

  @media (max-width: 640px){
    .board-panel{ width: 100%; }
    .board-price{ font-size: 0.68rem; }
  }

  footer{
    margin-top: 48px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.72rem;
    color: var(--ink-dim);
    opacity: 0.6;
    letter-spacing: 0.05em;
  }

  .debug-panel{
    margin-top: 28px;
    width: 100%;
    max-width: 560px;
    border: 1px dashed var(--panel-edge);
    border-radius: 12px;
    padding: 14px 18px 18px;
    font-family: 'Trebuchet MS', sans-serif;
  }

  .debug-title{
    font-size: 0.68rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin-bottom: 10px;
  }

  .debug-row{
    display:flex;
    align-items:center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .debug-row label{
    width: 52px;
    font-size: 0.78rem;
    color: var(--ink-dim);
  }

  .debug-field-label{
    width: 40px;
    font-size: 0.72rem;
    color: var(--ink-dim);
  }

  .debug-row input{
    flex: 1;
    min-width: 0;
    background: var(--bg-deep);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 6px 8px;
    font-family: inherit;
    font-size: 0.82rem;
  }

  .debug-row button{
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 6px 12px;
    font-size: 0.72rem;
    cursor: pointer;
  }

  .debug-row button:hover{
    border-color: var(--ink-dim);
  }

  .debug-row-compact{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap: 5px 14px;
    margin-bottom: 8px;
  }

  .debug-field{
    display:flex;
    align-items:center;
    gap: 4px;
  }

  .debug-field label{
    font-size: 0.7rem;
    font-weight:bold;
    color: var(--ink-dim);
  }

  .debug-field input{
    width: 54px;
    min-width: 0;
    background: var(--bg-deep);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 5px 6px;
    font-family: inherit;
    font-size: 0.76rem;
  }

  .debug-field button{
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 5px 8px;
    font-size: 0.66rem;
    cursor: pointer;
  }

  .debug-field button:hover{
    border-color: var(--ink-dim);
  }

  .debug-subhead{
    font-size: 0.68rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin: 16px 0 10px;
    opacity: 0.7;
  }

  .top-controls{
    display:flex;
    justify-content:center;
    gap: 10px;
    margin-bottom: 18px;
  }

  .top-controls button{
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 999px;
    color: var(--ink-dim);
    padding: 6px 16px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .top-controls button:hover{
    color: var(--ink);
    border-color: var(--ink-dim);
  }

  /* --- compact persistent play HUD ------------------------------------- */
  #game-screen{
    /* The HUD is fixed; leave only a small breathing space before the grove. */
    padding-top: 112px;
    padding-bottom: 210px;
  }

  .game-hud{
    position:fixed;
    top:max(8px, env(safe-area-inset-top));
    left:50%;
    transform:translateX(-50%);
    z-index:40;
    display:grid;
    grid-template-columns:200px minmax(0, 1fr) auto;
    grid-template-rows:auto;
    align-items:center;
    gap:12px;
    width:min(1280px, 100%);
    min-height:82px;
    padding:7px 12px;
    margin-bottom:16px;
    border:1px solid rgba(217,194,122,0.24);
    border-radius:14px;
    background:linear-gradient(160deg, rgba(20,37,28,0.96), rgba(8,15,11,0.96));
    backdrop-filter:blur(10px);
    box-shadow:0 8px 24px rgba(0,0,0,0.42);
  }

  .game-hud .game-title-logo{
    width:100%;
    max-width:200px;
    margin:0;
    grid-column:1;
    grid-row:1;
  }

  .game-hud .top-controls{
    display:flex;
    flex-wrap:nowrap;
    justify-content:center;
    gap:5px;
    margin:0;
    grid-column:3;
    grid-row:1;
  }

  .game-hud .top-controls button{
    min-width:34px;
    padding:7px 9px;
    font-size:0.62rem;
  }

  .game-hud .main-vault{
    width:100%;
    margin:0;
    min-height:48px;
    padding:8px 6px 5px;
    border:0;
    border-radius:0;
    background:transparent;
    box-shadow:none;
    grid-column:2;
    grid-row:1;
  }

  .game-hud .main-vault .vault-title{
    top:-8px;
    left:8px;
    transform:none;
    font-size:0.46rem;
    padding:2px 7px;
    border-width:1px;
  }

  .game-hud .main-vault .vault-body,
  .game-hud .main-vault .vault-group{
    flex-wrap:nowrap;
    gap:6px;
  }

  .game-hud .main-vault .vault-divider{ width:1px; margin:0 3px; }
  .game-hud .main-vault .vault-item{
    min-width:104px;
    padding:4px 7px 4px 3px;
    gap:5px;
    border-color:rgba(217,194,122,0.16);
    background:rgba(0,0,0,0.18);
  }
  .game-hud .main-vault .vault-icon{ width:27px; height:27px; padding:1px; background:transparent; }
  .game-hud .main-vault .vault-count{ font-size:0.86rem; min-width:3ch; }
  .game-hud .main-vault .vault-rate{ font-size:0.54rem; color:var(--ink-dim); }

  .hud-icon-btn{ font-size:1.02rem !important; line-height:1; }

  .floating-inventory{
    position:fixed;
    z-index:45;
    left:50%;
    bottom:max(10px, env(safe-area-inset-bottom));
    transform:translateX(-50%);
    width:min(920px, calc(100% - 24px));
  }

  .floating-inventory .inventory-frame{
    margin:0;
    padding:10px 14px 7px;
    border-width:2px;
    border-radius:12px;
    box-shadow:0 10px 28px rgba(0,0,0,0.65), inset 0 0 18px rgba(0,0,0,0.6);
  }

  .floating-inventory .inventory-grid{ gap:8px; }
  .floating-inventory .inventory-slot{
    width:100%;
    min-width:64px;
    max-width:76px;
    min-height:64px;
    justify-self:center;
    border-radius:9px;
  }
  .floating-inventory .inventory-caption{ margin-top:5px; font-size:0.54rem; }

  .tool-shop{ max-width:540px; }
  .tool-shop-items{ display:grid; grid-template-columns:repeat(4, 110px); }
  .tool-shop-placeholder{
    width:110px;
    aspect-ratio:1;
    border:1px dashed rgba(217,194,122,0.2);
    border-radius:12px;
    background:rgba(0,0,0,0.14);
  }

  /* Unlock requirements are available on hover, without widening the cards. */
  .tree-unlock .unlock-cost,
  .craft-unlock .unlock-cost,
  .viridian-unlock .unlock-cost,
  .viridian-unlock .viridian-progress{ display:none; }

  .tree-unlock:hover .tier-popover,
  .tree-unlock:focus-within .tier-popover,
  .craft-unlock:hover .tier-popover,
  .craft-unlock:focus-within .tier-popover,
  .viridian-unlock:hover .tier-popover,
  .viridian-unlock:focus-within .tier-popover{
    opacity:1;
    transform:translateX(-50%) translateY(0);
  }

  #unlock-popover-viridian{
    width:260px;
    white-space:normal;
  }

  .module-slots{ gap:4px; }
  .module-equip-slot{ width:28px; height:28px; border-radius:7px; }
  .module-equip-uses{ bottom:-5px; right:-5px; font-size:0.5rem; }
  #craft-grid-modules .craft-icon-frame{ width:88px; height:88px; }
  #craft-grid-modules .craft-icon-frame img{ width:74%; height:74%; }

  /* Craft progress lives on the item itself: the illuminated slice expands as
     the remaining-time label counts down, instead of adding a separate ring. */
  .craft-icon-frame{ position:relative; overflow:hidden; }
  .craft-icon-frame.is-crafting::after{
    content:'';
    position:absolute;
    inset:0;
    background:conic-gradient(from -90deg, transparent calc(var(--p, 0) * 1%), rgba(8,14,10,0.68) 0);
    pointer-events:none;
  }
  .craft-brewing{ margin-top:-4px; }
  .craft-brewing-label,
  .craft-ring{ display:none; }
  .craft-pct{
    color:var(--gold);
    font-size:0.78rem;
    font-weight:bold;
  }

  @media (max-width: 900px){
    #game-screen{ padding-top:268px; }
    .game-hud{ grid-template-columns:1fr; grid-template-rows:auto; gap:8px; }
    .game-hud .game-title-logo{ max-width:180px; margin:auto; grid-column:1; grid-row:auto; }
    .game-hud .top-controls{ grid-column:1; grid-row:auto; }
    .game-hud .main-vault{ grid-column:1; grid-row:auto; }
    .game-hud .main-vault .vault-body{ flex-wrap:wrap; }
    .game-hud .main-vault .vault-group{ flex-wrap:wrap; justify-content:center; }
    .game-hud .main-vault .vault-divider{ display:none; }
    .tool-shop-items{ grid-template-columns:repeat(4, minmax(72px, 1fr)); width:100%; }
    .tool-shop-item, .tool-shop-placeholder{ width:auto; }
  }

  @media (max-width: 600px){
    #game-screen{ padding-top:292px; padding-bottom:170px; }
    .floating-inventory .inventory-grid{ grid-template-columns:repeat(8, 1fr); gap:4px; }
    .floating-inventory .inventory-slot{ min-width:0; min-height:0; }
    .floating-inventory .inventory-caption{ display:none; }
  }
