* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #2b1a10; color: #3d2314;
  font-family: 'Baloo 2', 'Nunito', system-ui, 'Noto Sans', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; display: block; touch-action: none; }

.hidden { display: none !important; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(43,26,16,.55); animation: fade .2s ease; z-index: 10; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.85) rotate(-1.5deg); opacity: 0 } to { transform: scale(1) rotate(0); opacity: 1 } }
@keyframes wob { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(1deg) } }
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1, 1) } 45% { transform: translateY(-5px) scale(.98, 1.03) } 55% { transform: translateY(-5px) scale(.98, 1.03) } }
@keyframes squish { 0% { transform: scale(1.25, .75) } 60% { transform: scale(.92, 1.08) } 100% { transform: scale(1) } }

#loading { background: #f6e3c8 url(assets/bg_market.webp) center/cover; }
.loader { text-align: center; font-size: 24px; font-weight: 800; background: #fff8ee; padding: 22px 40px; border: 5px solid #fff; outline: 4px solid #8a5a3c; border-radius: 28px; box-shadow: 0 10px 0 rgba(61,35,20,.4); }
.spin { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; border: 8px dotted #e63946; animation: rot 1.2s linear infinite; }
.bar { width: 260px; height: 16px; border-radius: 10px; background: #ead2b3; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, #e63946 0 10px, #fff 10px 20px); transition: width .2s; }
@keyframes rot { to { transform: rotate(360deg) } }

/* ---------------------------------------------------------------- map */
#map { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#map > * { pointer-events: auto; }
.logo { position: absolute; left: 28px; top: 14px; display: flex; flex-direction: column; line-height: .85; transform-origin: left center; animation: wob 4s ease-in-out infinite; pointer-events: none !important; }
.logo .l1, .logo .l2 { font-weight: 900; letter-spacing: 1px; -webkit-text-stroke: 3px #3d2314; paint-order: stroke fill; text-shadow: 0 6px 0 #3d2314; }
.logo .l1 { font-size: 42px; color: #fff; }
.logo .l2 { font-size: 66px; color: #ffb703; }
.logo .l3 { align-self: flex-start; margin-top: 8px; font-size: 18px; font-weight: 800; background: #fff8ee; border-radius: 14px; padding: 1px 12px; color: #8a5a3c; transform: rotate(-2deg); box-shadow: 0 3px 0 rgba(61,35,20,.35); }
.topstats { position: absolute; right: 20px; top: 16px; display: flex; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(61,35,20,.8); color: #fff; font-weight: 900; font-size: 22px; padding: 3px 14px 3px 8px; border-radius: 22px; border: 2px solid rgba(255,255,255,.4); }
.chip.streak { color: #ffd166; font-size: 17px; padding-left: 12px; }
.gd, .gc { display: inline-block; width: 26px; height: 26px; border-radius: 50% 50% 40% 40%; background: radial-gradient(circle at 35% 30%, #ff9aa2, #e63946 60%, #9d0208); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
.gc { border-radius: 4px; background: radial-gradient(circle at 35% 30%, #fff3b0, #f4c430 55%, #b8860b); clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 78%, 20% 100%, 30% 60%, 0 38%, 38% 35%); }
.mnav { position: absolute; right: 20px; top: 70px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 760px; }
.card { position: absolute; left: 258px; bottom: 18px; width: 800px; display: flex; align-items: center; gap: 16px; background: #fff8ee; border: 5px solid #fff; outline: 4px solid #8a5a3c; border-radius: 26px; padding: 10px 14px 10px 22px; box-shadow: 0 8px 0 rgba(61,35,20,.45); }
.cinfo { flex: 1; min-width: 0; }
.ctitle { font-size: 28px; font-weight: 900; line-height: 1.05; color: #3d2314; }
.csub { font-size: 17px; font-weight: 800; color: #8a5a3c; line-height: 1.15; }
.cline { font-size: 16px; font-weight: 700; color: #5c3d2e; margin-top: 3px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.cline .cuts { display: inline-flex; gap: 3px; } .cline .cuts i { width: 20px; height: 20px; opacity: .25; } .cline .cuts i.on { opacity: 1; }
.cline .ok { color: #2a9d8f; font-weight: 900; }
.btn.daily { position: absolute; left: 18px; bottom: 30px; display: flex; flex-direction: column; line-height: 1.05; text-align: left; width: 218px; font-size: 18px; }
.daily b { font-size: 19px; -webkit-text-stroke: 0; text-shadow: 0 2px 0 #145a52; } .daily small { font-size: 13px; font-weight: 800; -webkit-text-stroke: 0; color: #eafff9; margin-top: 2px; }

/* ---------------------------------------------------------------- buttons */
.btn { font: inherit; font-weight: 900; font-size: 20px; color: #3d2314; border: 4px solid #fff; cursor: pointer; padding: 5px 18px 7px; border-radius: 22px; position: relative;
  box-shadow: 0 5px 0 rgba(61,35,20,.45), 0 0 0 3px #8a5a3c; transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:hover { transform: translateY(-2px) rotate(-1deg); filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(61,35,20,.45), 0 0 0 3px #8a5a3c; animation: squish .25s ease; }
.btn:disabled { filter: grayscale(1); opacity: .6; cursor: not-allowed; }
.btn.big { font-size: 36px; padding: 4px 34px 8px; letter-spacing: 1px; }
.btn.red { background: linear-gradient(#ff6b6b, #e63946); color: #fff; -webkit-text-stroke: 1px #7a1c1c; }
#btn-play { animation: bounce 1.2s ease-in-out infinite; }
.btn.mint { background: linear-gradient(#7ee0c3, #2a9d8f); color: #fff; -webkit-text-stroke: .8px #145a52; }
.btn.cream { background: #fff1dc; }
.btn.green { background: linear-gradient(#8ee07e, #43aa3b); color: #fff; -webkit-text-stroke: .8px #1f5e1a; }
.badge { position: absolute; top: -10px; right: -8px; background: #e63946; color: #fff; border-radius: 12px; padding: 0 8px; font-size: 14px; border: 2px solid #fff; }

/* ---------------------------------------------------------------- modals */
.modal { background: #fff8ee; border: 6px solid #fff; outline: 5px solid #8a5a3c; border-radius: 30px; padding: 16px 28px 18px; min-width: 440px; max-width: 1000px; max-height: 680px; text-align: center; box-shadow: 0 12px 0 rgba(61,35,20,.45); animation: pop .22s ease both; display: flex; flex-direction: column; }
.modal.wide { width: 880px; } .modal.xwide { width: 1080px; max-width: 1080px; }
.modal h2 { margin: 0 0 6px; font-size: 42px; line-height: 1.05; color: #ffb703; -webkit-text-stroke: 2.5px #3d2314; paint-order: stroke fill; text-shadow: 0 4px 0 #3d2314; }
.sub { margin: 0 0 8px; color: #8a5a3c; font-size: 16px; font-weight: 700; }
.actions { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 14px; }
.coins { font-size: 22px; font-weight: 900; margin-right: auto; display: inline-flex; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 280px; margin: 8px auto; }

.colors { display: flex; gap: 18px; text-align: left; min-height: 0; }
.cprev { width: 300px; flex: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.cprev canvas { width: 280px; height: 280px; border-radius: 24px; background: radial-gradient(circle, #fff3d6, #f1c89b); }
.cname { font-size: 26px; font-weight: 900; text-align: center; }
.cgrid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-content: start; max-height: 470px; overflow-y: auto; padding: 6px; }
.citem { background: #fff; border: 3px solid #ead2b3; border-radius: 18px; padding: 6px; cursor: pointer; text-align: center; font: inherit; position: relative; transition: transform .1s; }
.citem:hover { transform: translateY(-2px) rotate(-1deg); }
.citem.on { border-color: #e63946; background: #fff1f1; }
.citem .sw { width: 54px; height: 54px; margin: 0 auto 4px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #8a5a3c; }
.citem .cn { font-size: 14px; font-weight: 900; line-height: 1.05; min-height: 30px; display: flex; align-items: center; justify-content: center; overflow-wrap: anywhere; }
.citem .cc { font-size: 13px; font-weight: 800; color: #8a5a3c; display: flex; align-items: center; justify-content: center; gap: 3px; }
.citem .cc i { width: 15px; height: 15px; }
.citem.locked .sw { filter: grayscale(.35) brightness(.92); }
.citem .tick { position: absolute; top: -8px; right: -6px; background: #43aa3b; color: #fff; border-radius: 12px; font-size: 12px; padding: 0 7px; font-weight: 900; border: 2px solid #fff; }

.list { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.qrow { display: flex; align-items: center; gap: 12px; background: #fff; border: 3px solid #ead2b3; border-radius: 18px; padding: 8px 14px; }
.qrow .qt { flex: 1; font-weight: 800; font-size: 18px; line-height: 1.15; }
.qrow .pb { width: 190px; height: 16px; border-radius: 10px; background: #ead2b3; overflow: hidden; flex: none; }
.qrow .pb i { display: block; height: 100%; background: repeating-linear-gradient(45deg, #43aa3b 0 10px, #6fd566 10px 20px); }
.qrow .qn { width: 70px; text-align: center; font-weight: 900; font-size: 15px; color: #8a5a3c; flex: none; }
.qrow .btn { font-size: 16px; padding: 3px 12px 5px; min-width: 120px; }

.howto { text-align: left; font-size: 17px; margin: 4px 0; padding-left: 26px; line-height: 1.3; font-weight: 600; }
.powers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; text-align: left; }
.pw { display: flex; gap: 8px; align-items: center; background: #fff; border: 3px solid #ead2b3; border-radius: 16px; padding: 6px 8px; font-size: 13px; line-height: 1.15; font-weight: 600; }
.pw canvas { width: 56px; height: 56px; flex: none; }
.pw b { display: block; font-size: 15px; }
.keys { margin: 4px 0; color: #5c3d2e; font-size: 15px; font-weight: 700; }

.setrow { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin: 6px 0; font-size: 20px; font-weight: 800; }
.setrow select { font: inherit; font-size: 17px; padding: 4px 10px; border-radius: 12px; background: #fff; border: 3px solid #8a5a3c; }
.toggle { min-width: 120px; font-size: 17px; }

.result h2 { font-size: 60px; transform: rotate(-2deg); animation: squish .5s ease; }
.quip { font-size: 19px; font-style: italic; }
.rbody { display: flex; gap: 18px; align-items: stretch; text-align: left; }
.rstats { width: 430px; flex: none; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; font-size: 21px; font-weight: 800; align-content: start; background: #fff; border: 3px solid #ead2b3; border-radius: 18px; padding: 12px 18px; }
.rstats .v { text-align: right; display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
.rstats .v i.gc { width: 24px; height: 24px; opacity: .22; } .rstats .v i.gc.on { opacity: 1; animation: squish .4s ease both; }
.nb { display: inline-block; background: #ffd166; border-radius: 10px; font-size: 13px; padding: 0 8px; margin-left: 6px; transform: rotate(-4deg); animation: pop .3s ease both; }
.rright { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 16px; font-weight: 800; max-height: 250px; overflow-y: auto; }
.rright .ms { background: #43aa3b; color: #fff; border-radius: 14px; padding: 4px 12px; animation: pop .3s ease both; }
.rright .nx { background: #fff; border: 3px solid #ead2b3; border-radius: 14px; padding: 4px 12px; }
.rright .gold { background: #ffd166; border-radius: 14px; padding: 4px 12px; }

.toast { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); background: #fff8ee; border: 4px solid #fff; outline: 3px solid #8a5a3c; box-shadow: 0 6px 0 rgba(61,35,20,.4); padding: 8px 22px; border-radius: 22px; font-size: 20px; font-weight: 900; z-index: 30; animation: pop .2s ease; max-width: 900px; text-align: center; pointer-events: none; }
.pausebtn { position: absolute; top: 14px; right: 16px; width: 54px; height: 54px; border-radius: 18px; border: 4px solid #fff; background: rgba(61,35,20,.75); color: #fff; font-size: 18px; font-weight: 900; cursor: pointer; z-index: 6; }
#rotate { display: none; position: fixed; inset: 0; background: #fff1dc; color: #3d2314; font-size: 26px; font-weight: 900; align-items: center; justify-content: center; text-align: center; padding: 30px; z-index: 50; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) { #rotate { display: flex; } }
@media (prefers-reduced-motion: reduce) { .logo, #btn-play, .result h2 { animation: none; } }
