/* 칙칙 팡 화면 스타일: 빨강 기관차 · 노랑 · 하늘 (들판 기차 여행) */
:root {
  --red: #e8453c; --red-d: #b52a23; --red-soft: #ffe1dc;
  --yellow: #ffd23f; --yellow-d: #d9a400; --yellow-soft: #fff4c4;
  --sky: #5cc4ff; --sky-d: #2a8fd0; --sky-soft: #dff3ff;
  --grass: #8fd16a; --grass-d: #4f9a3a;
  --ink: #2d3550; --ink2: #6b7393; --paper: #fffdf6;
  --warn: #e8453c;
}
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(--sky-d); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
button[disabled] { cursor: default; }
.hidden { display: none !important; }

/* ===== 바탕: 하늘과 언덕 ===== */
#app {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden;
  background-color: #bfe8ff;
  background-image:
    radial-gradient(ellipse at 18% 118%, #9fdc7a 38%, rgba(159,220,122,0) 39%),
    radial-gradient(ellipse at 82% 124%, #86cf63 36%, rgba(134,207,99,0) 37%),
    radial-gradient(ellipse at 14% 14%, rgba(255,255,255,0.9) 5%, rgba(255,255,255,0) 6%),
    radial-gradient(ellipse at 20% 12%, rgba(255,255,255,0.9) 6%, rgba(255,255,255,0) 7%),
    radial-gradient(ellipse at 78% 22%, rgba(255,255,255,0.85) 5%, rgba(255,255,255,0) 6%),
    radial-gradient(ellipse at 84% 20%, rgba(255,255,255,0.85) 6%, rgba(255,255,255,0) 7%),
    linear-gradient(180deg, #7fd0ff 0%, #bfe8ff 55%, #eaf8dc 100%);
  background-size: 100% 100%;
}
.q0 #app { background-image: linear-gradient(180deg, #7fd0ff 0%, #bfe8ff 55%, #eaf8dc 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 #b9dcf2, 0 6px 14px rgba(42,143,208,0.18); 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, .dbtn:active, .chip:active { -webkit-transform: scale(0.94); transform: scale(0.94); }
.bigbtn {
  min-height: 60px; border: 0; border-radius: 22px; padding: 10px 22px; font-size: 21px; font-weight: 900;
  background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d), 0 8px 18px rgba(181,42,35,0.25);
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; margin: 6px;
}
.bigbtn.sky { background: var(--sky); color: #0f4870; box-shadow: 0 5px 0 #3a9fdc, 0 8px 18px rgba(42,143,208,0.22); }
.bigbtn.yellow { background: var(--yellow); color: #5a4000; box-shadow: 0 5px 0 var(--yellow-d), 0 8px 18px rgba(217,164,0,0.22); }
.bigbtn.plain { background: #fff; color: var(--ink); box-shadow: 0 5px 0 #cfdbe6, 0 8px 18px rgba(60,90,120,0.12); }
.bigbtn[disabled], .bigbtn.cant { opacity: 0.45; }
.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 #f0d070; white-space: nowrap; -webkit-flex-shrink: 0; flex-shrink: 0;
}
.coinpill .ci { font-size: 24px; margin-right: 5px; }
.q0 .ibtn, .q0 .bigbtn, .q0 .coinpill { box-shadow: none; border: 2px solid #b9dcf2; }

/* ===== 지도 ===== */
#map { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.mapwrap { max-width: 940px; 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; color: var(--red); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 #fff; }
.gametitle span { color: var(--sky-d); }
.tagline { margin: 10px 4px 6px; font-size: 18px; color: #2c4a66; font-weight: 800; }
.tagline b { color: var(--red); }
.banner { margin: 10px 0; padding: 12px 16px; border-radius: 18px; background: #ffe3e3; color: #a2283f; 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(40,90,130,0.16); border: 3px solid var(--chc, #ffd23f);
}
.q0 .chapter { box-shadow: none; }
.chapter.locked { opacity: 0.75; }
.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, #ffd23f); 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: 700; 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, #e8c34a); font-size: 26px; font-weight: 900; line-height: 1.1;
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; position: relative;
  border: 2px solid var(--chc, #ffd23f);
}
.lv small { display: block; font-size: 13px; font-weight: 800; color: var(--ink2); margin-top: 4px; white-space: nowrap; }
.lv.done { background: var(--chc, #ffd23f); }
.lv.done small { color: var(--ink); }
.lv.locked { background: #eef1f4; color: #a9b1bc; box-shadow: 0 4px 0 #d6dce3; border-color: #dfe4ea; }
.lv.next { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-d); border-color: var(--red-d); }
.lv.next small { color: #fff; }
.q2 .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;
  -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s; display: block;
}
.modebtn.daily { background: linear-gradient(135deg, #fff1a8, #ffc9a8); box-shadow: 0 6px 0 #e7b46a, 0 10px 24px rgba(217,140,0,0.2); }
.modebtn.endless { background: linear-gradient(135deg, #c7ecff, #ffd0cc); box-shadow: 0 6px 0 #9cc6e6, 0 10px 24px rgba(42,143,208,0.2); }
.q0 .modebtn { box-shadow: none; }
.modebtn.locked { background: #eef1f4; box-shadow: 0 6px 0 #d6dce3; color: #8e97a3; }
.modebtn .mt { font-size: 25px; font-weight: 900; padding-right: 50px; }
.modebtn .ms { font-size: 16px; font-weight: 800; margin-top: 6px; color: var(--ink); opacity: 0.85; padding-right: 40px; }
.modebtn.locked .ms { color: #8e97a3; }
.modebtn .mi { position: absolute; right: 14px; top: 12px; font-size: 40px; }
.modebtn .done { display: inline-block; margin-top: 8px; background: #fff; color: #2f8a3a; border-radius: 12px; padding: 3px 10px; font-size: 15px; font-weight: 900; }

/* ===== 게임 화면 ===== */
#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(--red); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 #fff; }
.ttl small { display: block; font-size: 15px; font-weight: 800; color: #2c4a66; 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: 8px; }
.stat {
  display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center;
  background: #fff; border-radius: 16px; padding: 6px 12px; margin: 3px; font-weight: 900; font-size: 18px; min-height: 44px; white-space: nowrap;
  box-shadow: 0 3px 0 #c9dbe8;
}
.q0 .stat { box-shadow: none; border: 2px solid #dbe6ee; }
.stat .k { font-size: 14px; color: var(--ink2); margin-right: 6px; font-weight: 800; }
.stat .v { font-size: 22px; }
.stat .k2 { font-size: 14px; color: var(--ink2); margin-left: 6px; font-weight: 800; }
.stat.left { background: var(--yellow-soft); box-shadow: 0 3px 0 #ecd27a; }
.stat.left .v { font-size: 28px; color: #7a5200; }
.stat.left.low { background: #ffe0dc; box-shadow: 0 3px 0 #ffaaa0; }
.stat.left.low .v { color: #d3211a; }
.q1 .stat.left.low, .q2 .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); } }
.stat.aboard { min-width: 196px; }
.stat.aboard .pax { display: inline-block; position: relative; font-size: 24px; margin: 0 3px; line-height: 1; }
.stat.aboard .pax svg { position: absolute; right: -6px; bottom: -4px; }
.stat.aboard .none { font-size: 15px; color: var(--ink2); }
.hudcoins { display: -webkit-inline-flex; display: inline-flex; -webkit-align-items: center; align-items: center; margin: 3px; }
.hudcoins .coinpill { height: 44px; font-size: 18px; border-radius: 16px; }
.hudcoins .ibtn { height: 44px; min-width: 50px; margin-left: 6px; font-size: 22px; border-radius: 16px; }
.hint {
  text-align: center; font-size: 18px; font-weight: 900; margin: 6px 0 0; color: #1f3d5c;
  height: 2.6em; line-height: 1.3; overflow: hidden; /* 문구 길이에 따라 판 크기가 흔들리지 않게 높이를 고정 */
}
.hint svg { vertical-align: -3px; }
.hint.warn { color: #c0261f; }
.boardwrap { -webkit-flex: 1; flex: 1; position: relative; min-height: 0; margin: 6px 10px 4px; touch-action: none; }
#board { position: absolute; left: 0; top: 0; touch-action: none; display: block; }

/* 조작 버튼 */
.ctrl {
  -webkit-flex-shrink: 0; flex-shrink: 0; padding: 4px 12px 10px;
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
}
.dpad { display: grid; grid-template-columns: 72px 72px 72px; grid-template-rows: 72px 72px 72px; grid-gap: 6px; gap: 6px; }
.dbtn {
  border: 0; border-radius: 22px; background: #fff; font-size: 34px; font-weight: 900; color: var(--red);
  box-shadow: 0 5px 0 #b9cfe0, 0 8px 16px rgba(42,100,150,0.18); padding: 0;
  display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  -webkit-transition: -webkit-transform 0.06s; transition: transform 0.06s;
}
.q0 .dbtn { box-shadow: none; border: 3px solid #b9cfe0; }
.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 3; }
.dbtn.wait {
  grid-column: 2; grid-row: 2; background: var(--yellow); color: #5a4000; box-shadow: 0 5px 0 var(--yellow-d);
  -webkit-flex-direction: column; flex-direction: column; font-size: 26px; border-radius: 50%;
}
.dbtn.wait small { font-size: 13px; font-weight: 900; margin-top: 1px; }
.dbtn.wait.call { -webkit-animation: callMe 0.5s ease-in-out 3 alternate; animation: callMe 0.5s ease-in-out 3 alternate; }
@-webkit-keyframes callMe { from { -webkit-transform: scale(1); box-shadow: 0 5px 0 var(--yellow-d); } to { -webkit-transform: scale(1.14); box-shadow: 0 0 0 6px rgba(232,69,60,0.6); } }
@keyframes callMe { from { transform: scale(1); box-shadow: 0 5px 0 var(--yellow-d); } to { transform: scale(1.14); box-shadow: 0 0 0 6px rgba(232,69,60,0.6); } }
.dpadmid { grid-column: 2; grid-row: 2; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; font-size: 30px; opacity: 0.5; }
.dbtn[disabled] { opacity: 0.5; }

/* 준비 중 표시 */
.loading {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 12;
  display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;
  background: rgba(191,232,255,0.82); font-size: 24px; font-weight: 900; color: #1f3d5c;
}
.loading .lt { font-size: 64px; line-height: 1.2; }
.q1 .loading .lt, .q2 .loading .lt { -webkit-animation: chug 0.5s ease-in-out infinite alternate; animation: chug 0.5s ease-in-out infinite alternate; }
@-webkit-keyframes chug { from { -webkit-transform: translateX(-10px) rotate(-3deg); } to { -webkit-transform: translateX(10px) rotate(3deg); } }
@keyframes chug { from { transform: translateX(-10px) rotate(-3deg); } to { transform: translateX(10px) rotate(3deg); } }

/* ===== 겹쳐 뜨는 창 ===== */
.ov {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 20; background: rgba(20,40,70,0.42);
  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.low { -webkit-align-items: flex-end; align-items: flex-end; background: rgba(20,40,70,0.22); }
.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(20,40,70,0.35);
}
.q0 .sheet { box-shadow: none; }
.sheet h2 { margin: 2px 0 10px; font-size: 30px; font-weight: 900; color: var(--red); }
.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; margin: 8px 0; }
.mascot { font-size: 58px; line-height: 1; margin-right: 10px; -webkit-flex-shrink: 0; flex-shrink: 0; }
.bubble {
  position: relative; background: var(--sky-soft); border-radius: 26px; padding: 16px 18px; font-size: 23px; font-weight: 900; line-height: 1.4; color: #134a74;
  -webkit-flex: 1; flex: 1;
}
.bubble::before { content: ''; position: absolute; left: -14px; bottom: 18px; border: 10px solid transparent; border-right: 14px solid var(--sky-soft); border-left: 0; }
.bubble .art { display: block; font-size: 34px; letter-spacing: 4px; margin-bottom: 4px; }
.bubble .art svg { vertical-align: -4px; margin: 0 2px; }
.goal { font-size: 19px; font-weight: 900; color: #2c4a66; margin: 8px 0; }
.goal b { color: var(--red); font-size: 22px; }
.smokebox { margin: 10px 0 2px; background: #f3f8fc; border-radius: 20px; padding: 10px 8px 8px; }
.smokebox .st { font-size: 16px; font-weight: 900; color: #2c4a66; margin-bottom: 6px; }
.chips { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: center; justify-content: center; }
.chip {
  min-height: 56px; min-width: 64px; border: 3px solid #dbe6ee; background: #fff; border-radius: 18px; margin: 3px; padding: 4px 10px;
  font-size: 15px; font-weight: 900; line-height: 1.15; -webkit-transition: -webkit-transform 0.08s; transition: transform 0.08s;
}
.chip .ce { display: block; font-size: 24px; }
.chip.on { border-color: var(--red); background: var(--red-soft); }
.smokebox .sn { font-size: 15px; font-weight: 800; color: var(--ink2); margin-top: 6px; }
.smokebox .sn b { color: var(--red); }
.err { margin: 10px 0 4px; background: #ffe3e3; color: #a2283f; font-weight: 900; font-size: 18px; border-radius: 16px; padding: 10px 12px; }
.err:empty { display: none; }
.rface { font-size: 60px; line-height: 1.1; }
.score { font-size: 52px; font-weight: 900; color: var(--red); line-height: 1.1; margin: 4px 0; }
.score small { font-size: 24px; margin-left: 4px; }
.rline { font-size: 17px; 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; }
.unlock { margin: 8px 0; background: #e3f7dc; color: #2f6e22; font-weight: 900; font-size: 19px; border-radius: 16px; padding: 10px 12px; }
.failwhy { font-size: 24px; font-weight: 900; color: #2c4a66; margin: 4px 0 6px; }
.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: 6px; }
.shophead h2 { margin: 0; text-align: left; font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shopsec { text-align: left; font-size: 19px; font-weight: 900; color: #2c4a66; margin: 12px 4px 6px; }
.shopsec small { font-size: 14px; color: var(--ink2); font-weight: 800; margin-left: 4px; }
.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: 10px 8px 10px; border: 3px solid #e3ebf2; height: 100%; }
.item.using { border-color: #6cc35a; background: #f2fff0; }
.item.picked { border-color: var(--red); background: #fff6f4; }
.item canvas { display: block; margin: 0 auto 6px; }
.item .sprev { font-size: 30px; height: 50px; line-height: 50px; letter-spacing: 2px; white-space: nowrap; overflow: hidden; }
.iname { font-size: 17px; font-weight: 900; margin-bottom: 4px; }
.iqty { font-size: 14px; font-weight: 800; color: var(--ink2); margin-bottom: 6px; min-height: 17px; }
.item .bigbtn { width: 100%; margin: 4px 0 0; min-height: 56px; font-size: 17px; padding: 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usingtag { display: block; min-height: 56px; line-height: 56px; white-space: nowrap; font-size: 18px; font-weight: 900; color: #2f8a3a; margin-top: 4px; }
.shopmsg { margin-top: 10px; font-weight: 800; color: var(--ink2); font-size: 16px; min-height: 20px; }
.shopmsg.bad { color: #a2283f; }

/* 알림 */
#toast {
  position: absolute; left: 50%; top: 16%; z-index: 40; -webkit-transform: translateX(-50%); transform: translateX(-50%);
  background: rgba(31,61,92,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; }
}
@media (max-width: 560px) {
  .modecell { width: 100%; }
  .ttl b { font-size: 22px; }
  .stat { padding: 4px 9px; min-height: 40px; margin: 2px; }
  .stat .k { font-size: 13px; }
  .stat .v { font-size: 19px; }
  .stat.left .v { font-size: 24px; }
  .hint { font-size: 16px; }
  .stat.aboard { min-width: 176px; }
  .bubble { font-size: 20px; }
  .coinpill { font-size: 18px; padding: 0 10px 0 8px; }
  .hudcoins .coinpill { height: 40px; }
  .hudcoins .ibtn { height: 40px; }
  .itemcell { width: 50%; }
  .shophead h2 { font-size: 21px; }
  .shophead .coinpill { height: 48px; }
  .shophead .ibtn { height: 48px; min-width: 48px; }
  .item .bigbtn { font-size: 15px; padding: 8px 3px; }
  .iname { font-size: 15px; }
  .sheet { padding: 18px 12px 14px; }
}
@media (max-width: 400px) {
  .gametitle { font-size: 23px; }
  .lv { min-height: 70px; font-size: 23px; }
  .lv small { font-size: 12px; }
}
@media (max-height: 760px) and (orientation: portrait) {
  .dpad { grid-template-columns: 64px 64px 64px; grid-template-rows: 60px 60px 60px; }
  .dbtn { font-size: 30px; }
}
@media (max-height: 640px) and (orientation: portrait) {
  .dpad { grid-template-columns: 62px 62px 62px; grid-template-rows: 56px 56px 56px; grid-gap: 4px; gap: 4px; }
  .hud .ibtn { height: 50px; }
}

/* ===== 가로 화면: 왼쪽 상태 · 가운데 판 · 오른쪽 조작 ===== */
@media (orientation: landscape) and (min-aspect-ratio: 13/10) {
  #game { -webkit-flex-direction: row; flex-direction: row; }
  .hud { width: 270px; padding: 10px 4px 10px 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .hud .topbar { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .hud .ttl { -webkit-order: 9; order: 9; -webkit-flex-basis: 100%; flex-basis: 100%; text-align: left; margin: 8px 0 0; }
  .stats { -webkit-justify-content: flex-start; justify-content: flex-start; }
  .hint { text-align: left; font-size: 17px; height: auto; min-height: 2.6em; }
  .boardwrap { margin: 10px 6px; }
  .ctrl { padding: 10px 14px 10px 4px; }
}
@media (orientation: landscape) and (min-aspect-ratio: 13/10) and (max-height: 520px) {
  .hud { width: 230px; }
  .ttl b { font-size: 20px; }
  .ttl small { font-size: 13px; }
  .stat { min-height: 36px; padding: 3px 8px; }
  .stat .v { font-size: 18px; }
  .stat.left .v { font-size: 22px; }
  .hud .ibtn { height: 48px; min-width: 50px; }
  .hudcoins .coinpill, .hudcoins .ibtn { height: 38px; }
  .dpad { grid-template-columns: 60px 60px 60px; grid-template-rows: 60px 60px 60px; grid-gap: 4px; gap: 4px; }
  .dbtn { font-size: 28px; }
  .dbtn.wait { font-size: 22px; }
  .hint { font-size: 15px; }
}
