/* 셈셈 팡 화면 — 보라·노랑 숫자 블록 */
:root {
  --purple: #7b4dff; --purple-d: #5a2fd6; --purple-dd: #3d1ea6; --purple-soft: #ece4ff; --lav: #f6f1ff;
  --yellow: #ffd93b; --yellow-d: #e0a800; --yellow-soft: #fff4c2;
  --ink: #36265f; --ink2: #8676ad; --ok: #1fae7a; --ok-soft: #dcfaee; --warn: #ef3f68; --warn-soft: #ffe1e8;
  --paper: #fffdf8;
}
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #141a33; overflow: hidden; position: fixed;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: rgba(0,0,0,0);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; touch-action: manipulation; }
button { font-family: inherit; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
button:focus { outline: 4px solid var(--purple); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
svg text { font-family: inherit; }
.hidden { display: none !important; }

/* ===== 바탕 ===== */
#app {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden;
  background-color: var(--lav);
  background-image: radial-gradient(rgba(123,77,255,0.13) 13%, transparent 14%), radial-gradient(rgba(255,217,59,0.32) 13%, transparent 14%), linear-gradient(180deg, #f3edff 0%, #fbf6ff 55%, #fff7d8 100%);
  background-size: 44px 44px, 44px 44px, 100% 100%;
  background-position: 0 0, 22px 22px, 0 0;
}
.ql #app { background-image: linear-gradient(180deg, #f3edff 0%, #fbf6ff 55%, #fff7d8 100%); background-size: 100% 100%; }
.screen {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}

/* ===== 공통 단추 ===== */
.ibtn {
  min-width: 56px; height: 56px; border: 0; border-radius: 18px; background: #fff; font-size: 26px; line-height: 1;
  box-shadow: 0 4px 0 #d9ccf5, 0 6px 14px rgba(90,47,214,0.16); padding: 0 10px;
  display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; -webkit-flex-shrink: 0; flex-shrink: 0;
}
.ibtn:active, .bigbtn:active, .lv:active, .modebtn:active { -webkit-transform: scale(0.94); transform: scale(0.94); }
.ibtn[disabled] { opacity: 0.4; cursor: default; }
.bigbtn {
  min-height: 60px; border: 0; border-radius: 22px; padding: 10px 22px; font-size: 21px; font-weight: 900;
  background: var(--purple); color: #fff; box-shadow: 0 5px 0 var(--purple-dd), 0 8px 18px rgba(90,47,214,0.25);
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; margin: 6px;
}
.bigbtn.yellow { background: var(--yellow); color: #5a3d00; box-shadow: 0 5px 0 var(--yellow-d), 0 8px 18px rgba(224,168,0,0.25); }
.bigbtn.plain { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #ddd2f2, 0 8px 18px rgba(90,47,214,0.12); }
.bigbtn.ok { background: var(--ok); color: #fff; box-shadow: 0 5px 0 #13805a, 0 8px 18px rgba(31,174,122,0.25); }
.bigbtn[disabled] { opacity: 0.45; cursor: default; }
.coinpill {
  display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; height: 56px; padding: 0 14px 0 10px;
  background: var(--yellow-soft); border-radius: 18px; font-weight: 900; font-size: 21px; color: #6b4d00; box-shadow: 0 4px 0 #f0d26a; white-space: nowrap; -webkit-flex-shrink: 0; flex-shrink: 0;
}
.coinpill .ci { font-size: 24px; margin-right: 5px; }
.ql .ibtn, .ql .bigbtn, .ql .coinpill { box-shadow: none; border: 2px solid #d9ccf5; }

/* ===== 지도 ===== */
#map { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mapwrap { max-width: 920px; margin: 0 auto; padding: 12px 16px 40px; }
.topbar { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.topbar > * { margin-right: 8px; }
.topbar > *:last-child { margin-right: 0; }
.grow { -webkit-flex: 1; flex: 1; min-width: 0; }
.gametitle { font-size: 34px; font-weight: 900; letter-spacing: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gametitle .t1 { color: var(--purple-d); }
.gametitle .t2 { color: #e8a200; text-shadow: 0 2px 0 #fff3b0; }
.tblk { display: inline-block; vertical-align: 4px; margin-left: 4px; }
.tblk i {
  display: inline-block; font-style: normal; width: 28px; height: 28px; line-height: 28px; text-align: center; font-size: 18px; letter-spacing: 0;
  border-radius: 8px; background: var(--yellow); color: var(--purple-d); margin-right: 3px; box-shadow: inset 0 -3px 0 var(--yellow-d);
}
.tblk i:nth-child(2) { background: transparent; box-shadow: none; color: var(--purple); width: 16px; }
.tagline { margin: 10px 4px 6px; font-size: 18px; color: var(--ink2); font-weight: 800; }
.banner { margin: 10px 0; padding: 12px 16px; border-radius: 18px; background: var(--warn-soft); color: #a2183f; font-weight: 800; font-size: 17px; }
.chapter {
  margin: 16px 0; padding: 14px 14px 10px; border-radius: 28px; background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 22px rgba(90,47,214,0.12); border: 3px solid var(--chc, #e6dcff);
}
.ql .chapter { box-shadow: none; }
.chapter.locked { opacity: 0.72; }
.chhead { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin: 0 4px 8px; }
.chicon { font-size: 34px; width: 56px; height: 56px; border-radius: 18px; background: var(--chc, #e6dcff); display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; margin-right: 12px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.chname { font-size: 22px; font-weight: 900; }
.chname small { display: block; font-size: 15px; font-weight: 800; color: var(--ink2); margin-top: 2px; }
.lvgrid { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.lvcell { width: 12.5%; padding: 4px; }
.lv {
  width: 100%; min-height: 76px; border: 0; border-radius: 20px; background: #fff; padding: 6px 2px;
  box-shadow: 0 4px 0 var(--chd, #cbbcf2); font-size: 26px; font-weight: 900; line-height: 1.1; color: var(--ink);
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; position: relative;
}
.lv small { display: block; font-size: 13px; font-weight: 800; color: var(--ink2); margin-top: 4px; white-space: nowrap; }
.lv.done { background: var(--chc, #e6dcff); }
.lv.done small { color: var(--ink); }
.lv.locked { background: #eeeaf4; color: #b3a9c6; box-shadow: 0 4px 0 #ddd6e8; cursor: default; }
.lv.next { background: var(--yellow); color: var(--purple-d); box-shadow: 0 4px 0 var(--yellow-d); }
.lv.next small { color: var(--purple-d); }
.qh .lv.next { -webkit-animation: bob 1.4s ease-in-out infinite; animation: bob 1.4s ease-in-out infinite; }
@-webkit-keyframes bob { 0%,100% { -webkit-transform: translateY(0); } 50% { -webkit-transform: translateY(-4px); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.modes { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 8px -6px 0; }
.modecell { width: 50%; padding: 6px; }
.modebtn {
  width: 100%; min-height: 128px; border: 0; border-radius: 28px; padding: 16px; text-align: left; position: relative; color: var(--ink);
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; display: block;
}
.modebtn.daily { background: linear-gradient(135deg, #fff0a8, #ffd0e6); box-shadow: 0 6px 0 #e6b7c9, 0 10px 24px rgba(224,88,143,0.18); }
.modebtn.endless { background: linear-gradient(135deg, #d9ccff, #c4e8ff); box-shadow: 0 6px 0 #a99be0, 0 10px 24px rgba(90,47,214,0.2); }
.ql .modebtn { box-shadow: none; }
.modebtn.locked { background: #eeeaf4; box-shadow: 0 6px 0 #ddd6e8; color: #9a90ad; cursor: default; }
.modebtn .mt { font-size: 25px; font-weight: 900; }
.modebtn .ms { font-size: 16px; font-weight: 800; margin-top: 6px; opacity: 0.9; }
.modebtn .mi { position: absolute; right: 14px; top: 12px; font-size: 40px; }
.dots { margin-top: 10px; line-height: 0; padding-left: 3px; }
.dots i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.8); margin: 0 2px 4px 0; }
.dots i.on { background: var(--purple); }
.dots i.today { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--yellow-d); }

/* ===== 게임 화면 ===== */
#game { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; }
.hud { padding: 8px 12px 0; -webkit-flex-shrink: 0; flex-shrink: 0; }
.ttl { text-align: center; line-height: 1.05; min-width: 0; }
.ttl b { display: block; font-size: 26px; font-weight: 900; color: var(--purple-d); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl small { display: block; font-size: 15px; font-weight: 800; color: var(--ink2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; margin-top: 6px; }
.stat {
  display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center;
  background: #fff; border-radius: 16px; padding: 4px 12px; margin: 3px; font-weight: 900; min-height: 48px; white-space: nowrap;
  box-shadow: 0 3px 0 #ddd2f2;
}
.ql .stat { box-shadow: none; border: 2px solid #ddd2f2; }
.stat .k { font-size: 14px; color: var(--ink2); margin-right: 6px; font-weight: 800; }
.stat .v { font-size: 26px; }
.stat.left { background: var(--purple-soft); box-shadow: 0 3px 0 #c6b5f5; }
.stat.left .v { color: var(--purple-d); }
.stat.left.low { background: var(--warn-soft); box-shadow: 0 3px 0 #ffadbd; }
.stat.left.low .v { color: var(--warn); }
.stat.left.low .k::before { content: '⚠ '; color: var(--warn); }
.qh .stat.left.low, .qm .stat.left.low { -webkit-animation: lowBlink 0.7s ease-in-out infinite alternate; animation: lowBlink 0.7s ease-in-out infinite alternate; }
@-webkit-keyframes lowBlink { from { -webkit-transform: scale(1); } to { -webkit-transform: scale(1.08); } }
@keyframes lowBlink { from { transform: scale(1); } to { transform: scale(1.08); } }
.gdots { margin-left: 8px; font-size: 0; }
.gdots i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-left: 3px; background: #ece6f7; box-shadow: inset 0 0 0 2px #d4c8ee; vertical-align: middle; }
.gdots i.on { background: var(--yellow); box-shadow: inset 0 -3px 0 var(--yellow-d); }
.hudcoins { display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; margin: 3px; }
.hudcoins .coinpill { height: 48px; font-size: 18px; }
.hudcoins .ibtn { height: 48px; min-width: 52px; margin-left: 6px; font-size: 24px; }

/* 목표 */
.targetrow { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; margin-top: 8px; }
.target {
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center;
  background: var(--purple); color: #fff; border-radius: 24px; padding: 4px 18px 4px 16px; min-height: 72px;
  box-shadow: 0 5px 0 var(--purple-dd), 0 8px 18px rgba(90,47,214,0.25);
}
.ql .target { box-shadow: none; }
.tlabel { font-size: 18px; font-weight: 900; margin-right: 10px; opacity: 0.92; }
.tnum { font-size: 52px; font-weight: 900; color: var(--yellow); line-height: 1; min-width: 1.1em; text-align: center; text-shadow: 0 3px 0 var(--purple-dd); }
.target.bump .tnum { -webkit-animation: bump 0.5s ease-out; animation: bump 0.5s ease-out; }
@-webkit-keyframes bump { 0% { -webkit-transform: scale(1); } 35% { -webkit-transform: scale(1.35); } 100% { -webkit-transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
.tside { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: flex-start; align-items: flex-start; margin-left: 10px; }
.opbadge, .three, .nextchip {
  display: inline-block; border-radius: 14px; padding: 3px 12px; font-weight: 900; font-size: 18px; margin: 2px 0; white-space: nowrap;
}
.opbadge { background: var(--yellow); color: var(--purple-d); box-shadow: inset 0 -3px 0 var(--yellow-d); }
.opbadge b { font-size: 26px; line-height: 1; vertical-align: -2px; margin-right: 4px; }
.three { background: #fff; color: var(--purple-d); box-shadow: inset 0 0 0 3px var(--purple); }
.three .tdots { margin-left: 6px; letter-spacing: 1px; color: var(--purple); }
.three.warn { background: var(--warn-soft); color: #b0123f; box-shadow: inset 0 0 0 3px var(--warn); }
.three.full { background: var(--purple); color: #fff; box-shadow: inset 0 -3px 0 var(--purple-dd); }
.three.full .tdots { color: var(--yellow); }
.nextchip { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px #d4c8ee; }
.invis { visibility: hidden; }
.nextchip b { color: var(--purple-d); font-size: 22px; vertical-align: -1px; }

/* 식 보여 주기 */
.expr {
  margin: 8px auto 0; max-width: 640px; height: 92px; overflow: hidden; background: #fff; border-radius: 22px; padding: 6px 12px;
  display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: center; justify-content: center; -webkit-align-items: center; align-items: center;
  box-shadow: 0 3px 0 #ddd2f2; text-align: center; border: 3px solid transparent;
}
.ql .expr { box-shadow: none; border-color: #ddd2f2; }
.etext { font-size: 34px; font-weight: 900; line-height: 1.15; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.etext .op { color: var(--purple); margin: 0 0.12em; }
.etext .eq { color: var(--ink2); margin: 0 0.12em; }
.etext .res { display: inline-block; min-width: 1.2em; padding: 0 0.2em; border-radius: 0.3em; background: var(--purple-soft); color: var(--purple-d); }
.etext.idle { font-size: 22px; color: var(--ink2); white-space: normal; }
.etext.idle b { color: var(--purple-d); font-size: 28px; }
.enote { font-size: 17px; font-weight: 900; color: var(--ink2); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.enote:empty { display: none; }
.etext.idle { line-height: 1.2; max-height: 2.4em; }
.expr.good { border-color: var(--ok); background: var(--ok-soft); }
.expr.good .res { background: var(--ok); color: #fff; }
.expr.good .enote { color: #0d6e4b; }
.expr.bad { border-color: var(--warn); background: #fff6f8; }
.expr.bad .res { background: var(--warn); color: #fff; }
.expr.bad .enote { color: #b0123f; }
.expr.warn { border-color: #ffb020; background: #fff8e4; }
.expr.warn .enote { color: #9a5a00; }

/* ===== 숫자판 ===== */
.boardwrap { -webkit-flex: 1; flex: 1; position: relative; min-height: 0; margin: 8px 8px 8px; touch-action: none; }
#panel { position: absolute; left: 0; top: 0; border-radius: 26px; overflow: hidden; touch-action: none; }
.pbg {
  background-color: var(--purple);
  background-image: radial-gradient(rgba(255,255,255,0.12) 12%, transparent 13%);
  background-size: 26px 26px;
  box-shadow: 0 6px 0 var(--purple-dd), 0 12px 26px rgba(61,30,166,0.3);
}
.ql .pbg, .qm .pbg { box-shadow: 0 6px 0 var(--purple-dd); }
#board { position: absolute; touch-action: none; }
#blocks, #fx { position: absolute; left: 0; top: 0; right: 0; bottom: 0; }
#lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#fx { pointer-events: none; }
.blk { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; }
#board.anim .blk { -webkit-transition: -webkit-transform 0.34s cubic-bezier(0.34, 1.25, 0.64, 1); transition: transform 0.34s cubic-bezier(0.34, 1.25, 0.64, 1); }
.reduce #board.anim .blk { -webkit-transition-duration: 0.12s; transition-duration: 0.12s; }
.face {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0;
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  font-weight: 900; line-height: 1; letter-spacing: -0.03em;
}
.face .n { position: relative; z-index: 1; }
.blk.sel .face { -webkit-transform: scale(0.92); transform: scale(0.92); }
.blk.hint .face { -webkit-animation: hintPulse 0.8s ease-in-out infinite alternate; animation: hintPulse 0.8s ease-in-out infinite alternate; }
@-webkit-keyframes hintPulse { from { -webkit-transform: scale(1); } to { -webkit-transform: scale(0.84); } }
@keyframes hintPulse { from { transform: scale(1); } to { transform: scale(0.84); } }
.blk.hint .face::after {
  content: ''; position: absolute; left: -0.1em; top: -0.1em; right: -0.1em; bottom: -0.1em; border-radius: 0.4em;
  border: 0.12em solid #22d3ff; z-index: 2;
}
.blk.shake .face { -webkit-animation: shake 0.45s ease-in-out; animation: shake 0.45s ease-in-out; }
@-webkit-keyframes shake { 0%,100% { -webkit-transform: translateX(0); } 20% { -webkit-transform: translateX(-0.22em) rotate(-4deg); } 40% { -webkit-transform: translateX(0.22em) rotate(4deg); } 60% { -webkit-transform: translateX(-0.15em); } 80% { -webkit-transform: translateX(0.1em); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-0.22em) rotate(-4deg); } 40% { transform: translateX(0.22em) rotate(4deg); } 60% { transform: translateX(-0.15em); } 80% { transform: translateX(0.1em); } }
.blk.badpath .face::after {
  content: '✗'; position: absolute; right: 0.08em; top: 0.04em; font-size: 0.42em; color: #fff; background: var(--warn);
  width: 1.3em; height: 1.3em; line-height: 1.3em; text-align: center; border-radius: 50%; z-index: 2;
}
.blk.pop .face { -webkit-animation: popOut 0.28s ease-in forwards; animation: popOut 0.28s ease-in forwards; }
@-webkit-keyframes popOut { 0% { -webkit-transform: scale(1); opacity: 1; } 40% { -webkit-transform: scale(1.22); opacity: 1; } 100% { -webkit-transform: scale(0.1); opacity: 0; } }
@keyframes popOut { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.22); opacity: 1; } 100% { transform: scale(0.1); opacity: 0; } }
.blk.fade .face { opacity: 0; -webkit-transition: opacity 0.2s; transition: opacity 0.2s; }
.reduce .blk.pop .face { -webkit-animation-duration: 0.12s; animation-duration: 0.12s; }
.spark {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  -webkit-transition: -webkit-transform 0.5s ease-out, opacity 0.5s ease-out; transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}
.spark.star { background: transparent !important; width: 22px; height: 22px; margin: -11px 0 0 -11px; font-size: 20px; line-height: 22px; text-align: center; color: #ffe14d; }
#pop {
  position: absolute; left: 50%; top: 40%; z-index: 15; pointer-events: none; font-size: 44px; font-weight: 900; color: #fff; white-space: nowrap;
  text-shadow: 0 3px 0 var(--purple-dd), 0 0 12px rgba(90,47,214,0.6); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); opacity: 0;
}
#pop.show { -webkit-animation: popUp 0.9s ease-out forwards; animation: popUp 0.9s ease-out forwards; }
@-webkit-keyframes popUp { 0% { opacity: 0; -webkit-transform: translate(-50%, -30%) scale(0.6); } 25% { opacity: 1; -webkit-transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; -webkit-transform: translate(-50%, -110%) scale(1); } }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -110%) scale(1); } }

/* ===== 숫자판 스킨: 색과 블록 모양이 모두 다르다 ===== */
/* 기본 숫자판: 노란 네모 블록 */
.skin-basic .face {
  border-radius: 24%; background: #ffd93b; background-image: linear-gradient(180deg, #ffe87a 0%, #ffd93b 60%);
  color: var(--purple-d); box-shadow: inset 0 -0.16em 0 #e0a800, inset 0 0.08em 0 rgba(255,255,255,0.7);
}
.qh .skin-basic .face { box-shadow: inset 0 -0.16em 0 #e0a800, inset 0 0.08em 0 rgba(255,255,255,0.7), 0 0.08em 0.18em rgba(40,10,120,0.35); }
.skin-basic { --line: #4a1fc0; --bead: #4a1fc0; --beadtxt: #ffe14d; }
/* 분필 노트: 초록 칠판 + 점선 네모 */
.pbg.skin-paper {
  background-color: #2f5d46; background-image: radial-gradient(rgba(255,255,255,0.06) 20%, transparent 22%); background-size: 18px 18px;
  box-shadow: 0 0 0 6px #b9844f inset, 0 6px 0 #7a5230;
}
.skin-paper .face {
  border-radius: 10%; background: rgba(255,255,255,0.07); border: 0.07em dashed rgba(255,255,255,0.85);
  color: #fffbe6; text-shadow: 0 0 0.06em rgba(255,255,255,0.8);
}
.skin-paper .blk:nth-child(3n) .face { -webkit-transform: rotate(-3deg); transform: rotate(-3deg); }
.skin-paper .blk:nth-child(3n+1) .face { -webkit-transform: rotate(2deg); transform: rotate(2deg); }
.skin-paper { --line: #fff59a; --bead: #fff59a; --beadtxt: #2f5d46; --ordtxt: #2f5d46; }
/* 민트 건반: 피아노 건반 모양 */
.pbg.skin-mint { background-color: #1f3b36; background-image: linear-gradient(180deg, #24463f, #183029); box-shadow: 0 6px 0 #0f221e; }
.skin-mint .face {
  border-radius: 0.1em 0.1em 0.45em 0.45em; background: #ffffff; background-image: linear-gradient(180deg, #ffffff 0%, #d4f7ea 100%);
  color: #12715a; box-shadow: inset 0 -0.2em 0 #5fd3b0;
}
.skin-mint .face::before {
  content: ''; position: absolute; left: 34%; right: 34%; top: 0; height: 22%; background: #1f3b36; border-radius: 0 0 0.12em 0.12em;
}
.skin-mint .face .n { margin-top: 0.3em; }
.skin-mint { --line: #14a37f; --bead: #14a37f; --beadtxt: #ffffff; }
/* 밤색 피아노: 동그란 나무 단추 */
.pbg.skin-walnut {
  background-color: #4a2c17; background-image: repeating-linear-gradient(100deg, rgba(255,255,255,0.05) 0, rgba(255,255,255,0.05) 6px, transparent 6px, transparent 17px);
  box-shadow: 0 6px 0 #2a170a;
}
.skin-walnut .face {
  border-radius: 50%; background: #a8693d; background-image: radial-gradient(circle at 38% 30%, #d9a06c 0%, #a8693d 55%, #7a4626 100%);
  color: #fff4dc; box-shadow: inset 0 0 0 0.07em #f2d3a8; text-shadow: 0 0.05em 0 rgba(0,0,0,0.35);
}
.skin-walnut { --line: #ffe9b8; --bead: #ffe9b8; --beadtxt: #5b3416; --ordtxt: #5b3416; }
/* 황금 재즈: 밤하늘 무대 + 금빛 잎 모양 */
.pbg.skin-gold {
  background-color: #15132b; background-image: radial-gradient(rgba(255,230,140,0.5) 6%, transparent 8%), linear-gradient(180deg, #1d1940, #0f0d22);
  background-size: 30px 30px, 100% 100%; box-shadow: 0 6px 0 #000;
}
.skin-gold .face {
  border-radius: 0.55em 0.12em 0.55em 0.12em; background: #ffcf3a; background-image: linear-gradient(135deg, #fff6b0 0%, #ffcf3a 45%, #c98a00 100%);
  color: #2a1a00; box-shadow: inset 0 0 0 0.05em rgba(255,255,255,0.6);
}
.skin-gold .face::before { content: '★'; position: absolute; right: 0.14em; top: 0.06em; font-size: 0.34em; color: #fff; }
.skin-gold { --line: #ff4f9a; --bead: #ff4f9a; --beadtxt: #ffffff; }

/* 선택 선 */
#lines .ln { fill: none; stroke: var(--line, #4a1fc0); stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
#lines .bead { fill: var(--bead, #4a1fc0); }
#lines .bt { fill: var(--beadtxt, #ffe14d); font-weight: 900; text-anchor: middle; }
#lines .ord { fill: #fff; stroke: var(--line, #4a1fc0); }
#lines .ot { fill: var(--ordtxt, var(--line, #4a1fc0)); font-weight: 900; text-anchor: middle; }
#lines.good .ln { stroke: var(--ok); }
#lines.good .bt { fill: #fff; }
#lines.good .ord { stroke: var(--ok); }
#lines.good .ot { fill: var(--ok); }
#lines.good .bead { fill: var(--ok); }

/* ===== 겹쳐 뜨는 창 ===== */
.ov {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 20; background: rgba(54,38,95,0.5);
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  padding: 16px; padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.ov.light { background: rgba(246,241,255,0.6); }
.loading { background: #fff; border-radius: 22px; padding: 16px 24px; font-size: 22px; font-weight: 900; color: var(--purple-d); box-shadow: 0 4px 0 #ddd2f2; }
.sheet {
  width: 100%; max-width: 560px; max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--paper); border-radius: 32px; padding: 22px 18px 16px; text-align: center; border: 4px solid #fff;
  box-shadow: 0 16px 40px rgba(54,38,95,0.35);
}
.ql .sheet { box-shadow: none; }
.sheet h2 { margin: 2px 0 10px; font-size: 30px; font-weight: 900; color: var(--purple-d); }
.btnrow { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: center; justify-content: center; margin-top: 12px; }
.bubblewrap { display: -webkit-flex; display: flex; -webkit-align-items: flex-end; align-items: flex-end; text-align: left; }
.mascot { font-size: 64px; line-height: 1; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.bubble {
  position: relative; background: var(--purple-soft); border-radius: 26px; padding: 18px 20px; font-size: 25px; font-weight: 900; line-height: 1.4; color: var(--purple-dd);
  -webkit-flex: 1; flex: 1;
}
.bubble::before { content: ''; position: absolute; left: -14px; bottom: 18px; border: 10px solid transparent; border-right: 14px solid var(--purple-soft); border-left: 0; }
.introart { margin: 4px 0 14px; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.mini {
  display: inline-block; width: 52px; height: 52px; line-height: 52px; border-radius: 14px; background: var(--yellow); color: var(--purple-d);
  font-size: 30px; font-weight: 900; text-align: center; box-shadow: inset 0 -5px 0 var(--yellow-d); margin: 3px;
}
.mini.on { background: var(--purple); color: var(--yellow); box-shadow: inset 0 -5px 0 var(--purple-dd); }
.mop { font-size: 34px; font-weight: 900; color: var(--purple); margin: 0 4px; }
.mgrid { display: inline-block; line-height: 0; }
.mgrid i { display: inline-block; width: 22px; height: 22px; margin: 2px; border-radius: 6px; background: var(--yellow); box-shadow: inset 0 -3px 0 var(--yellow-d); }
.pagedots { margin-top: 10px; }
.pagedots i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #e1d8f2; margin: 0 3px; }
.pagedots i.on { background: var(--purple); }
.rface { font-size: 64px; line-height: 1.1; }
.score { font-size: 54px; font-weight: 900; color: var(--purple-d); line-height: 1.1; margin: 4px 0; }
.score small { font-size: 24px; margin-left: 4px; }
.rline { font-size: 18px; font-weight: 800; color: var(--ink2); margin: 4px 0; }
.rbest { font-size: 18px; font-weight: 900; margin: 6px 0; }
.rbest .newrec { display: inline-block; background: var(--yellow); color: #5a3d00; border-radius: 10px; padding: 2px 8px; margin-left: 6px; font-size: 15px; }
.rcoins { margin: 10px auto 4px; display: inline-block; background: var(--yellow-soft); border-radius: 20px; padding: 8px 20px; font-size: 30px; font-weight: 900; color: #6b4d00; min-height: 54px; }
.rcoins.wait { font-size: 19px; color: var(--ink2); padding-top: 14px; }
.rnote { font-size: 16px; font-weight: 800; color: var(--ink2); margin: 2px 0; }
.rerr { margin: 10px 0 4px; background: var(--warn-soft); color: #a2183f; font-weight: 900; font-size: 18px; border-radius: 16px; padding: 10px 12px; }
.unlock { margin: 8px 0; background: var(--ok-soft); color: #0d6e4b; font-weight: 900; font-size: 19px; border-radius: 16px; padding: 10px 12px; }
.pausebtns { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: stretch; align-items: stretch; max-width: 320px; margin: 0 auto; }

/* 상점 */
.shophead { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin-bottom: 10px; }
.shophead h2 { margin: 0; text-align: left; }
.shophead .ibtn { margin-left: 8px; }
.items { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -5px; }
.itemcell { width: 50%; padding: 5px; }
.item { background: #fff; border-radius: 22px; padding: 12px 8px 10px; border: 3px solid #ece4fb; height: 100%; }
.item.using { border-color: var(--ok); background: #f2fff8; }
.skinprev { box-shadow: none !important; position: relative; display: block; width: 158px; height: 66px; margin: 0 auto 8px; border-radius: 16px; overflow: hidden; }
.skinprev .blk { width: 44px; height: 44px; top: 11px; font-size: 24px; }
.skinprev .blk.p1 { left: 9px; } .skinprev .blk.p2 { left: 57px; } .skinprev .blk.p3 { left: 105px; }
.skinprev .blk { z-index: 1; }
.skinprev .pline { position: absolute; left: 31px; right: 31px; top: 30px; height: 6px; border-radius: 3px; background: var(--line); opacity: 0.9; z-index: 0; }
.iname { font-size: 18px; font-weight: 900; margin-bottom: 4px; }
.idesc { font-size: 14px; font-weight: 800; color: var(--ink2); margin-bottom: 8px; }
.item .bigbtn { width: 100%; margin: 0; min-height: 56px; font-size: 18px; padding: 8px 6px; }
.item .bigbtn.cant { opacity: 0.45; }
.usingtag { display: block; min-height: 56px; line-height: 56px; font-size: 18px; font-weight: 900; color: var(--ok); }
.shopmsg { margin-top: 10px; font-weight: 800; color: var(--ink2); font-size: 16px; }

/* 알림·효과 */
#toast {
  position: absolute; left: 50%; top: 18%; z-index: 40; -webkit-transform: translateX(-50%); transform: translateX(-50%);
  background: rgba(54,38,95,0.94); color: #fff; font-weight: 900; font-size: 20px; padding: 12px 20px; border-radius: 20px; max-width: 88%; text-align: center; pointer-events: none;
}
.confetti { position: absolute; top: -40px; z-index: 18; pointer-events: none; font-size: 28px; -webkit-animation: fall 1.8s ease-in forwards; animation: fall 1.8s ease-in forwards; }
@-webkit-keyframes fall { to { -webkit-transform: translateY(110vh) rotate(540deg); } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* 작은 화면 */
@media (max-width: 700px) {
  .lvcell { width: 25%; }
  .gametitle { font-size: 28px; }
  .tblk { display: none; }
}
@media (max-width: 560px) {
  .modecell { width: 100%; }
  .hud { padding: 6px 8px 0; }
  .ttl b { font-size: 22px; }
  .stat { padding: 3px 9px; min-height: 44px; }
  .stat .k { font-size: 13px; }
  .stat .v { font-size: 22px; }
  .gdots i { width: 11px; height: 11px; }
  .bubble { font-size: 21px; }
  .coinpill { font-size: 18px; padding: 0 10px 0 8px; }
  .hudcoins .coinpill { height: 44px; }
  .hudcoins .ibtn { height: 44px; }
  .target { min-height: 60px; padding: 2px 14px; }
  .tnum { font-size: 42px; }
  .opbadge, .three, .nextchip { font-size: 16px; padding: 2px 10px; }
  .expr { height: 82px; padding: 4px 8px; }
  .etext { font-size: 28px; }
  .etext.idle { font-size: 19px; }
  .etext.idle b { font-size: 24px; }
  .enote { font-size: 15px; }
  .boardwrap { margin: 6px 4px 6px; }
  .itemcell { width: 50%; }
  .skinprev { width: 132px; }
  .skinprev .blk { width: 38px; height: 38px; top: 14px; font-size: 21px; }
  .skinprev .blk.p1 { left: 6px; } .skinprev .blk.p2 { left: 47px; } .skinprev .blk.p3 { left: 88px; }
  .skinprev .pline { left: 25px; right: 25px; }
}
@media (max-width: 400px) {
  .gametitle { font-size: 23px; }
  .lv { min-height: 70px; font-size: 23px; }
  .lv small { font-size: 12px; }
  .stat .k { font-size: 12px; margin-right: 4px; }
  .itemcell { width: 100%; }
}
/* 낮은 가로 화면: 상태 표시를 왼쪽 세로 줄로 */
@media (orientation: landscape) and (max-height: 600px) {
  #game { -webkit-flex-direction: row; flex-direction: row; }
  .hud { width: 300px; padding: 8px 4px 8px 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .stats { -webkit-justify-content: flex-start; justify-content: flex-start; }
  .ttl b { font-size: 21px; }
  /* 좁은 세로 줄에서는 장 이름을 자르지 않고 두 줄로 */
  .ttl small { white-space: normal; overflow: visible; word-break: keep-all; font-size: 14px; line-height: 1.2; }
  .targetrow { -webkit-justify-content: flex-start; justify-content: flex-start; }
  .expr { margin-left: 0; margin-right: 0; }
  .etext { font-size: 28px; }
  .boardwrap { margin: 8px 8px 8px 4px; }
}
/* 폭도 좁은 가로 화면(예: 480×320): 상태 줄 폭을 화면에 맞춰 줄여 숫자판 자리를 확보 */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 680px) {
  .hud { width: 34vw; min-width: 150px; padding: 6px 2px 6px 8px; }
  .ttl b { font-size: 18px; }
  .ttl small { font-size: 12px; }
  .etext { font-size: 22px; }
  .stat .k { font-size: 11px; margin-right: 3px; }
  .boardwrap { margin: 6px 6px 6px 2px; }
  /* 좁아진 상태 줄 안: 버튼을 줄이고, 판 이름은 버튼 아래 줄로, 목표 옆 표시는 목표 아래로 */
  .hud .topbar { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .hud .topbar > * { margin-right: 6px; }
  .hud .ibtn { min-width: 42px; height: 42px; border-radius: 14px; font-size: 20px; padding: 0 6px; }
  .hud .topbar .ttl { -webkit-order: 9; order: 9; -webkit-flex: 1 0 100%; flex: 1 0 100%; margin: 6px 0 0; text-align: left; }
  .targetrow { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .target { min-height: 54px; padding: 4px 12px; border-radius: 18px; }
  .tlabel { font-size: 15px; margin-right: 6px; }
  .tnum { font-size: 38px; }
  .tside { margin: 6px 0 0; -webkit-flex-direction: row; flex-direction: row; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .opbadge, .three, .nextchip { font-size: 15px; padding: 2px 10px; margin: 2px 4px 2px 0; }
}
