/* 🎮 Game mode: an isometric cartoon city. Classic sections are hidden while it is on. */
body.game-mode main, body.game-mode .footer, body.game-mode .ticker,
html.pre-game main, html.pre-game .footer, html.pre-game .ticker, html.pre-game #city { display: none; }
#boot { display: none; }
html.pre-game #boot {
  display: grid; place-items: center; position: fixed; inset: 63px 0 0; z-index: 30;
  background: linear-gradient(#7fcfff, #d8f2ff 55%, #f6ffe9);
}
:root[data-theme="dark"].pre-game #boot { background: linear-gradient(#0b1030, #23285a 60%, #2b2f55); }
.boot-card {
  display: grid; justify-items: center; gap: 6px; background: #fffdf6; color: #2b2140; border: 4px solid #2b2140; border-radius: 22px;
  box-shadow: 0 7px 0 #2b2140; padding: 22px 30px; font-family: var(--sans);
}
.boot-card b { font-size: 20px; font-weight: 900; } .boot-card small { font-weight: 800; opacity: .6; }
.boot-crane { font-size: 46px; animation: hbob 1s ease-in-out infinite; }
body:not(.game-mode) #city { display: none; }

.mode-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 3px solid var(--edge); border-radius: 10px;
  background: var(--p); color: #111; font-weight: 900; cursor: pointer; box-shadow: var(--sh-sm); white-space: nowrap;
}
.mode-btn:active { transform: translate(2px, 2px); box-shadow: none; }

#city {
  max-width: none; margin: 0; padding: 0;
  --ink: #2b2140; --sky1: #7fcfff; --sky2: #d8f2ff; --grass: #8fdc6e; --grass2: #7fd05f; --road: #5d6577; --road-line: #ffe27a;
  position: relative; height: calc(100dvh - 63px); overflow: hidden; overflow: clip; color: var(--ink);
  background: linear-gradient(var(--sky1), var(--sky2) 55%, #f6ffe9);
  font-family: var(--sans); user-select: none;
}
:root[data-theme="dark"] #city {
  --sky1: #0b1030; --sky2: #23285a; --grass: #3f7d4a; --grass2: #376f41; --road: #3a3f52;
  background: linear-gradient(var(--sky1), var(--sky2) 60%, #2b2f55);
}
.stars { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s;
  background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#fff 1px, transparent 1.5px);
  background-size: 120px 90px, 170px 130px; background-position: 10px 20px, 60px 70px; }
:root[data-theme="dark"] .stars { opacity: .8; }
#city .g-sun { position: absolute; right: 8%; top: 70px; width: 80px; height: 80px; border-radius: 50%; background: #ffe27a; border: 4px solid var(--ink); box-shadow: 0 0 0 14px rgba(255,226,122,.35); }
:root[data-theme="dark"] #city .g-sun { background: #fff6d6; box-shadow: 0 0 0 14px rgba(255,246,214,.12); }
:root[data-theme="dark"] #city .g-sun::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: var(--sky1); left: 22px; top: -10px; }
#city .g-cloud { position: absolute; height: 34px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; animation: cloud linear infinite; opacity: .95; pointer-events: none; }
#city .g-cloud::before { content: ""; position: absolute; width: 46%; height: 150%; left: 18%; top: -70%; background: #fff; border: 3px solid var(--ink); border-bottom: 0; border-radius: 999px 999px 0 0; }
:root[data-theme="dark"] .cloud, :root[data-theme="dark"] #city .g-cloud::before { background: #6b6f9c; }
@keyframes cloud { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }

