/* Garden Guardian — cute cel-shaded UI: chunky navy outlines, two-tone buttons, jewel colours. */
:root { --ink: #2B2D42; --coral: #FF7A59; --sun: #FFD166; --mint: #06D6A0; --sea: #118AB2; --rose: #EF476F; --cream: #FFF8E7; }
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #1f3a24; color: var(--ink);
  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; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(31, 58, 36, .55); animation: fade .2s ease; }
.overlay.hidden, .hidden { display: none !important; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.85) translateY(10px); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes wob { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(1.5deg) } }
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1) } 50% { transform: translateY(-6px) scale(1.03, .98) } }
@keyframes buzz { 0%,100% { transform: translate(0,0) rotate(0) } 25% { transform: translate(3px,-4px) rotate(8deg) } 75% { transform: translate(-3px,2px) rotate(-8deg) } }

#loading { background: radial-gradient(circle at 50% 40%, #9bd36a, #3f7d3a); }
.loader { text-align: center; font-size: 24px; font-weight: 800; background: var(--cream); padding: 22px 40px; border: 5px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); }
.spin { font-size: 56px; animation: buzz .5s ease-in-out infinite; }
.bar { width: 260px; height: 16px; border: 4px solid var(--ink); background: #fff; overflow: hidden; margin-top: 8px; border-radius: 10px; }
.bar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .2s; }

