* { box-sizing: border-box; }
:root {
  --ink: #120a07; --lacq: #7a1712; --lacq2: #a3281d; --gold: #c9a227; --gold2: #f3d77a; --cream: #e8dfc8; --jade: #2e4a3f;
  --glass: rgba(18, 10, 7, .9);
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--cream);
  font-family: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans Thai', 'Leelawadee UI',
    'Hiragino Sans', '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; }
.hidden { display: none !important; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.88); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes glow { 50% { filter: brightness(1.18); } }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes spin { to { transform: rotate(360deg) } }

/* lucky seed icon (red melon seed) */
.seed { display: inline-block; width: 13px; height: 18px; border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%; vertical-align: -2px;
  background: radial-gradient(ellipse at 35% 30%, #ff7a6b, #b3140f 55%, #5e0a07); box-shadow: inset 0 0 0 1px rgba(255, 220, 150, .35); transform: rotate(-18deg); }

/* ---------------------------------------------------------------- overlays & panels */
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at center, rgba(30, 8, 6, .6), rgba(8, 4, 3, .92)); animation: fade .22s ease; z-index: 20;
}
.loader { text-align: center; font-size: 22px; color: var(--gold2); }
.spin { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; border: 5px solid rgba(201, 162, 39, .25); border-top-color: var(--gold2); animation: spin 1s linear infinite; }