/* HUD */
.hud {
  position: absolute; left: 14px; right: 14px; top: 12px; z-index: 10; display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.chip-hud {
  display: flex; align-items: center; gap: 9px; background: #fffdf6; border: 3px solid var(--ink); border-radius: 16px; padding: 6px 12px;
  box-shadow: 0 4px 0 var(--ink); color: var(--ink); min-width: 0;
}
.chip-hud .ic { font-size: 22px; animation: hbob 1.8s ease-in-out infinite; }
@keyframes hbob { 50% { transform: translateY(-3px) rotate(-6deg); } }
.chip-hud small { display: block; font-size: 11px; font-weight: 800; opacity: .7; white-space: nowrap; }
.chip-hud b { font-family: var(--mono); font-size: 18px; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; display: inline-block; min-width: 9ch; }
.hpbar { width: 130px; height: 12px; border: 3px solid var(--ink); border-radius: 99px; background: #eee; overflow: hidden; margin-top: 3px; }
.hpbar i { display: block; height: 100%; background: #4fd99a; transition: width .5s, background .3s; }
.lvl { background: #ff8fc7; font-weight: 900; }
.hud-btn { cursor: pointer; font: inherit; font-weight: 900; }
.hud-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.hud .spacer { flex: 1; }

/* map */
.stage { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.stage.drag { cursor: grabbing; }
.stage svg { width: 100%; height: 100%; display: block; }
.tile { stroke: rgba(0,0,0,.08); stroke-width: 1; }
.bld { cursor: pointer; transition: filter .2s; }
.bld:hover { filter: brightness(1.08) drop-shadow(0 0 6px #fff); }
.bld.pop { animation: pop .6s cubic-bezier(.3,1.7,.5,1); transform-box: fill-box; transform-origin: bottom center; }
@keyframes pop { 0% { transform: scale(1, .8); } 60% { transform: scale(1, 1.08); } 100% { transform: none; } }
.win { fill: #bfe9ff; }
:root[data-theme="dark"] .win.on { fill: #ffe27a; animation: flick 4s infinite; }
:root[data-theme="dark"] .win:not(.on) { fill: #2c3150; }
@keyframes flick { 92% { opacity: 1; } 94% { opacity: .4; } 96% { opacity: 1; } }
.sign rect { fill: #fffdf6; stroke: var(--ink); stroke-width: 3; }
.sign text { font-weight: 900; font-size: 15px; fill: var(--ink); font-family: var(--sans); }
.sign .lv { fill: #ff8fc7; }
.sign { animation: sign 2.4s ease-in-out infinite; }
@keyframes sign { 50% { transform: translateY(-4px); } }
.worker { animation: wbob .5s ease-in-out infinite alternate; }
@keyframes wbob { to { transform: translateY(-3px); } }
.smoke { fill: #fff; opacity: .8; animation: smoke 2.4s ease-out infinite; }
@keyframes smoke { from { transform: translateY(0) scale(.6); opacity: .8; } to { transform: translateY(-40px) scale(1.4); opacity: 0; } }
.fountain { animation: wbob 1s ease-in-out infinite alternate; }

.coin {
  position: absolute; z-index: 8; width: 22px; height: 22px; border-radius: 50%; background: #ffd84d; border: 3px solid var(--ink);
  font-size: 11px; font-weight: 900; display: grid; place-items: center; pointer-events: none; color: var(--ink);
  animation: coinfly 1.5s cubic-bezier(.5,0,.6,1) forwards;
}
@keyframes coinfly {
  0% { opacity: 0; transform: translate(0, 0) scale(.3); }
  15% { opacity: 1; transform: translate(0, -24px) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.5) rotate(540deg); }
}
.map-ctrl { position: absolute; right: 14px; bottom: 14px; z-index: 10; display: grid; gap: 8px; }
.map-ctrl button { width: 44px; height: 44px; font-size: 20px; }
.hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9; background: #fffdf6; border: 3px solid var(--ink);
  border-radius: 999px; padding: 8px 16px; font-weight: 900; box-shadow: 0 4px 0 var(--ink); white-space: nowrap; animation: hbob 2s infinite;
}

/* monster */
.monster { position: absolute; z-index: 9; bottom: 40px; left: -260px; width: 200px; pointer-events: none; transition: left 1.2s cubic-bezier(.3,1.4,.5,1); }
.monster.show { left: 30px; animation: mshake .35s infinite; }
@keyframes mshake { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.monster .bub { position: absolute; top: -48px; left: 40px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 5px 12px; font-weight: 900; white-space: nowrap; color: var(--ink); }

/* 3D city */
.city3d { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; touch-action: none; }
#city.is3d .stage { cursor: grab; }
#city.is3d .g-cloud { display: none; }
.labels3d { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.lbl3d {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap; font: inherit; font-weight: 900; font-size: 14px;
  color: var(--ink); background: #fffdf6; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 12px; box-shadow: 0 4px 0 var(--ink);
  transition: opacity .2s; will-change: transform;
}
.lbl3d:hover { background: #ffd84d; }
.lbl3d i { font-style: normal; margin-left: 6px; display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: #ff8fc7; border: 2px solid var(--ink); font-size: 12px; }
@media (max-width: 700px) { .lbl3d { font-size: 11px; padding: 2px 8px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); } .lbl3d i { min-width: 18px; height: 18px; } }

/* drawer */
.drawer {
  position: absolute; z-index: 20; top: 86px; right: 12px; bottom: 12px; width: min(440px, calc(100% - 24px)); display: flex; flex-direction: column;
  background: #fffdf6; color: var(--ink); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink);
  transform: translateX(calc(100% + 40px)); transition: transform .4s cubic-bezier(.3,1.3,.5,1);
}
.drawer.open { transform: none; }
.dr-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 4px solid var(--ink); border-radius: 18px 18px 0 0; }
.dr-head .em { font-size: 34px; }
.dr-head h3 { font-size: 22px; font-weight: 900; line-height: 1.1; }
.dr-head p { font-size: 12.5px; font-weight: 800; opacity: .75; }
.dr-close { margin-left: auto; width: 38px; height: 38px; border: 3px solid var(--ink); border-radius: 50%; background: #fff; font-size: 18px; font-weight: 900; cursor: pointer; flex: none; }
.dr-body { flex: 1; overflow: auto; padding: 14px 16px 18px; }
.dr-body h4 { font-size: 14px; font-weight: 900; margin: 12px 0 8px; }
.g-search { width: 100%; border: 3px solid var(--ink); border-radius: 12px; padding: 10px 12px; font: inherit; font-weight: 700; background: #fff; color: var(--ink); outline: none; }
.g-list { display: grid; gap: 8px; margin-top: 10px; }
.g-item { border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 9px 11px; cursor: pointer; transition: transform .12s; }
.g-item:hover { transform: translateX(-3px); }
.g-item.open { background: #fff7d6; cursor: default; }
.g-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.g-row .nm { font-family: var(--mono); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.g-row .pv { font-size: 12px; font-weight: 800; opacity: .65; }
.g-row > div { flex: 1; min-width: 0; }
.g-row .pr { font-family: var(--mono); font-weight: 900; white-space: nowrap; text-align: right; }
.g-row .pr small { display: block; font-size: 11px; opacity: .7; }
.g-form { display: grid; gap: 8px; margin-top: 10px; }
.g-form label { font-size: 13px; font-weight: 800; display: grid; gap: 4px; }
.g-form input { border: 3px solid var(--ink); border-radius: 10px; padding: 7px 10px; font-family: var(--mono); font-weight: 800; width: 100%; background: #fff; color: var(--ink); }
.g-form .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g-btn {
  cursor: pointer; font: inherit; font-weight: 900; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; background: #4fd99a; color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.g-btn:active { transform: translateY(4px); box-shadow: none; }
.g-btn.red { background: #ff6b6b; color: #fff; }
.g-btn.y { background: #ffd84d; }
.g-btn.b { background: #6ea8ff; color: #fff; }
.g-btn.wide { width: 100%; }
.g-est { font-weight: 900; font-size: 15px; }
.hired { display: grid; gap: 6px; }
.hired .g-row { border: 3px dashed var(--ink); border-radius: 12px; padding: 6px 10px; background: #e9fff3; }
.x { cursor: pointer; border: 0; background: none; color: #d6336c; font-weight: 900; font-size: 15px; }
.g-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.g-tabs button { border: 0; padding: 9px; font: inherit; font-weight: 900; cursor: pointer; background: #fff; color: var(--ink); }
.g-tabs button + button { border-left: 3px solid var(--ink); }
.g-tabs button.on { background: var(--ink); color: #fff; }
.bill-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 10px; border-top: 4px solid var(--ink); font-weight: 900; }
.bill-total b { font-family: var(--mono); font-size: 30px; background: #ffd84d; border: 3px solid var(--ink); border-radius: 10px; padding: 0 8px; }
.bill-sub { display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; margin-top: 6px; opacity: .8; }
.g-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.needs { display: flex; flex-wrap: wrap; gap: 8px; }
.needs label { border: 3px solid var(--ink); border-radius: 999px; padding: 5px 12px; font-weight: 900; cursor: pointer; background: #fff; display: inline-flex; gap: 6px; align-items: center; }
.needs input { accent-color: #ff6b6b; }
.budget-row { display: flex; gap: 10px; align-items: center; font-weight: 900; }
.budget-row input[type=range] { flex: 1; accent-color: #ff6b6b; }
.budget-row input[type=number] { width: 110px; }
.plans { display: grid; gap: 10px; margin-top: 12px; }
.plan { border: 3px solid var(--ink); border-radius: 16px; padding: 12px; background: #fff; box-shadow: 0 4px 0 var(--ink); }
.plan.best { background: #fff7d6; }
.plan h5 { font-size: 16px; font-weight: 900; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.plan .ok { font-size: 12px; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px; background: #4fd99a; }
.plan .no { font-size: 12px; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px; background: #ff6b6b; color: #fff; }
.plan ul { list-style: none; margin: 8px 0; font-size: 13.5px; font-weight: 700; }
.plan li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 2px dotted #ccc; }
.plan li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-table { display: grid; gap: 6px; }
.ep-g { display: block; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; background: #fff; text-decoration: none; color: var(--ink); font-family: var(--mono); font-weight: 800; font-size: 13px; overflow-wrap: anywhere; }
.note-g { font-size: 12.5px; font-weight: 700; opacity: .7; margin-top: 10px; }

.topbar .logo { white-space: nowrap; flex: none; }
@media (max-width: 700px) {
  #city { height: calc(100dvh - 58px); }
  .topbar .logo { font-size: 14px; padding: 4px 8px; } .topbar .logo-mark { display: none; }
  .hud { left: 8px; right: 8px; top: 8px; gap: 6px; }
  .chip-hud { padding: 3px 8px; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
  .chip-hud .ic { font-size: 16px; } .chip-hud small { font-size: 10px; } .chip-hud b { font-size: 14px; } .hpbar { width: 70px; height: 9px; border-width: 2px; }
  .hud .hide-sm, .hud-btn span { display: none; }
  .lvl { font-size: 12px; }
  #city .g-sun { width: 46px; height: 46px; top: 120px; right: 6%; box-shadow: 0 0 0 8px rgba(255,226,122,.35); }
  :root[data-theme="dark"] #city .g-sun::after { width: 40px; height: 40px; left: 14px; top: -6px; }
  .map-ctrl { right: 8px; bottom: 8px; } .map-ctrl button { width: 38px; height: 38px; font-size: 16px; }
  .hint { font-size: 13px; bottom: 12px; left: 8px; transform: none; white-space: normal; max-width: calc(100% - 70px); }
  .drawer { top: auto; height: 74%; left: 8px; right: 8px; bottom: 8px; width: auto; transform: translateY(calc(100% + 40px)); }
  .drawer.open { transform: none; }
  .monster { width: 150px; }
  .mode-btn span { display: none; }
}