/* ---------------- menu (the attract-mode demo plays behind it) */
#menu { display: block; background: linear-gradient(90deg, rgba(255,248,231,.92) 0%, rgba(255,248,231,.8) 38%, rgba(255,248,231,0) 60%); }
.menu-left { position: absolute; left: 40px; top: 20px; width: 600px; }
.menu-right { position: absolute; right: 26px; top: 20px; width: 440px; display: flex; flex-direction: column; gap: 12px; }
.logo { display: flex; flex-direction: column; line-height: .85; margin-bottom: 8px; transform-origin: left center; animation: wob 4s ease-in-out infinite; }
.logo .l1, .logo .l2 { white-space: nowrap; align-self: flex-start; font-weight: 900; letter-spacing: 2px; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); }
.logo .l1 { font-size: 84px; color: var(--mint); }
.logo .l2 { font-size: 100px; color: var(--sun); margin-left: 24px; }
.logo .l3 { align-self: flex-start; margin-top: 12px; font-size: 22px; font-weight: 800; background: var(--rose); color: #fff; border: 4px solid var(--ink); padding: 2px 16px; border-radius: 20px; transform: rotate(-2deg); }
.playbox { display: flex; gap: 14px; align-items: stretch; margin-top: 16px; }
.sidebtns { display: flex; flex-direction: column; gap: 10px; }
.daily { display: flex; flex-direction: column; justify-content: center; line-height: 1.05; text-align: left; max-width: 280px; }
.daily b { font-size: 20px; }
.daily small { font-size: 13px; font-weight: 700; opacity: .95; }
#btn-continue { font-size: 18px; padding: 6px 14px 8px; }
.zones { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 800; font-size: 17px; flex-wrap: wrap; }
.zlist { display: flex; gap: 6px; flex-wrap: wrap; }
.zchip { font: inherit; font-size: 15px; font-weight: 800; border: 3px solid var(--ink); border-radius: 14px; padding: 2px 12px; background: #fff; cursor: pointer; color: var(--ink); }
.zchip.on { background: var(--mint); color: #fff; -webkit-text-stroke: .5px var(--ink); }
.zchip:disabled { opacity: .45; cursor: not-allowed; }
.bestline { margin-top: 12px; font-size: 20px; font-weight: 800; }
.goal { margin-top: 8px; display: inline-block; font-size: 16px; font-weight: 800; background: #fff; border: 3px solid var(--ink); padding: 4px 14px; border-radius: 14px; max-width: 560px; }
.menu-nav { position: absolute; left: 40px; bottom: 22px; display: flex; gap: 10px; flex-wrap: wrap; max-width: 1200px; }

.card { background: var(--cream); border: 5px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink); padding: 10px 14px; }
.beebox { position: relative; padding: 0; overflow: hidden; cursor: pointer; background: radial-gradient(circle at 50% 60%, #bfe89b, #6fb35a); }
.beebox canvas { display: block; width: 100%; height: auto; }
.bname { position: absolute; left: 14px; bottom: 8px; font-size: 26px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); }
.bhoney { position: absolute; right: 12px; top: 10px; font-size: 22px; font-weight: 900; color: var(--ink); background: var(--sun); border: 3px solid var(--ink); border-radius: 20px; padding: 0 14px; }
.mcard { padding: 8px 14px 10px; }
.mhead { display: flex; justify-content: space-between; font-size: 18px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
.streak { color: var(--rose); font-size: 16px; text-transform: none; letter-spacing: 0; }
.mmini { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.mm { font-size: 15px; font-weight: 700; line-height: 1.1; display: flex; gap: 8px; align-items: center; }
.mm .t { flex: 1; }
.mm .pb { width: 90px; height: 12px; border: 3px solid var(--ink); background: #fff; flex: none; border-radius: 8px; overflow: hidden; }
.mm .pb i { display: block; height: 100%; background: var(--mint); }

.btn { font: inherit; font-weight: 900; font-size: 20px; color: var(--ink); border: 4px solid var(--ink); cursor: pointer; padding: 6px 18px 8px; border-radius: 16px; position: relative;
  box-shadow: 0 5px 0 var(--ink), inset 0 -5px 0 rgba(0,0,0,.14); transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 7px 0 var(--ink), inset 0 -5px 0 rgba(0,0,0,.14); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink), inset 0 -3px 0 rgba(0,0,0,.14); }
.btn:disabled { filter: grayscale(1); opacity: .6; cursor: not-allowed; }
.btn.big { font-size: 46px; padding: 4px 44px 10px; letter-spacing: 2px; }
.btn.yellow { background: var(--sun); }
#btn-play { animation: bounce 1.3s ease-in-out infinite; }
.btn.blue { background: var(--sea); color: #fff; }
.btn.white { background: #fff; }
.btn.green { background: var(--mint); color: #fff; -webkit-text-stroke: .6px var(--ink); }
.btn.rose { background: var(--rose); color: #fff; }

.modal { background: var(--cream); border: 5px solid var(--ink); border-radius: 26px; padding: 18px 28px; min-width: 440px; max-width: 900px; max-height: 690px; text-align: center; box-shadow: 0 12px 0 var(--ink); animation: pop .22s ease both; display: flex; flex-direction: column; }
.modal.wide { width: 860px; }
.modal.xwide { width: 1140px; max-width: 1140px; }
.modal h2 { margin: 0 0 8px; font-size: 42px; line-height: 1; color: var(--sun); -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); letter-spacing: 1px; }
.sub { margin: 0 0 8px; color: #4a4c63; font-size: 16px; font-weight: 700; }
.actions { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 14px; }
.coins { font-size: 24px; font-weight: 900; margin-right: auto; } .coins b { color: #c07a00; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 280px; margin: 8px auto; }

.hivebox { display: flex; gap: 18px; text-align: left; min-height: 0; }
.hprev { width: 360px; flex: none; display: flex; flex-direction: column; gap: 6px; }
.hprev canvas { width: 100%; height: auto; display: block; border: 4px solid var(--ink); border-radius: 18px; background: radial-gradient(circle at 50% 60%, #bfe89b, #6fb35a); }
.hname { font-size: 28px; font-weight: 900; line-height: 1; }
.hdesc { font-size: 16px; font-weight: 700; color: #4a4c63; min-height: 44px; line-height: 1.2; }
.hgrid { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-content: start; max-height: 520px; overflow-y: auto; padding: 4px 8px 8px 4px; }
.hitem { background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 6px; cursor: pointer; text-align: center; font: inherit; position: relative; box-shadow: 0 4px 0 var(--ink); transition: transform .1s; }
.hitem:hover { transform: translateY(-2px) rotate(-1deg); }
.hitem.on { background: var(--sun); }
.hitem canvas { width: 100%; height: auto; display: block; }
.hitem .tn { font-size: 15px; font-weight: 900; line-height: 1.05; min-height: 32px; overflow-wrap: anywhere; display: flex; align-items: center; justify-content: center; }
.hitem .tc { font-size: 15px; font-weight: 900; color: #c07a00; }
.hitem.locked canvas { filter: brightness(0) opacity(.5); }
.hitem .sel { position: absolute; top: -10px; right: -8px; background: var(--rose); color: #fff; border: 3px solid var(--ink); border-radius: 12px; font-size: 12px; padding: 0 7px; font-weight: 900; }

.list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.qrow { display: flex; align-items: center; gap: 12px; background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 8px 12px; }
.qrow .ic { font-size: 30px; width: 44px; text-align: center; flex: none; }
.qrow .qt { flex: 1; font-weight: 800; font-size: 17px; line-height: 1.15; }
.qrow .qt small { display: block; font-weight: 700; font-size: 14px; color: #666; }
.qrow .qp { width: 170px; flex: none; }
.pips { display: flex; gap: 4px; }
.pips i { width: 26px; height: 14px; border: 3px solid var(--ink); background: #fff; border-radius: 6px; }
.pips i.on { background: var(--sun); }
.qrow .pb { height: 16px; border: 3px solid var(--ink); background: #fff; border-radius: 8px; overflow: hidden; }
.qrow .pb i { display: block; height: 100%; background: var(--mint); }
.qrow .qp small { display: block; font-size: 13px; font-weight: 800; text-align: center; }
.qrow .qr { width: 80px; text-align: right; font-weight: 900; color: #c07a00; font-size: 18px; flex: none; }
.qrow .btn { font-size: 16px; padding: 3px 12px 5px; min-width: 110px; }

.table { border-collapse: separate; border-spacing: 0 4px; font-size: 20px; font-weight: 800; margin: 4px auto; min-width: 420px; }
.table td { padding: 2px 14px; background: #fff; border-top: 3px solid var(--ink); border-bottom: 3px solid var(--ink); }
.table td:first-child { border-left: 3px solid var(--ink); border-radius: 12px 0 0 12px; color: #c07a00; }
.table td:last-child { border-right: 3px solid var(--ink); border-radius: 0 12px 12px 0; }
.table tr.me td { background: var(--sun); }
.table .sc { text-align: right; font-variant-numeric: tabular-nums; }
.table .st { font-size: 14px; color: #666; }

.letters { display: flex; gap: 14px; justify-content: center; margin: 6px 0; }
.letter { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.letter b { font-size: 60px; width: 80px; line-height: 1.1; background: #fff; border: 4px solid var(--ink); border-radius: 16px; }
.letter.on b { background: var(--sun); }
.letter button { font: inherit; font-size: 20px; font-weight: 900; width: 60px; border: 3px solid var(--ink); border-radius: 12px; background: var(--mint); color: #fff; cursor: pointer; }
.bigscore { font-size: 30px; font-weight: 900; margin: 4px; }

.howto { text-align: left; font-size: 17px; margin: 4px 0; padding-left: 26px; line-height: 1.3; font-weight: 600; }
.hitems { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; text-align: left; margin: 8px 0; }
.hbug { display: flex; gap: 6px; align-items: center; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 6px; font-size: 12.5px; line-height: 1.1; font-weight: 600; }
.hbug canvas { width: 48px; height: 48px; flex: none; }
.hbug b { display: block; font-size: 14px; }
.keys { margin: 4px 0; color: #4a4c63; 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 var(--ink); }
.toggle { min-width: 120px; font-size: 17px; }

.result .rtitle { display: flex; justify-content: center; }
.result h2 { font-size: 64px; color: var(--rose); transform: rotate(-2deg); }
.quip { font-size: 19px; font-style: italic; }
.rbody { display: flex; gap: 20px; align-items: stretch; text-align: left; }
.rstats { width: 440px; flex: none; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; font-size: 20px; font-weight: 800; align-content: start; background: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 10px 16px; }
.rstats .v { text-align: right; }
.rstats .big { font-size: 30px; color: var(--rose); }
.rstats .nb { display: inline-block; background: var(--sun); border: 3px solid var(--ink); border-radius: 10px; font-size: 13px; padding: 0 6px; margin-left: 6px; transform: rotate(-4deg); animation: pop .3s ease both; }
.rright { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rewards { background: var(--sea); color: #fff; border: 4px solid var(--ink); border-radius: 16px; padding: 10px 16px; font-size: 18px; font-weight: 800; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.rewards .tot { font-size: 30px; color: var(--sun); -webkit-text-stroke: 1px var(--ink); }
.rextra { display: flex; flex-direction: column; gap: 5px; font-size: 16px; font-weight: 800; max-height: 190px; overflow-y: auto; }
.rextra .ms { background: var(--mint); color: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 3px 10px; animation: pop .3s ease both; -webkit-text-stroke: .4px var(--ink); }
.rextra .nx { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 3px 10px; }

.toast { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: var(--cream); border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink); padding: 8px 22px; border-radius: 18px; font-size: 20px; font-weight: 900; z-index: 20; animation: pop .2s ease; max-width: 900px; text-align: center; pointer-events: none; }
.pausebtn { position: absolute; top: 90px; right: 16px; width: 54px; height: 54px; border-radius: 16px; border: 4px solid var(--ink); background: var(--cream); color: var(--ink); font-size: 18px; font-weight: 900; cursor: pointer; z-index: 5; box-shadow: 0 4px 0 var(--ink); opacity: .85; }
#rotate { display: none; position: fixed; inset: 0; background: var(--sun); color: var(--ink); 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, .spin { animation: none; } }
/* phones: the 1280×720 stage is scaled ~0.55×, so give the menu buttons finger-sized heights (≈44 real px) */
@media (pointer: coarse) {
  .menu-nav .btn { min-height: 80px; }
}
@media (pointer: coarse) { .zchip { min-height: 58px; padding: 4px 14px; } }
@media (pointer: coarse) { .pausebtn { width: 80px; height: 80px; font-size: 24px; } }