.modal, .panel {
  background: linear-gradient(160deg, #2a0f0b, #140807 60%, #1c0c09); border: 2px solid var(--gold); border-radius: 22px;
  box-shadow: 0 0 0 5px rgba(18, 10, 7, .9), 0 0 0 7px rgba(201, 162, 39, .35), 0 20px 60px rgba(0, 0, 0, .6);
  padding: 20px 28px; min-width: 440px; max-width: 760px; max-height: 680px; overflow: auto; animation: pop .22s ease; text-align: center; position: relative;
}
.modal.wide { width: 760px; }
.modal.tall { max-height: 690px; }
.panel { width: 1180px; max-width: 1180px; height: 660px; display: flex; flex-direction: column; text-align: left; }
.panel-head { display: flex; align-items: center; gap: 16px; }
.panel-head h2 { flex: 1; }
h2 { margin: 0 0 6px; font-size: 34px; color: var(--gold2); text-shadow: 0 2px 0 #5e0f0b, 0 0 18px rgba(243, 215, 122, .25); line-height: 1.1; }
h3 { margin: 0; color: var(--gold2); }
.sub { margin: 4px 0 8px; font-size: 18px; color: #d9cdb0; line-height: 1.25; }
.sub.small { font-size: 15px; opacity: .85; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 8px auto; width: 340px; }

.btn {
  font: inherit; font-weight: 800; font-size: 19px; color: #fff; border: 0; border-radius: 16px; padding: 10px 22px; cursor: pointer;
  background: linear-gradient(#a3281d, #6d120d); box-shadow: 0 4px 0 #3b0806, inset 0 1px 0 rgba(255, 220, 180, .35), 0 0 0 1.5px rgba(201, 162, 39, .6);
  transition: transform .08s ease, filter .12s; text-shadow: 0 1px 0 rgba(0, 0, 0, .4); line-height: 1.15;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #3b0806, 0 0 0 1.5px rgba(201, 162, 39, .6); }
.btn.gold { background: linear-gradient(#e0b83e, #9c7616); color: #2a1604; text-shadow: 0 1px 0 rgba(255, 240, 200, .5); box-shadow: 0 4px 0 #5c430b, 0 0 0 1.5px #f3d77a; }
.btn.green, .btn.jade { background: linear-gradient(#3f7a5f, #1e4434); box-shadow: 0 4px 0 #0f261c, 0 0 0 1.5px rgba(201, 162, 39, .6); }
.btn.blue { background: linear-gradient(#2d4f7c, #172a45); box-shadow: 0 4px 0 #0b1526, 0 0 0 1.5px rgba(201, 162, 39, .6); }
.btn.purple { background: linear-gradient(#6b3fa0, #3a1f5c); box-shadow: 0 4px 0 #1f0f33, 0 0 0 1.5px rgba(201, 162, 39, .6); }
.btn.dark { background: linear-gradient(#3a2a22, #1a110d); box-shadow: 0 4px 0 #0a0605, 0 0 0 1.5px rgba(201, 162, 39, .45); }
.btn.red { background: linear-gradient(#d23a2a, #8c1c13); }
.btn.icon { padding: 10px 14px; }
.btn[disabled], .btn.locked { filter: grayscale(.8) brightness(.7); cursor: default; }
.badge { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: #d7261e; color: #fff; font-size: 14px; margin-left: 4px; animation: bob 1s infinite; }

/* ---------------------------------------------------------------- menu */
.menu { justify-content: flex-start; padding-top: 22px; gap: 16px; background: linear-gradient(180deg, rgba(12, 5, 4, .6), rgba(12, 5, 4, .15) 40%, rgba(12, 5, 4, .85)); }
.menu-head { width: 1190px; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; flex-direction: column; line-height: .9; transform: rotate(-2deg); }
.logo .l1 { font-size: 76px; font-weight: 800; color: var(--gold2); letter-spacing: 2px;
  text-shadow: 0 3px 0 #7a1712, 0 6px 0 #3b0806, 0 0 28px rgba(243, 215, 122, .45); }
.logo .l2 { font-size: 34px; font-weight: 800; color: #fff; background: linear-gradient(#a3281d, #6d120d); padding: 0 16px; border-radius: 12px;
  align-self: flex-start; margin-left: 40px; box-shadow: 0 0 0 2px var(--gold); transform: rotate(3deg); }
.profile { display: flex; align-items: center; gap: 12px; background: var(--glass); border: 2px solid rgba(201, 162, 39, .6); padding: 10px 16px; border-radius: 20px; }
.pinfo { width: 210px; }
.pname { font-size: 19px; color: var(--gold2); }
.xpbar { position: relative; height: 18px; border-radius: 9px; background: #2a1510; overflow: hidden; margin-top: 3px; border: 1px solid rgba(201, 162, 39, .4); }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #c9a227, #f3d77a); border-radius: 9px; }
.xpbar span { position: relative; font-size: 12px; font-weight: 800; padding-left: 8px; line-height: 17px; color: #2a1604; }
.wallet { font-size: 24px; background: #1c0c09; border: 2px solid rgba(201, 162, 39, .6); padding: 3px 16px; border-radius: 24px; white-space: nowrap; }
.wallet b { color: var(--gold2); }
.wallet.small { font-size: 19px; padding: 2px 14px; }
.streak { font-size: 20px; background: #3b0f06; border: 2px solid rgba(255, 140, 60, .6); padding: 3px 12px; border-radius: 24px; }
.streak b { color: #ffb36b; }
.continue { background: linear-gradient(#e0b83e, #9c7616); color: #2a1604; font-size: 20px; animation: glow 1.6s ease-in-out infinite; text-shadow: none; }
.continue small { display: block; font-size: 14px; font-weight: 700; }
.modes { display: flex; gap: 14px; margin-top: 4px; }
.mode {
  font: inherit; width: 216px; height: 196px; border-radius: 22px; border: 2px solid var(--gold); color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px;
  background: linear-gradient(170deg, rgba(122, 23, 18, .95), rgba(40, 10, 8, .95)); box-shadow: 0 6px 0 #2a0604, 0 10px 30px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 220, 180, .25);
  transition: transform .12s ease, filter .12s; position: relative;
}
.mode:hover { transform: translateY(-4px) rotate(-1deg); filter: brightness(1.12); }
.mode .mi { font-size: 52px; line-height: 1; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .4)); }
.mode b { font-size: 23px; line-height: 1.05; color: var(--gold2); }
.mode small { font-size: 14px; opacity: .9; line-height: 1.15; }
.mode.career { background: linear-gradient(170deg, rgba(20, 16, 12, .96), rgba(60, 20, 10, .95)); }
.mode.daily { background: linear-gradient(170deg, rgba(46, 74, 63, .95), rgba(14, 30, 24, .95)); }
.mode.duo { background: linear-gradient(170deg, rgba(45, 79, 124, .95), rgba(16, 26, 44, .95)); }
.mode.learn { background: linear-gradient(170deg, rgba(107, 63, 160, .95), rgba(34, 18, 56, .95)); }
.mode .ping { position: absolute; top: -8px; right: -8px; background: #d7261e; color: #fff; border-radius: 12px; padding: 0 8px; font-size: 14px; font-weight: 800; animation: bob 1s infinite; }
.menu-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.disclaimer { position: absolute; bottom: 8px; font-size: 13px; opacity: .7; margin: 0; }

/* ---------------------------------------------------------------- choices / lists */
.choice { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.opt { font: inherit; min-width: 180px; padding: 10px 14px; border-radius: 16px; border: 2px solid rgba(201, 162, 39, .45); background: #1c0c09; color: var(--cream); cursor: pointer; }
.opt b { display: block; font-size: 20px; color: var(--gold2); }
.opt small { font-size: 14px; opacity: .85; }
.opt.on { border-color: var(--gold2); background: linear-gradient(#7a1712, #3b0806); box-shadow: 0 0 18px rgba(243, 215, 122, .35); }
.opt.locked { opacity: .5; }
.opt .faces { display: flex; justify-content: center; gap: 2px; margin: 4px 0; }
.opt .faces img, .faces img { width: 44px; height: 44px; object-fit: contain; }
.list { display: flex; flex-direction: column; gap: 10px; text-align: left; margin: 8px 0; }
.row { display: flex; align-items: center; gap: 12px; background: #1c0c09; border: 1.5px solid rgba(201, 162, 39, .35); border-radius: 14px; padding: 10px 14px; }
.row .grow { flex: 1; }
.row .t { font-size: 19px; font-weight: 800; color: var(--gold2); }
.row .d { font-size: 15px; opacity: .88; }
.row.done { border-color: rgba(120, 200, 150, .7); }
.bar { height: 10px; border-radius: 5px; background: #2a1510; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #c9a227, #f3d77a); }

.cities { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; overflow: auto; padding: 6px 4px; }
.city { font: inherit; position: relative; height: 262px; border-radius: 18px; border: 2px solid var(--gold); overflow: hidden; cursor: pointer; color: #fff;
  background: #2a0f0b center/cover no-repeat; text-align: left; padding: 0; transition: transform .12s; }
.city:hover { transform: translateY(-3px); }
.city .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 5, 4, .15), rgba(12, 5, 4, .92) 62%); }
.city .in { position: absolute; left: 12px; right: 12px; bottom: 10px; }
.city .num { position: absolute; top: 8px; left: 10px; background: rgba(18, 10, 7, .85); border: 1px solid var(--gold); border-radius: 10px; padding: 0 8px; font-weight: 800; font-size: 14px; color: var(--gold2); }
.city .stars { position: absolute; top: 6px; right: 10px; font-size: 20px; letter-spacing: 1px; color: var(--gold2); text-shadow: 0 1px 2px #000; }
.city .nm { font-size: 22px; font-weight: 800; color: var(--gold2); line-height: 1.05; }
.city .faces { display: flex; gap: 2px; margin: 4px 0; }
.city .money { font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.city .money b { color: var(--gold2); }
.city.locked { filter: grayscale(.9) brightness(.55); cursor: default; }
.city.locked .lock { position: absolute; inset: 0 0 50% 0; display: grid; place-items: center; font-size: 46px; }

.tabs { display: flex; gap: 8px; margin: 8px 0; }
.tab { font: inherit; font-weight: 800; font-size: 17px; padding: 6px 18px; border-radius: 12px; border: 1.5px solid rgba(201, 162, 39, .5); background: #1c0c09; color: var(--cream); cursor: pointer; }
.tab.on { background: linear-gradient(#a3281d, #6d120d); color: #fff; }
.coll-list { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; overflow: auto; padding: 6px; }
.coll { font: inherit; background: #1c0c09; border: 2px solid rgba(201, 162, 39, .35); border-radius: 16px; padding: 10px; color: var(--cream); cursor: pointer; text-align: center; }
.coll.on { border-color: var(--gold2); box-shadow: 0 0 16px rgba(243, 215, 122, .35); }
.coll img, .coll .sw { width: 100%; height: 150px; object-fit: contain; border-radius: 10px; display: block; margin-bottom: 6px; }
.coll .sw { background: center/cover; }
.coll b { display: block; color: var(--gold2); font-size: 16px; line-height: 1.1; }
.coll small { font-size: 13px; opacity: .85; }
.ach-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; overflow: auto; padding: 6px; }
.ach { display: flex; gap: 10px; align-items: center; background: #1c0c09; border: 1.5px solid rgba(201, 162, 39, .3); border-radius: 14px; padding: 8px 12px; opacity: .55; }
.ach.got { opacity: 1; border-color: var(--gold2); }
.ach .ic { font-size: 30px; }
.ach b { color: var(--gold2); font-size: 16px; }
.ach small { display: block; font-size: 13px; line-height: 1.15; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.stat { background: #1c0c09; border: 1.5px solid rgba(201, 162, 39, .3); border-radius: 14px; padding: 8px; }
.stat b { display: block; font-size: 26px; color: var(--gold2); }
.stat small { font-size: 14px; }
.set-list { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #1c0c09; border-radius: 12px; padding: 8px 14px; border: 1px solid rgba(201, 162, 39, .3); }
.set-row small { display: block; font-size: 13px; opacity: .8; }
.set-h { margin: 8px 0 0; color: var(--gold2); font-size: 18px; }
.tog { font: inherit; font-weight: 800; min-width: 84px; padding: 4px 12px; border-radius: 12px; border: 1.5px solid rgba(201, 162, 39, .5); cursor: pointer; background: #2a1510; color: #aaa; }
.tog.on { background: linear-gradient(#3f7a5f, #1e4434); color: #fff; }
.langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.langs button { font: inherit; font-weight: 700; font-size: 18px; padding: 8px; border-radius: 12px; background: #1c0c09; color: var(--cream); border: 1.5px solid rgba(201, 162, 39, .4); cursor: pointer; }
.langs button.on { background: linear-gradient(#a3281d, #6d120d); color: #fff; border-color: var(--gold2); }
.daily-body { display: flex; flex-direction: column; gap: 8px; align-items: center; font-size: 18px; }

/* rules cheat sheet */
.rules-body { text-align: left; font-size: 17px; line-height: 1.35; }
.rules-body h4 { margin: 12px 0 4px; color: var(--gold2); font-size: 20px; }
.rules-body p { margin: 4px 0; }
.rules-body .ex { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; }
.rules-body .vs { font-weight: 800; color: var(--gold2); padding: 0 4px; }
.mc { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 34px; height: 46px; border-radius: 6px; background: linear-gradient(#fffaf0, #efe2c2);
  color: #1d1512; font-weight: 800; font-size: 15px; line-height: 1; border: 1px solid #8a6d2a; box-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.mc.r { color: #b3261e; }
.mc i { font-style: normal; font-size: 15px; }
.mc.pig { background: linear-gradient(#ffd7df, #f4a6b4); }
.tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
.tbl td { padding: 4px 8px; border-bottom: 1px solid rgba(201, 162, 39, .2); }

/* ---------------------------------------------------------------- results */
.result-table { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.rrow { display: grid; grid-template-columns: 48px 56px 1fr 110px 90px; align-items: center; gap: 8px; background: #1c0c09; border-radius: 14px; padding: 4px 12px; border: 1.5px solid rgba(201, 162, 39, .3); text-align: left; animation: pop .3s ease both; }
.rrow.me { border-color: var(--gold2); background: linear-gradient(90deg, rgba(122, 23, 18, .8), #1c0c09); }
.rrow .medal { font-size: 30px; text-align: center; }
.rrow img { width: 52px; height: 52px; object-fit: contain; }
.rrow .nm { font-size: 19px; font-weight: 800; color: var(--gold2); line-height: 1.05; }
.rrow .nm small { display: block; font-size: 13px; color: var(--cream); font-weight: 600; opacity: .85; }
.rrow .pts { font-size: 24px; font-weight: 800; text-align: right; }
.rrow .tot { font-size: 15px; text-align: right; opacity: .85; }
.pos { color: #7fe0a4; } .neg { color: #ff8a7a; }
.reward { font-size: 20px; margin-top: 6px; line-height: 1.35; }
.reward b { color: var(--gold2); }
.stars-big { font-size: 44px; color: var(--gold2); letter-spacing: 4px; text-shadow: 0 2px 0 #5e0f0b; }
.cover { background: rgba(12, 5, 4, .97); }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.hbtn { position: absolute; left: 14px; top: 12px; width: 52px; height: 52px; border-radius: 16px; font-size: 26px; font-weight: 800; color: var(--gold2); cursor: pointer;
  background: rgba(18, 10, 7, .88); border: 2px solid var(--gold); }
.hud-info { position: absolute; left: 76px; top: 14px; font-size: 17px; font-weight: 700; background: rgba(18, 10, 7, .8); border: 1.5px solid rgba(201, 162, 39, .5); border-radius: 14px; padding: 4px 12px; max-width: 360px; line-height: 1.2; pointer-events: none; }
.hud-info b { color: var(--gold2); }
.hud-seeds { position: absolute; right: 14px; top: 14px; font-size: 21px; background: rgba(18, 10, 7, .88); border: 2px solid rgba(201, 162, 39, .6); border-radius: 20px; padding: 2px 14px; pointer-events: none; }
.hud-seeds b { color: var(--gold2); }
.actions-col { position: absolute; right: 14px; bottom: 14px; width: 176px; display: flex; flex-direction: column; gap: 8px; }
.arow { display: flex; gap: 8px; }
.abtn { font: inherit; font-weight: 800; font-size: 21px; color: #fff; border: 0; border-radius: 16px; padding: 8px 10px; cursor: pointer; line-height: 1.05;
  background: linear-gradient(#3a2a22, #1a110d); box-shadow: 0 4px 0 #0a0605, 0 0 0 1.5px rgba(201, 162, 39, .55); transition: transform .08s, filter .12s; }
.abtn:hover { filter: brightness(1.15); }
.abtn:active { transform: translateY(3px); }
.abtn.play { background: linear-gradient(#d23a2a, #8c1c13); min-height: 72px; font-size: 26px; box-shadow: 0 5px 0 #3b0806, 0 0 0 2px var(--gold2); }
.abtn.play small { display: block; font-size: 14px; font-weight: 700; opacity: .92; }
.abtn.play.ready { animation: glow 1s ease-in-out infinite; }
.abtn.pass { background: linear-gradient(#5b5f66, #2c2f35); }
.abtn.small { flex: 1; font-size: 15px; padding: 7px 4px; }
.abtn[disabled] { filter: grayscale(.9) brightness(.55); cursor: default; animation: none; }
.coach { position: absolute; left: 50%; bottom: 196px; transform: translateX(-58%); max-width: 640px; background: rgba(255, 250, 235, .96); color: #2a1604;
  border: 2px solid var(--gold); border-radius: 16px; padding: 8px 36px 8px 14px; font-size: 17px; font-weight: 700; line-height: 1.25; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); animation: pop .2s ease; pointer-events: auto; }
.coach::after { content: ''; position: absolute; left: 50%; bottom: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: rgba(255, 250, 235, .96); }
.coach b { color: #a3281d; }
.coach-x { position: absolute; right: 6px; top: 6px; border: 0; background: none; font-size: 16px; cursor: pointer; color: #7a1712; }
.lesson-box { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: 640px; background: rgba(18, 10, 7, .94); border: 2px solid var(--gold2); border-radius: 18px; padding: 8px 18px 10px; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .6); }
.lesson-box .lesson-num { font-size: 14px; opacity: .8; }
.lesson-box h3 { font-size: 24px; }
.lesson-box p { margin: 4px 0; font-size: 16px; line-height: 1.3; }
.lesson-goal { color: var(--gold2); font-weight: 800; }
.lesson-fb { color: #ffb3a6; font-weight: 700; min-height: 1em; }
.lesson-fb.ok { color: #9ff0b8; }
.lesson-act { display: flex; justify-content: center; }
.toast { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(18, 10, 7, .94); border: 2px solid var(--gold2); color: var(--cream);
  padding: 8px 20px; border-radius: 16px; font-size: 19px; font-weight: 700; z-index: 40; max-width: 760px; text-align: center; animation: pop .2s ease; pointer-events: none; }

.lesson-mode .toast { top: 250px; }
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) and (pointer: coarse) {
  #rotate { display: flex; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px; justify-content: center; background: rgba(122, 23, 18, .95); color: #fff; font-weight: 800; z-index: 99; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
