:root {
  --navy: #1b3a5c; --navy2: #12283f; --gold: #f1c40f; --gold2: #d4a017; --sand: #f3e2bb; --sand2: #e3c98e;
  --ink: #2b1d12; --red: #c0392b; --blue: #2e86c1;
  --side: 240px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy2); color: var(--ink); font-family: 'Fredoka', 'Trebuchet MS', sans-serif; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
body { background: radial-gradient(circle at 30% 20%, #2a5784, var(--navy2) 70%); }
button { font-family: inherit; cursor: pointer; }
h1, h2 { font-family: 'Luckiest Guy', Impact, sans-serif; letter-spacing: 1px; margin: 0.2em 0; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.screen.on { display: flex; }
.panel {
  background: linear-gradient(#f9eccd, var(--sand2)); border: 4px solid var(--ink); border-radius: 22px; padding: 18px 22px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .35), inset 0 0 0 3px #fff6dc; text-align: center; max-width: 440px; width: 100%;
  max-height: calc(100dvh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; align-items: stretch;
}
.panel.wide { max-width: 860px; }
.panel.title h1 { position: relative; font-size: clamp(30px, 7vw, 48px); color: var(--gold); -webkit-text-stroke: 2px var(--ink); text-shadow: 0 4px 0 var(--ink); line-height: 1; }
.panel h2 { font-size: 30px; color: var(--navy); }
.sub { margin: 0 0 6px; font-weight: 600; color: #7a4a1a; }
#titleArt { width: 360px; max-width: 100%; height: auto; aspect-ratio: 3/1; align-self: center; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.hint { font-size: 14px; margin: 0; }

.btn {
  border: 3px solid var(--ink); border-radius: 14px; padding: 9px 14px; font-size: 17px; font-weight: 600; color: #fff;
  background: linear-gradient(#3a8fd6, #1f5f99); box-shadow: 0 4px 0 var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .35); transition: transform .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { filter: grayscale(.8) brightness(.85); cursor: not-allowed; }
.btn.big { font-size: 22px; padding: 12px 16px; }
.btn.gold { background: linear-gradient(#ffd84d, #e09b0e); color: var(--ink); text-shadow: 0 1px 0 #fff3; }
.btn small { display: block; font-size: 13px; font-weight: 400; opacity: .9; }
.btn.small { font-size: 13px; padding: 4px 8px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); border-radius: 9px; }
.diff-easy { background: linear-gradient(#58c25e, #2f8a36); }
.diff-medium { background: linear-gradient(#f0a33a, #c66d12); }
.diff-hard { background: linear-gradient(#e2553f, #9b2a1a); }

#diffList { display: flex; flex-direction: column; gap: 10px; }
.panel [data-back] { align-self: center; min-width: 140px; }
#mapList { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.mapcard { border: 3px solid var(--ink); border-radius: 14px; background: #fff7e3; padding: 6px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 4px 0 var(--ink); font-size: 16px; }
.mapcard:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.mapcard img { width: 100%; border-radius: 9px; border: 2px solid var(--ink); }
.mapcard i { font-size: 13px; color: #7a4a1a; }
.medals span { filter: grayscale(1) opacity(.3); font-size: 20px; } .medals span.got { filter: none; }
.help { text-align: left; } .help ul { padding-left: 4px; list-style: none; margin: 0; } .help li { margin: 6px 0; } .help .btn { align-self: center; }

/* ---------- game layout ---------- */
#game { padding: 0; align-items: stretch; justify-content: stretch; gap: 0; }
#stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
#cv { display: block; border-radius: 6px; box-shadow: 0 0 0 3px var(--ink), 0 6px 20px rgba(0, 0, 0, .5); touch-action: none; }
#side {
  width: calc(var(--side) + env(safe-area-inset-right, 0px)); flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px; padding-right: max(8px, env(safe-area-inset-right));
  background: linear-gradient(#f6e6c2, #dcbf84); border-left: 4px solid var(--ink); overflow-x: hidden; overflow-y: auto;
}
#stats { display: flex; justify-content: space-between; gap: 4px; font-weight: 600; font-size: 16px; background: var(--navy); color: #fff; border-radius: 10px; padding: 6px 8px; border: 2px solid var(--ink); flex-wrap: wrap; }
#shopWrap { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
#shop { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; flex: none; min-width: 0; }
.tbtn { position: relative; aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 10px; background: radial-gradient(#fff9e8, #e8cf98); padding: 0; box-shadow: 0 3px 0 var(--ink); }
.tbtn img { width: 100%; height: 100%; display: block; min-width: 0; }
.tbtn { min-width: 0; }
#stats, #shopWrap, #info, #sel { min-width: 0; }
#side { container-type: inline-size; }   /* the stats text scales with the panel's width */
.tbtn .price { position: absolute; bottom: 0; left: 0; right: 0; font-size: 12px; font-weight: 600; color: #fff; background: rgba(27, 58, 92, .85); border-radius: 0 0 8px 8px; }
.tbtn.poor { filter: grayscale(.9) opacity(.6); }
.tbtn.active { outline: 3px solid var(--gold); background: radial-gradient(#fff, #ffe37a); }
#info { font-size: 13px; background: #fff7e3; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 8px; min-height: 60px; }
#info .cost { color: #2f8a36; font-weight: 600; }
#info .btn { margin-top: 4px; }

#sel { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.selhead { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.x { border: 2px solid var(--ink); background: #fff; border-radius: 8px; font-weight: 700; width: 30px; height: 30px; }
.selstats { display: flex; justify-content: space-between; align-items: center; }
.upaths { display: flex; flex-direction: column; gap: 6px; }
.upath { border: 2px solid var(--ink); border-radius: 10px; padding: 6px; background: #fff7e3; display: flex; flex-direction: column; gap: 3px; }
.upath.p0 { border-left: 8px solid #e67e22; } .upath.p1 { border-left: 8px solid #3fa0e0; }
.uname { font-weight: 600; font-size: 14px; } .udesc { font-size: 12px; color: #5d4037; }
.pips { display: flex; gap: 3px; } .pips i { width: 14px; height: 6px; border-radius: 3px; background: #ccb88e; border: 1px solid var(--ink); }
.upath.p0 .pips i.on { background: #e67e22; } .upath.p1 .pips i.on { background: #3fa0e0; }
.ubuy { font-size: 14px; padding: 5px; background: linear-gradient(#58c25e, #2f8a36); }
.sell { background: linear-gradient(#e2553f, #9b2a1a); font-size: 15px; padding: 6px; }
.abil { background: linear-gradient(#b05ce0, #6c2a99); }

#btnMute { position: absolute; z-index: 30; right: 68px; top: 14px; width: 46px; height: 46px; font-size: 18px; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 4px 0 var(--ink); background: radial-gradient(circle at 35% 30%, #ffd84d, #e09b0e); }
#btnMute.off { background: radial-gradient(circle at 35% 30%, #b0b0b0, #6d6d6d); }
#btnMute.off::after { content: ''; position: absolute; left: 8px; right: 8px; top: 50%; height: 3px; background: #c0392b; transform: rotate(-45deg); border-radius: 2px; }
#btnMute:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tbtn { touch-action: none; }
#btnGo, #btnPause { position: absolute; z-index: 30; border: 3px solid var(--ink); border-radius: 50%; color: #fff; font-size: 26px; box-shadow: 0 4px 0 var(--ink); }
#btnGo { right: 14px; bottom: 14px; width: 68px; height: 68px; background: radial-gradient(circle at 35% 30%, #6fdc6f, #2f8a36); }
#btnGo.ff { background: radial-gradient(circle at 35% 30%, #ffd84d, #e09b0e); font-size: 17px; color: var(--ink); }
#btnPause { right: 14px; top: 14px; width: 46px; height: 46px; font-size: 18px; background: radial-gradient(circle at 35% 30%, #5aa7e6, #1f5f99); }
#btnGo:active, #btnPause:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#abilBar { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%; }
.abtn { border: 3px solid var(--ink); border-radius: 12px; background: linear-gradient(#b05ce0, #6c2a99); color: #fff; font-size: 18px; padding: 4px 8px; box-shadow: 0 3px 0 var(--ink); }
.abtn small { display: block; font-size: 10px; } .abtn:disabled { filter: grayscale(.7) brightness(.8); }

.overlay { position: absolute; inset: 0; background: rgba(10, 20, 35, .6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.overlay[hidden] { display: none; }

#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; pointer-events: none; width: min(460px, calc(100% - 32px)); }
.toast { background: #fff7e3; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .4); font-size: 14px; display: flex; gap: 10px; align-items: center; transition: opacity .4s, transform .4s; }
.toast img { width: 64px; flex: none; }
.toast.gone { opacity: 0; transform: translateY(-10px); }

/* phones in landscape: the map is limited by the screen's height, so the side panel takes
   whatever width is left over (200-300px) and the cat buttons grow to fill it */
@media (max-height: 520px) {
  :root { --side: clamp(200px, calc(100vw - 150dvh), 300px); }
  #shop { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  #info { min-height: 0; font-size: 13px; }
  #stats { font-size: clamp(10px, 7cqi, 15px); padding: 5px 6px; }
  .tbtn .price { font-size: 13px; }
  #btnGo { width: 56px; height: 56px; right: 10px; bottom: 10px; }
  #btnPause { width: 40px; height: 40px; right: 10px; top: 10px; }
  #btnMute { width: 40px; height: 40px; right: 56px; top: 10px; }
  .panel { padding: 12px 16px; gap: 7px; } .btn.big { font-size: 18px; padding: 8px 12px; }
  #titleArt { width: 240px; }
}
/* portrait: stack the shop under the map */
@media (max-aspect-ratio: 1/1) {
  #game { flex-direction: column; }
  #side { width: auto; height: 42dvh; border-left: none; border-top: 4px solid var(--ink); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  #shop { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .upaths { flex-direction: row; } .upath { flex: 1; }
  #btnGo { width: 54px; height: 54px; right: 8px; bottom: 8px; font-size: 20px; }
  #btnPause { width: 38px; height: 38px; right: 8px; top: 8px; }
  #btnMute { width: 38px; height: 38px; right: 52px; top: 8px; }
  #abilBar { left: 8px; bottom: 8px; }
}

/* ---------- bouncy cartoon motion ---------- */
@keyframes popIn { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.08); } 75% { transform: rotate(8deg) scale(1.08); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes slideDown { 0% { transform: translateY(-40px) scale(.8); opacity: 0; } 70% { transform: translateY(4px) scale(1.02); opacity: 1; } 100% { transform: none; } }
@keyframes titleBob { 0%, 100% { transform: rotate(-2deg) translateY(0); } 50% { transform: rotate(2deg) translateY(-4px); } }
@keyframes shimmer { 0% { background-position: -150% 0; } 100% { background-position: 250% 0; } }
.screen.on .panel, .overlay:not([hidden]) .panel { animation: popIn .38s cubic-bezier(.3, 1.5, .5, 1); }
.panel.title h1 { animation: titleBob 3s ease-in-out infinite; }
.btn { transition: transform .08s, filter .15s; }
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.1); }
.tbtn { transition: transform .1s; }
.tbtn:hover img { animation: wiggle .5s ease-in-out; }
.tbtn:hover { transform: translateY(-2px); }
.tbtn.active { animation: pulse .8s ease-in-out infinite; }
.mapcard { transition: transform .12s; } .mapcard:hover { transform: translateY(-4px) rotate(-1deg); }
.ubuy:not(:disabled) { background: linear-gradient(100deg, #2f8a36 30%, #7be07f 50%, #2f8a36 70%) , linear-gradient(#58c25e, #2f8a36); background-size: 250% 100%, 100% 100%; animation: shimmer 2.4s linear infinite; }
.toast { animation: slideDown .45s cubic-bezier(.3, 1.4, .5, 1); }
#btnGo:not(.ff) { animation: pulse 1.4s ease-in-out infinite; }
#btnGo:active { animation: none; }
#stats span { display: inline-block; }
#stats .bump { animation: popIn .3s; }

/* ---------- new enemy papyrus scroll ---------- */
#intro { position: absolute; inset: 0; z-index: 26; display: flex; align-items: center; justify-content: center; padding: 22px 12px; pointer-events: none; background: radial-gradient(ellipse at center, rgba(20, 10, 0, .35), rgba(20, 10, 0, .05) 70%); }
#intro .scroll {
  pointer-events: auto; position: relative; width: min(600px, 94%); max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 26px 16px; text-align: center; color: #3b2410;
  background:
    repeating-linear-gradient(90deg, rgba(150, 105, 45, .07) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(0deg, rgba(150, 105, 45, .06) 0 1px, transparent 1px 9px),
    radial-gradient(ellipse at 50% 40%, #fcf1d6 0%, #f1dcab 55%, #d8b878 100%);
  border-left: 4px solid #7a5022; border-right: 4px solid #7a5022;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .45), inset 0 0 40px rgba(140, 90, 30, .35);
  animation: unroll .55s cubic-bezier(.3, 1.35, .5, 1);
  transform-origin: center top;
}
@keyframes unroll { 0% { transform: scaleY(.05); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
#intro .rod { position: absolute; left: -18px; right: -18px; top: -13px; height: 22px; border: 3px solid var(--ink); border-radius: 11px;
  background: linear-gradient(#c8894a, #8b5a2b 45%, #5d3a19 55%, #a8743f); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
#intro .rod::before, #intro .rod::after { content: ''; position: absolute; top: -6px; width: 16px; height: 28px; border: 3px solid var(--ink); border-radius: 8px; background: linear-gradient(90deg, #f1c40f, #b7950b); }
#intro .rod::before { left: -12px; } #intro .rod::after { right: -12px; }
#intro .rod.bottom { top: auto; bottom: -13px; }
#intro .band { align-self: stretch; height: 10px; border: 2px solid var(--ink); border-radius: 3px; background: repeating-linear-gradient(90deg, #f1c40f 0 10px, #2471a3 10px 20px, #c0392b 20px 24px, #2471a3 24px 34px); }
#intro .stamp { font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 15px; letter-spacing: 1px; color: #fff; background: #c0392b; border: 3px solid var(--ink); border-radius: 8px; padding: 2px 10px; transform: rotate(-4deg); box-shadow: 0 3px 0 var(--ink); animation: stampIn .5s .25s both cubic-bezier(.3, 1.8, .5, 1); }
@keyframes stampIn { 0% { transform: scale(2.4) rotate(-12deg); opacity: 0; } 100% { transform: scale(1) rotate(-4deg); opacity: 1; } }
#intro h2 { font-size: clamp(20px, 3.4vw, 30px); color: #8f1d16; -webkit-text-stroke: 1px #3b2410; margin: 2px 0 0; }
#intro .when { margin: 0; font-size: 14px; }
#intro .cards { display: flex; flex-direction: column; gap: 8px; align-self: stretch; overflow-y: auto; min-height: 0; padding: 2px; }
#intro .dcard { display: flex; gap: 12px; align-items: center; text-align: left; background: rgba(255, 250, 235, .7); border: 2px solid #a87a43; border-radius: 12px; padding: 8px 10px; }
#intro .dimg { flex: none; width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle at 40% 35%, #fff6d8, #e3c98e); display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12); }
#intro .dimg img { width: 92px; height: 92px; animation: dogBob .9s ease-in-out infinite; }
@keyframes dogBob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-4px) rotate(3deg); } }
#intro h3 { font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 22px; margin: 0; color: #1b3a5c; letter-spacing: .5px; }
#intro .dtext p { margin: 2px 0 5px; font-size: 14px; line-height: 1.25; }
#intro .chips { display: flex; flex-wrap: wrap; gap: 4px; }
#intro .chip { font-size: 12px; font-weight: 600; border: 2px solid #a87a43; background: #fff7e3; border-radius: 999px; padding: 1px 8px; }
#intro .chip.bad { background: #fde2dd; border-color: #c0392b; color: #8f1d16; }
#intro .chip.good { background: #dff3df; border-color: #2f8a36; color: #1e6b25; }
#intro .introbtns { display: flex; gap: 10px; margin-top: 4px; }
#intro .introbtns .btn.big { font-size: 19px; }
@media (max-height: 520px), (max-aspect-ratio: 1/1) {
  #intro { padding: 16px 6px; }
  #intro .scroll { padding: 12px 14px 10px; gap: 4px; }
  #intro .dimg { width: 64px; height: 64px; } #intro .dimg img { width: 60px; height: 60px; }
  #intro h3 { font-size: 18px; } #intro .dtext p { font-size: 12px; } #intro .chip { font-size: 10.5px; }
  #intro .introbtns .btn.big { font-size: 16px; padding: 6px 12px; }
}

/* ---------- map select: 20 maps grouped by difficulty ---------- */
#mapList { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
#mapList .lvl { grid-column: 1 / -1; margin: 6px 0 -4px; text-align: left; font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 20px; letter-spacing: .5px; display: flex; align-items: baseline; gap: 8px; }
#mapList .lvl small { font-family: 'Fredoka', sans-serif; font-size: 13px; color: #7a4a1a; }
.lvl-beginner { color: #2f8a36; } .lvl-intermediate { color: #c66d12; } .lvl-advanced { color: #9b2a1a; } .lvl-expert { color: #5b2c6f; }
.mapcard img { aspect-ratio: 3 / 2; background: linear-gradient(110deg, #e9d3a2 30%, #f6e7c4 50%, #e9d3a2 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.mapcard img[src] { animation: none; background: none; }
.mapcard b { font-size: 15px; }

/* ---------- Road to Cleocatra ---------- */
.btn.road { background: linear-gradient(#a569bd, #6c3483); }
.btn.road small { color: #f9e79f; }
.roadpanel { max-width: 900px; gap: 8px; }
.roadpanel h2 { color: #6c3483; }
#roadTrack { display: flex; flex-wrap: wrap; gap: 6px 4px; justify-content: center; align-items: center; padding: 6px; background: repeating-linear-gradient(90deg, #d9b878 0 10px, #cfa968 10px 20px); border: 2px solid var(--ink); border-radius: 12px; }
.rnode { position: relative; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); background: #e9d9b5; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; color: #8a7350; }
.rnode small { position: absolute; bottom: -9px; font-size: 9px; background: #2f8a36; color: #fff; border-radius: 6px; padding: 0 3px; line-height: 12px; }
.rnode.done { background: radial-gradient(circle at 35% 30%, #7be07f, #2f8a36); color: #fff; }
.rnode.here { background: radial-gradient(circle at 35% 30%, #ffe680, #e09b0e); color: var(--ink); animation: pulse 1s ease-in-out infinite; box-shadow: 0 0 0 3px #fff6; }
.rnode.herostop::after { content: '⭐'; position: absolute; top: -10px; right: -8px; font-size: 12px; }
.rnode.final { width: 40px; height: 40px; font-size: 20px; background: radial-gradient(circle at 35% 30%, #f9e79f, #b7950b); }
.newhero { background: linear-gradient(90deg, #fdebd0, #f9e79f, #fdebd0); border: 2px solid #b7950b; border-radius: 10px; padding: 6px; font-size: 15px; animation: popIn .5s; }
.roadnext { display: flex; gap: 12px; align-items: center; text-align: left; background: #fff7e3; border: 2px solid var(--ink); border-radius: 12px; padding: 8px; }
.roadnext img { width: 180px; flex: none; border-radius: 8px; border: 2px solid var(--ink); aspect-ratio: 3 / 2; }
.roadnext h3 { margin: 0 0 4px; font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 22px; color: #1b3a5c; }
.roadnext p { margin: 0; font-size: 14px; line-height: 1.35; }
.pickhero { margin: 4px 0 0; font-family: 'Luckiest Guy', Impact, sans-serif; color: #6c3483; }
.pickhero small { font-family: 'Fredoka', sans-serif; font-size: 13px; color: #7a4a1a; }
#heroList { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.herocard { border: 3px solid var(--ink); border-radius: 12px; background: #fff7e3; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 3px 0 var(--ink); font-size: 15px; transition: transform .1s; }
.herocard img { width: 56px; height: 56px; }
.herocard i { font-size: 12px; color: #7a4a1a; }
.herocard small { font-size: 11px; line-height: 1.2; color: #5d4037; }
.herocard.picked { background: radial-gradient(#fff, #ffe37a); outline: 3px solid #b7950b; transform: translateY(-3px); }
.herocard.locked { filter: grayscale(1) opacity(.5); cursor: default; }
.roadbtns { align-items: center; }
.tbtn.hero { background: radial-gradient(#fff6c9, #f1c40f); outline: 2px solid #b7950b; }
.tbtn .herotag { position: absolute; top: -2px; left: 50%; transform: translateX(-50%); font-size: 9px; font-weight: 700; background: #6c3483; color: #fff; border-radius: 6px; padding: 0 4px; }
.herotitle { font-size: 12px; color: #6c3483; margin-top: -4px; }
.herolvl { font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.xpbar { height: 8px; border: 2px solid var(--ink); border-radius: 6px; background: #e9d9b5; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #f1c40f, #e67e22); }
.perk { font-size: 11px; font-weight: 400; color: #1e6b25; }
#stats small { font-size: 11px; opacity: .8; }
/* victory */
#cleo { padding: 0; flex-direction: column; background: #1b0f2e; }
#cleoCv { position: absolute; inset: 0; width: 100%; height: 100%; }
.cleotext { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px max(16px, env(safe-area-inset-bottom)); text-align: center; color: #fff; background: linear-gradient(transparent, rgba(20,8,40,.85) 40%); }
.cleotext h1 { position: relative; --gold: #f9e79f; font-size: clamp(30px, 6vw, 54px); color: #f9e79f; -webkit-text-stroke: 2px var(--ink); text-shadow: 0 4px 0 var(--ink); margin: 0; animation: titleBob 3s ease-in-out infinite; }
.cleotext p { margin: 4px 0; font-size: 16px; }
.cleostats { color: #f9e79f; font-weight: 600; }
.cleotext .row { max-width: 460px; margin: 8px auto 0; }
@media (max-height: 520px) { .roadnext img { width: 120px; } #heroList { grid-template-columns: repeat(5, 1fr); } .herocard small { display: none; } .rnode { width: 26px; height: 26px; font-size: 11px; } }

/* road v2: level select + treasury */
.treasury { font-size: 17px; background: linear-gradient(90deg, #fdebd0, #f9e79f, #fdebd0); border: 2px solid #b7950b; border-radius: 10px; padding: 4px 8px; }
.treasury small { font-size: 12px; color: #7a4a1a; }
.rnode { cursor: default; padding: 0; font-family: inherit; }
.rnode.open { cursor: pointer; background: #fff7e3; color: var(--ink); }
.rnode.open:hover { transform: translateY(-2px); }
.rnode.locked { opacity: .55; font-size: 11px; }
.rnode.here { outline: 3px solid #6c3483; outline-offset: 1px; }
#roadEnd .panel .btn { width: 100%; }
.rnode.open.done { background: radial-gradient(circle at 35% 30%, #7be07f, #2f8a36); color: #fff; }

/* settings */
.settings { max-width: 460px; }
.sethead { margin: 6px 0 -2px; text-align: left; font-family: 'Luckiest Guy', Impact, sans-serif; color: #1b3a5c; font-size: 18px; }
.btn.danger { background: linear-gradient(#e2553f, #9b2a1a); }

/* stats bar: fixed layout so changing numbers never shift or re-wrap anything */
#stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; flex-wrap: nowrap; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; }
#stats.stats-road { grid-template-columns: auto auto; row-gap: 2px; }
#stats b { font-weight: 600; }
.tbtn, .tbtn img { backface-visibility: hidden; }
.tbtn { transition: transform .1s, filter .2s; }

.resumebox { display: flex; align-items: center; gap: 10px; justify-content: space-between; text-align: left; font-size: 14px; background: #e8f8e8; border: 2px solid #2f8a36; border-radius: 10px; padding: 6px 8px; animation: popIn .4s; }
.resumebox .btn { flex: none; }
@media (max-width: 520px) { .roadnext { flex-direction: column; align-items: stretch; } .roadnext img { width: 100%; } }

/* F8 performance readout */
#perf { position: fixed; left: 8px; bottom: 8px; z-index: 30; pointer-events: none; white-space: pre; font: 12px/1.35 ui-monospace, Consolas, monospace; color: #e8f5e9; background: rgba(0,0,0,.72); padding: 6px 9px; border-radius: 8px; }

/* next-round preview */
#nextUp { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 72%; background: rgba(255,247,227,.92); border: 2px solid var(--ink); border-radius: 12px; padding: 3px 10px; font-size: 14px; pointer-events: none; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
#nextUp span { display: inline-flex; align-items: center; font-weight: 700; }
#nextUp img { width: 28px; height: 28px; }
@media (max-width: 700px) { #nextUp { font-size: 12px; top: 6px; max-width: 86%; } #nextUp img { width: 22px; height: 22px; } }
/* synergies */
.synhint { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 12.5px; }
.synhint span { background: rgba(244,208,63,.18); border-radius: 7px; padding: 3px 6px; }
.synhint span.on { background: #f4d03f; color: #3b2a05; }
.btn.sell.armed { background: #e74c3c; animation: glowpulse .5s ease-in-out infinite alternate; }
@keyframes glowpulse { to { filter: brightness(1.25); } }
/* game-over stats and leaderboard */
.ostats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.ostats > div { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.55); border: 2px solid var(--ink); border-radius: 10px; padding: 5px 8px; text-align: left; }
.ostats i { font-style: normal; font-size: 24px; } .ostats img { width: 34px; height: 34px; }
.ostats span { display: flex; flex-direction: column; font-size: 12px; line-height: 1.15; } .ostats b { font-size: 16px; } .ostats small { font-size: 11px; opacity: .75; }
.newbest { font-weight: 800; color: #b9770e; margin: 4px 0; animation: glowpulse .6s ease-in-out infinite alternate; }
#overStats h4 { margin: 8px 0 4px; font-size: 14px; }
.board { list-style: none; padding: 0; margin: 0 0 8px; counter-reset: rank; font-size: 13px; }
.board li { display: grid; grid-template-columns: 22px 1fr 1fr auto; gap: 6px; padding: 3px 6px; border-radius: 7px; counter-increment: rank; text-align: left; }
.board li::before { content: counter(rank) '.'; font-weight: 800; }
.board li.me { background: #f4d03f; }
.board small { opacity: .7; }
.medals .best { font-style: normal; font-size: 13px; font-weight: 700; margin-left: 6px; color: #7a4a1a; }
/* hazard countdown */
#hazWarn { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(27,42,58,.88); color: #fff; border: 3px solid #f4d03f; border-radius: 12px; padding: 4px 14px; font-weight: 800; font-size: 16px; pointer-events: none; animation: glowpulse .5s ease-in-out infinite alternate; white-space: nowrap; }
#hazWarn b { font-size: 20px; color: #f9e79f; }
@media (max-width: 700px) { #hazWarn { font-size: 13px; top: 6px; } #hazWarn b { font-size: 16px; } }
/* crisp canvas-drawn titles: the page text keeps the layout but is invisible */
h1.crisp { color: transparent !important; -webkit-text-stroke: 0 !important; text-shadow: none !important; animation: none !important; }
.titlecv { position: absolute; left: -18px; top: -16px; width: calc(100% + 36px); height: calc(100% + 34px); pointer-events: none; }
/* Library of Alexandria */
.library { text-align: left; max-width: 980px; gap: 8px; }
.libhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.libhead h2 { margin: 0; font-size: clamp(22px, 4vw, 30px); color: var(--navy); }
.libhead .x { font-size: 20px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--ink); background: #fff7e3; font-weight: 800; }
#libTabs { display: flex; flex-wrap: wrap; gap: 6px; }
.libtab { border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; background: #fff7e3; font-weight: 700; font-size: 14px; }
.libtab.on { background: var(--gold); box-shadow: 0 2px 0 var(--ink); }
#libSearch { border: 2px solid #a87a43; border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 15px; background: #fffaf0; user-select: text; -webkit-user-select: text; }
#libBody { overflow-y: auto; min-height: 0; }
.libsec h3 { font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 21px; margin: 10px 0 4px; color: var(--navy); letter-spacing: .5px; }
.libnote { font-size: 13px; margin: 0 0 6px; opacity: .8; }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.libcard { background: rgba(255, 250, 235, .8); border: 2px solid #a87a43; border-radius: 12px; padding: 8px 10px; font-size: 13.5px; line-height: 1.3; }
.libcard.good { border-color: #2f8a36; } .libcard.bad { border-color: #c0392b; }
.libcard p { margin: 5px 0 0; }
.libtop { display: flex; gap: 10px; align-items: center; }
.libtop b { font-size: 16px; display: block; } .libtop i { font-weight: 600; font-size: 12px; opacity: .75; } .libtop small { display: block; font-size: 12px; opacity: .75; }
.libicon { flex: none; display: flex; gap: 2px; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; }
.libicon.round { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--ink); background: radial-gradient(circle at 40% 35%, #fff6d8, #e3c98e); }
.libicon.round img { width: 58px; height: 58px; }
.libdog .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.libdog .chip { font-size: 11.5px; font-weight: 600; border: 2px solid #a87a43; background: #fff7e3; border-radius: 999px; padding: 0 7px; }
.libdog .chip.bad { background: #fde2dd; border-color: #c0392b; color: #8f1d16; } .libdog .chip.good { background: #dff3df; border-color: #2f8a36; color: #1e6b25; }
.libcat summary { cursor: pointer; list-style: none; } .libcat summary::-webkit-details-marker { display: none; }
.libcat summary::after { content: '▾ Upgrades'; display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: #7a4a1a; }
.libcat[open] summary::after { content: '▴ Hide upgrades'; }
.libpaths { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.libpath { border-radius: 8px; padding: 5px 7px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.libpath.p0 { background: rgba(230, 126, 34, .14); } .libpath.p1 { background: rgba(63, 160, 224, .14); }
.libpath h4 { margin: 0; font-size: 13px; } .libpath .cost, .libcard .cost { color: #7a4a1a; font-weight: 700; }
.libsyn { background: rgba(244, 208, 63, .25); border-radius: 8px; padding: 4px 7px; font-size: 12.5px; }
.libperks { margin: 6px 0 0; padding-left: 0; list-style: none; font-size: 12.5px; display: grid; gap: 2px; }
.libperks b { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: var(--gold); text-align: center; font-size: 11px; line-height: 18px; margin-right: 4px; }
.libhz { display: inline-flex; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); align-items: center; justify-content: center; font-weight: 800; }
.libmaps { font-size: 12px; opacity: .85; }
.libmap { display: flex; gap: 10px; align-items: flex-start; } .libmap b { font-size: 15px; display: block; } .libmap small { display: block; font-size: 12px; color: #7a4a1a; }
.libthumb { width: 110px; aspect-ratio: 3 / 2; border-radius: 8px; border: 2px solid var(--ink); flex: none; background: #e9d3a2; }
.libbasics { list-style: none; padding: 0; margin: 0; } .libbasics li { margin: 6px 0; }
.libnone { text-align: center; padding: 20px; }
@media (max-width: 600px) { .libpaths { grid-template-columns: 1fr; } .libgrid { grid-template-columns: 1fr; } .libthumb { width: 90px; } }
.libdiff { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 2px 0 6px; font-weight: 700; font-size: 13px; opacity: 1; }
.libdiff button { border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; background: #fff7e3; font-weight: 700; font-size: 13px; }
.libdiff button.on { background: var(--gold); box-shadow: 0 2px 0 var(--ink); }
/* turn-your-phone prompt (phones held upright, in a game) */
#rotate { display: none; position: fixed; inset: 0; z-index: 60; background: radial-gradient(circle at 50% 40%, #2a5784, var(--navy2) 75%); align-items: center; justify-content: center; padding: 24px; text-align: center; color: #fff; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) { body.ingame:not(.portraitOk) #rotate { display: flex; } }
.rotbox { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; }
.rotbox h2 { color: var(--gold); -webkit-text-stroke: 1px var(--ink); font-size: 28px; margin: 0; }
.rotbox p { margin: 0; font-size: 16px; line-height: 1.35; }
.rotbox .btn { margin-top: 10px; font-size: 14px; opacity: .85; }
.rotphone { font-size: 70px; animation: rotPhone 2.2s ease-in-out infinite; }
@keyframes rotPhone { 0%, 25% { transform: rotate(0deg); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0deg); } }
.prealpha { display: flex; flex-direction: column; align-items: center; gap: 1px; margin: -4px -6px 2px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 12px; color: var(--ink);
  background: repeating-linear-gradient(-45deg, #f4d03f 0 14px, #f9e79f 14px 28px); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.prealpha b { font-family: 'Luckiest Guy', Impact, sans-serif; font-size: 20px; letter-spacing: 1.5px; font-weight: 400; }
.prealpha span { font-size: 13px; font-weight: 700; line-height: 1.2; background: rgba(255, 247, 227, .85); border-radius: 6px; padding: 1px 6px; }
/* main menu: one column normally; on phones in landscape, title on the left and big buttons on the right */
.tleft, .tright { display: contents; }
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  .panel.title { max-width: 900px; flex-direction: row; align-items: center; gap: 18px; padding: 12px 18px; }
  .tleft, .tright { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
  .tleft { align-items: center; }
  .tleft .prealpha { align-self: stretch; margin: 0; }
  .tright .btn.big { font-size: 20px; padding: 10px 14px; }
  .tright .btn.big small { font-size: 13px; }
  .tright .row .btn { font-size: 15px; padding: 10px 8px; }
  #titleArt { width: 260px; }
}
.prealpha em { font-family: 'Fredoka', sans-serif; font-style: normal; font-size: 12px; font-weight: 700; letter-spacing: 0; background: var(--ink); color: #f9e79f; border-radius: 6px; padding: 0 5px; vertical-align: middle; }
/* installed full-screen app with the camera notch on the left: keep the map clear of it */
#stage { padding-left: env(safe-area-inset-left, 0px); }
#diag { position: fixed; left: 4px; top: 4px; z-index: 40; pointer-events: none; white-space: pre; font: 11px/1.3 ui-monospace, Consolas, monospace; color: #e8f5e9; background: rgba(0,0,0,.8); padding: 4px 7px; border-radius: 6px; }
#gameVer { cursor: pointer; }
