* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #2a1a0f; color: #fff3dc;
  font-family: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans Thai', 'Thonburi', 'Leelawadee UI', 'Hiragino Sans', 'Yu Gothic', 'Noto Sans JP', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', 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; touch-action: none; display: block; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, rgba(40,22,10,.45), rgba(24,12,4,.85));
  animation: fade .25s ease;
}
.overlay.hidden, .hidden { display: none !important; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes wob { 0%, 100% { transform: rotate(-1.5deg) } 50% { transform: rotate(1.5deg) } }

.loader { text-align: center; font-size: 22px; }
.spin { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; border: 7px solid #6b4428; border-top-color: #ffb347; animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg) } }

/* ------------------------------------------------ title */
#title { background: linear-gradient(180deg, rgba(30,15,5,.2), rgba(30,15,5,.75)); gap: 14px; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: .88; animation: wob 4s ease-in-out infinite; filter: drop-shadow(0 8px 0 rgba(40,20,5,.5)); }
.logo .l1 { font-size: 62px; font-weight: 800; letter-spacing: 10px; color: #ffd34d; -webkit-text-stroke: 8px #6b3a00; paint-order: stroke fill; }
.logo .l2 { font-size: 92px; font-weight: 800; -webkit-text-stroke: 10px #2a1405; paint-order: stroke fill; }
.logo .l2 i { font-style: normal; }
.logo .l2 .b { color: #5c9bff; }
.logo .l2 .r { color: #ff5a4a; }
.tagline { margin: 0; font-size: 22px; font-weight: 700; color: #ffe9c8; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.wallet-row { display: flex; gap: 10px; }
.wallet { font-size: 24px; font-weight: 800; background: rgba(60,34,14,.9); border: 3px solid rgba(255,220,170,.25); padding: 4px 18px; border-radius: 30px; }
.wallet b { color: #ffe27a; }
.wallet.small { font-size: 19px; padding: 2px 14px; margin-left: 12px; }
.streak b { color: #ffb36b; }

.menu-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.menu-row.small { margin-top: 12px; }

.btn {
  font: inherit; font-weight: 800; font-size: 21px; color: #fff; border: 0; cursor: pointer;
  padding: 10px 24px 13px; border-radius: 18px; position: relative;
  box-shadow: 0 6px 0 rgba(40,20,5,.55), inset 0 3px 0 rgba(255,255,255,.3), inset 0 -4px 0 rgba(0,0,0,.15);
  transition: transform .08s, filter .15s; text-shadow: 0 2px 0 rgba(0,0,0,.3);
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(40,20,5,.55), inset 0 3px 0 rgba(255,255,255,.3); }
.btn:disabled { filter: grayscale(.9) brightness(.7); cursor: not-allowed; }
.btn.green { background: linear-gradient(#5fd06a, #2a8a38); }
.btn.red { background: linear-gradient(#ff7a55, #c2361c); }
.btn.purple { background: linear-gradient(#b672e6, #6d2f9e); }
.btn.teal { background: linear-gradient(#3ec6c0, #1a7c80); }
.btn.gold { background: linear-gradient(#ffcf4a, #c28400); color: #3a2200; text-shadow: none; }
.btn.wood { background: linear-gradient(#b07a4c, #6e4524); }
.btn.dark { background: linear-gradient(#6a5a4c, #3a2e24); }
.btn.icon { padding: 10px 16px 13px; }
.btn.off { opacity: .45; }
.btn.big { font-size: 40px; padding: 10px 60px 16px; animation: glow 1.6s ease-in-out infinite; }
.btn.big small { display: block; font-size: 17px; font-weight: 700; opacity: .9; margin-top: -4px; }
@keyframes glow { 50% { filter: brightness(1.15); transform: scale(1.03); } }
.btn .badge {
  position: absolute; top: -9px; right: -9px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px;
  background: #ef4444; color: #fff; font-size: 15px; line-height: 26px; box-shadow: 0 2px 0 #7f1d1d;
}

/* ------------------------------------------------ modals */
.modal {
  background: linear-gradient(180deg, #f6e7cf, #e8cfa8); color: #4a2e18;
  border: 5px solid #8a5a34; border-radius: 28px; padding: 22px 34px; min-width: 440px; max-width: 980px;
  text-align: center; box-shadow: 0 10px 0 #5e3b20, 0 30px 80px rgba(0,0,0,.55); animation: pop .25s ease both;
  max-height: 700px; overflow-y: auto; overflow-wrap: break-word;
}
.modal.wide { width: 920px; }
.modal h2 { margin: 0 0 6px; font-size: 40px; line-height: 1.1; color: #6b3a14; }
.modal .sub { margin: 0 0 8px; color: #7a5a3a; font-weight: 700; }
.modal .note { font-size: 14px; max-width: 320px; margin: 12px auto 0; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

.tabs { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 6px 0; }
.tab {
  font: inherit; font-weight: 800; font-size: 19px; color: #7a5a3a; cursor: pointer;
  background: #efdcbc; border: 3px solid #c9a77a; border-radius: 14px; padding: 3px 18px;
}
.tab.on { color: #fff; background: #8a5a34; border-color: #6b4428; }
.modal .wallet { color: #fff3dc; }

.list { display: grid; gap: 8px; margin-top: 10px; text-align: left; max-height: 420px; overflow-y: auto; padding-right: 4px; }
.row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; background: rgba(255,255,255,.5); border: 2px solid #d9bc92; border-radius: 16px; padding: 6px 14px; }
.row.locked { opacity: .5; }
.row .ic { width: 60px; height: 60px; display: grid; place-items: center; font-size: 36px; }
.row .ic img { max-width: 60px; max-height: 60px; }
.row .nm { font-size: 21px; font-weight: 800; color: #4a2e18; }
.row .nm .lv { color: #b0660a; font-size: 17px; margin-left: 8px; }
.row .ds { color: #7a5a3a; font-size: 15px; font-weight: 700; line-height: 1.25; }
.row .btn { font-size: 17px; padding: 6px 14px 9px; min-width: 128px; max-width: 200px; }
.row .btn.sel { background: linear-gradient(#5fd06a, #2a8a38); }
.prog { height: 9px; border-radius: 5px; background: #d9bc92; overflow: hidden; margin-top: 4px; }
.prog i { display: block; height: 100%; background: #e39a1a; }

.col-grid { display: grid; grid-template-columns: 150px repeat(10, 1fr); gap: 4px; margin-top: 4px; align-items: center; }
.col-grid .cn { font-weight: 800; font-size: 15px; line-height: 1.05; text-align: left; overflow-wrap: anywhere; }
.col-grid .cc { height: 48px; border-radius: 10px; background: rgba(90,60,30,.18); display: grid; place-items: center; position: relative; overflow: hidden; }
.col-grid .cc img { max-height: 44px; max-width: 44px; }
.col-grid .cc.off img { filter: brightness(0) opacity(.25); }
.col-grid .cc.got { background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 2px #e3a93a; }
.col-grid .cc span { position: absolute; bottom: 1px; right: 4px; font-size: 12px; font-weight: 800; color: #6b3a14; }
.col-grid .cc em { position: absolute; top: 1px; left: 4px; font-size: 11px; font-style: normal; font-weight: 800; color: #9a5a9a; }
.col-grid .lock { opacity: .35; }

.howto { text-align: left; font-size: 18px; line-height: 1.4; margin: 6px 0; padding-left: 24px; font-weight: 600; }
.howto li { margin: 3px 0; }
#howto .modal { width: 1080px; max-width: 1080px; padding: 16px 30px 18px; }
#howto h2 { font-size: 34px; margin-bottom: 2px; }
#howto .howto { font-size: 17px; line-height: 1.32; }
#howto .counters { font-size: 14px; line-height: 1.25; }
.counters small { white-space: nowrap; }
#howto .actions { margin-top: 8px; }
.counters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px; text-align: left; font-size: 15px; font-weight: 700; margin: 8px 0; }
.keys { color: #7a5a3a; font-size: 15px; font-weight: 700; }
kbd { background: #8a5a34; border-radius: 6px; padding: 0 7px; margin: 0 2px; font-family: inherit; font-weight: 800; color: #fff; }

.stars { font-size: 66px; letter-spacing: 8px; line-height: 1; margin: 2px 0 8px; }
.stars span { display: inline-block; color: #ffc629; text-shadow: 0 5px 0 #9a5a00; animation: pop .4s ease both; }
.stars span.off { color: #d2b894; text-shadow: none; }
.rewards { display: flex; gap: 22px; justify-content: center; font-size: 32px; font-weight: 800; }
.rw { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.55); border-radius: 20px; padding: 2px 18px; }
.rw img { width: 44px; height: 44px; }
.extra { display: grid; gap: 4px; margin-top: 10px; font-size: 17px; font-weight: 700; color: #6b4a2a; }
.extra .good { color: #1f7a3a; }
.extra .gold { color: #b0660a; }
.extra .hint { color: #9a2a1a; }
.win h2 { color: #c27c00; }
.lose h2 { color: #b0301c; }
.pop-icon { font-size: 70px; line-height: 1; }
.pop-icon img { width: 110px; height: 110px; object-fit: contain; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) {
  #rotate {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center;
    background: rgba(255,176,32,.95); color: #2a1a00; font-weight: 800; z-index: 10;
  }
}

.toast {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: linear-gradient(#ffcf4a, #c28400); color: #3a2200; font-weight: 800; font-size: 20px;
  padding: 8px 22px; border-radius: 16px; box-shadow: 0 6px 0 rgba(40,20,5,.45); animation: pop .3s ease both;
  pointer-events: none; max-width: 860px; text-align: center;
}
.toast.low { top: 160px; }
@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .toast, .logo, .btn.big { animation: none !important; }
}

/* ------------------------------------------------ language picker */
.btn.lang-btn { padding: 10px 16px 13px; }
.lang-btn .lang-code { font-size: 16px; letter-spacing: 1px; }
.lang-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 4px; }
.lang-grid .btn { font-size: 20px; padding: 8px 10px 11px; }
.lang-grid .btn.on { background: linear-gradient(#5fd06a, #2a8a38); box-shadow: 0 6px 0 rgba(40,20,5,.55), 0 0 0 4px #ffd34d; }

/* phones: invisible hit-area padding around buttons (the 1280×720 stage is scaled down on small screens) */
@media (pointer: coarse) {
  .btn::after { content: ''; position: absolute; inset: -7px -5px; }
}
