:root {
  --cream: #FFF4E0; --cream2: #FBE7C6; --ink: #3E2A1E; --pink: #FF8FAE; --pinkL: #FFB3C7;
  --star: #FFD23F; --green: #4E9A3F; --mud: #8B5A2B; --side: clamp(184px, 22vw, 280px);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #A9DA8A; color: var(--ink); font-family: var(--font);
  overflow: hidden; overscroll-behavior: none; touch-action: none; word-break: keep-all; overflow-wrap: anywhere;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: var(--ink); cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #4FB3E8; outline-offset: 2px; }
svg { fill: var(--ink); stroke: var(--ink); stroke-width: 0; }
svg [fill="none"] { fill: none; }

/* ---------------- HUD: 세로 = 위·아래 막대, 가로 = 오른쪽 패널 ---------------- */
#ui {
  position: fixed; inset: 0; display: grid; pointer-events: none; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "top" "board" "bottom";
  transition: opacity .25s;
}
#ui.off { visibility: hidden; }
#ui.dim { opacity: .35; }
#boardArea { grid-area: board; min-height: 0; min-width: 0; }
#top { grid-area: top; display: flex; align-items: center; gap: 8px; }
#bottom { grid-area: bottom; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.bar > * { pointer-events: auto; }
.group { display: flex; gap: 8px; }
#actions { margin-left: auto; }

.card {
  background: var(--cream); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 4px 0 rgba(62, 42, 30, .35); padding: 5px 12px;
}
#lvlBox { min-width: 74px; text-align: center; line-height: 1.05; }
#lvlNum { font-size: 22px; font-weight: 900; letter-spacing: .5px; }
#lvlName { font-size: 12px; font-weight: 700; opacity: .75; white-space: nowrap; }
#chProg { display: none; align-items: center; gap: 6px; margin-top: 5px; }
#lvlBox.daily #chProg { display: none !important; }
#chTrack { flex: 1; height: 8px; border-radius: 4px; background: #E4D3B6; border: 2px solid var(--ink); overflow: hidden; }
#chBar { height: 100%; width: 0; background: linear-gradient(90deg, #FFC93C, #FFE27A); transition: width .5s; }
#chStars { font-size: 12px; font-weight: 900; white-space: nowrap; }
#meter { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
#stars3 { display: flex; gap: 2px; }
#stars3 span, #resStars span { position: relative; display: inline-block; width: 24px; height: 24px; }
#stars3 span::before, #stars3 span::after, #resStars span::before, #resStars span::after {
  content: ''; position: absolute; clip-path: polygon(50% 0%, 61.5% 35%, 98% 35.5%, 68.5% 57%, 79.5% 92%, 50% 70.5%, 20.5% 92%, 31.5% 57%, 2% 35.5%, 38.5% 35%);
}
#stars3 span::before, #resStars span::before { inset: 0; background: var(--ink); }
#stars3 span::after, #resStars span::after { inset: 18%; top: 22%; background: #FFF4E0; transition: background .2s; }
#stars3 span.on::after, #resStars span.on::after { background: var(--star); }
/* 빈 별은 색뿐 아니라 크기·투명도로도 다르게 (색약 대응) */
#stars3 span:not(.on), #resStars span:not(.on) { opacity: .45; transform: scale(.82); }
#resStars span:nth-child(2):not(.on) { transform: translateY(-10px) scale(.82); }
#stars3 span { transition: opacity .2s, transform .2s; }
#stars3 span.lose { animation: starLose .6s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes starLose { 0% { opacity: 1; transform: scale(1.25) rotate(0); } 30% { transform: scale(1.1) rotate(-18deg); } 60% { transform: translateY(6px) scale(.9) rotate(12deg); } }
#tapLine { font-size: 15px; font-weight: 700; white-space: nowrap; display: flex; align-items: baseline; gap: 4px; }
#tapLine b { font-size: 22px; font-weight: 900; display: inline-block; }
#tapLine b.bump { animation: bump .28s ease-out; }
@keyframes bump { 40% { transform: scale(1.35); } }
#tapLine .dot { opacity: .5; }
#goal { opacity: .8; }
.sys { display: flex; gap: 8px; }

.ib {
  width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream);
  box-shadow: 0 4px 0 rgba(62, 42, 30, .35); display: grid; place-items: center; padding: 0;
}
.ib svg { width: 24px; height: 24px; stroke: var(--ink); }
.tool, .act {
  position: relative; min-width: 66px; height: 66px; padding: 4px 8px 6px; border-radius: 18px;
  border: 3px solid var(--ink); background: var(--cream); box-shadow: 0 4px 0 rgba(62, 42, 30, .35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 800; line-height: 1.1;
}
.act svg { width: 28px; height: 28px; stroke: var(--ink); }
.tool canvas { width: 32px; height: 32px; display: block; }
.tool.on { background: linear-gradient(#FFE27A, #FFC93C); border-width: 4px; }
/* 고른 도구: 색 + 굵은 테두리 + 이름 앞 체크 (색만으로 구분하지 않게) */
.tool.on span::before { content: '✓'; margin-right: 2px; font-weight: 900; }
.tool .cnt {
  position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 12px;
  background: var(--ink); color: var(--cream); font-style: normal; font-size: 13px; font-weight: 900; display: grid; place-items: center;
}
.ib:active, .tool:active, .act:active, button.big:active, button.mid:active, button.small:active, .lv:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(62, 42, 30, .35); }
button:disabled { opacity: .42; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .ib:hover:not(:disabled), .tool:hover:not(:disabled), .act:hover:not(:disabled), button.big:hover, button.mid:hover, button.small:hover, .lv:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
}
button:disabled:active { transform: none; }
.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); box-shadow: 0 4px 0 rgba(62, 42, 30, .35), 0 0 0 0 rgba(255, 210, 63, .9); } 50% { transform: scale(1.08); box-shadow: 0 4px 0 rgba(62, 42, 30, .35), 0 0 0 8px rgba(255, 210, 63, 0); } }

@media (min-aspect-ratio: 6/5) {
  #ui { grid-template-columns: minmax(0, 1fr) var(--side); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "board top" "board bottom"; gap: 10px; }
  #top { flex-direction: column; align-items: stretch; gap: 10px; }
  #top .sys { order: -1; justify-content: flex-end; }
  #meter { flex-direction: column; gap: 4px; padding: 8px 10px; flex: none; }
  #lvlBox { padding: 8px 12px; }
  #chProg { display: flex; }
  #lvlNum { font-size: 28px; }
  #lvlName { font-size: 14px; }
  #stars3 span { width: 30px; height: 30px; }
  #bottom { flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 12px; }
  #actions { margin-left: 0; }
  .group { justify-content: center; }
  .tool, .act { flex: 1; min-width: 0; }
}
@media (min-aspect-ratio: 6/5) and (max-height: 460px) {
  #ui { gap: 6px; }
  #top { gap: 6px; }
  #bottom { gap: 8px; }
  .ib { width: 44px; height: 44px; }
  #lvlBox { padding: 3px 8px; display: flex; align-items: baseline; justify-content: center; gap: 8px; }
  #chProg { display: none; }
  #lvlNum { font-size: 20px; }
  #lvlName { font-size: 12px; }
  #meter { padding: 4px 8px; flex-direction: row; gap: 8px; }
  #stars3 span { width: 22px; height: 22px; }
  #tapLine { font-size: 13px; }
  #tapLine b { font-size: 18px; }
  .tool, .act { height: 58px; font-size: 12px; padding: 4px 2px 6px; }
  .act svg { width: 24px; height: 24px; }
  .tool canvas { width: 28px; height: 28px; }
}
@media (max-aspect-ratio: 6/5) {
  #meter { flex-direction: column; gap: 2px; padding: 4px 8px; }
  #stars3 span { width: 21px; height: 21px; }
  #tapLine { font-size: 13px; }
  #tapLine b { font-size: 18px; }
}
@media (max-aspect-ratio: 6/5) and (max-width: 400px) {
  .tool, .act { min-width: 58px; height: 62px; font-size: 12px; padding: 4px 4px 6px; }
  .group { gap: 6px; }
  #lvlBox { min-width: 60px; padding: 4px 8px; }
  #lvlNum { font-size: 20px; }
  .ib { width: 46px; height: 46px; }
}

#tip {
  position: fixed; transform: translate(-50%, -100%); z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 6px 16px; border-radius: 18px; background: rgba(62, 42, 30, .88); color: var(--cream);
  font-size: 15px; font-weight: 800; line-height: 1.25; width: max-content; text-wrap: balance;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18); animation: tipIn .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes tipIn { from { opacity: 0; } }
@media (max-width: 520px) { #tip { font-size: 13.5px; padding: 5px 12px; } }
#toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  padding: 10px 18px; border-radius: 16px; background: var(--cream); border: 3px solid var(--ink);
  font-size: 16px; font-weight: 900; box-shadow: 0 5px 0 rgba(62, 42, 30, .35); white-space: nowrap;
}
#toast.pop { animation: toastIn .3s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes toastIn { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

/* ---------------- 오버레이 ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(62, 42, 30, .28);
}
#title { background: radial-gradient(ellipse at 50% 42%, rgba(255, 244, 224, .55) 0, rgba(255, 244, 224, .25) 45%, rgba(62, 42, 30, .25) 100%); cursor: pointer; }
.panel {
  position: relative; text-align: center; width: 100%; max-width: 420px; max-height: 100%;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 26px;
  box-shadow: 0 8px 0 rgba(62, 42, 30, .4), 0 24px 60px rgba(0, 0, 0, .18);
  padding: 16px 22px 20px; animation: popIn .38s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes popIn { from { transform: scale(.82) translateY(14px); opacity: 0; } }
.title-panel { padding-top: 8px; background: rgba(255, 244, 224, .94); max-width: 460px; }
#mascot { width: 230px; height: 118px; display: block; margin: 0 auto -6px; }
h1.logo {
  margin: 0; font-size: clamp(36px, min(12vw, 10vh), 80px); line-height: 1.02; font-weight: 900; letter-spacing: 1px; color: var(--pink); white-space: nowrap;
  text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 2.2px 2.2px 0 var(--ink), -2.2px 2.2px 0 var(--ink), 2.2px -2.2px 0 var(--ink), -2.2px -2.2px 0 var(--ink), 0 7px 0 var(--ink);
}
html[lang="en"] h1.logo { font-size: clamp(34px, min(10vw, 9vh), 64px); }
.sub { margin: 12px 0 6px; font-size: 13px; font-weight: 900; letter-spacing: 5px; color: var(--mud); }
.pitch { text-wrap: balance; margin: 4px auto 12px; max-width: 330px; font-size: 15px; line-height: 1.45; font-weight: 600; }
.pitch b { color: var(--mud); font-weight: 900; }
h2 { margin: 2px 0 12px; font-size: 28px; font-weight: 900; }
p { margin: 6px 0; }
.hint { font-size: 13px; font-weight: 700; opacity: .72; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
button.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 60px; padding: 10px 28px;
  font-size: 22px; font-weight: 900; border-radius: 18px; border: 4px solid var(--ink);
  background: linear-gradient(#FFE27A, #FFC93C); box-shadow: 0 5px 0 var(--ink);
}
button.big svg { width: 22px; height: 22px; stroke: var(--ink); }
button.big.alt { background: var(--cream); }
button.mid { min-height: 50px; padding: 8px 18px; font-size: 17px; font-weight: 800; border-radius: 14px; border: 3px solid var(--ink); background: var(--cream2); box-shadow: 0 4px 0 rgba(62, 42, 30, .4); }
button.small { min-height: 44px; padding: 6px 16px; font-size: 15px; font-weight: 800; border-radius: 12px; border: 3px solid var(--ink); background: var(--cream2); box-shadow: 0 4px 0 rgba(62, 42, 30, .4); }
#btnPlay { min-width: 210px; font-size: 26px; min-height: 66px; animation: breathe 1.6s ease-in-out infinite; }
button.daily { position: relative; background: linear-gradient(#FFF6D6, #FFE7A0); }
.badge { position: absolute; top: -8px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; border: 2px solid var(--ink); background: #E5383B; color: #fff; font-size: 12px; font-style: normal; font-weight: 900; line-height: 14px; }
.badge.done { background: #5DBB3F; }
button.daily.loading { animation: pulse .8s ease-in-out infinite; cursor: progress; }
@keyframes breathe { 50% { transform: scale(1.045); } }

.rules { margin: -4px auto 12px; max-width: 360px; font-size: 14px; line-height: 1.45; font-weight: 600; text-wrap: balance; background: var(--cream2); border-radius: 14px; padding: 8px 12px; }
.rules b { color: var(--mud); font-weight: 900; }
.hats { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin-top: 2px; }
/* 일시정지: 기본은 한 줄로 쌓기(래퍼는 display:contents 로 풀고 order 로 순서), 낮은 가로 화면은 두 칸 */
.pause-panel { display: flex; flex-direction: column; align-items: stretch; }
.pause-panel .pleft, .pause-panel .pright { display: contents; }
.pause-panel h2 { order: 0; }
.pause-panel .rules { order: 1; }
.pause-panel #btnResume { order: 2; align-self: center; }
.pause-panel .col { order: 3; }
.pause-panel .hats { order: 4; margin-top: 12px; }
.hlabel { font-size: 14px; font-weight: 900; }
#hatRow { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.hatb { width: 48px; height: 48px; padding: 0; border-radius: 12px; border: 3px solid var(--ink); background: var(--cream2); box-shadow: 0 3px 0 rgba(62, 42, 30, .4); position: relative; }
.hatb canvas { width: 40px; height: 40px; display: block; margin: auto; }
.hatb.on { background: linear-gradient(#FFE27A, #FFC93C); border-width: 4px; }
.hatb.on::after { content: '✓'; position: absolute; top: -8px; right: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); color: var(--cream); font-size: 12px; font-weight: 900; line-height: 18px; }
.hatb small { position: absolute; left: 0; right: 0; bottom: 0; font-size: 12px; line-height: 1; font-weight: 900; color: var(--ink); text-shadow: 0 0 3px #fff; }
.newhat { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 0; font-size: 14px; font-weight: 900; color: #B5262A; animation: tipIn .5s; }
.newhat canvas { width: 40px; height: 40px; }
.newhat.next { color: var(--ink); font-size: 13px; font-weight: 800; opacity: .8; animation: none; }
.newhat.next canvas { width: 32px; height: 32px; }
.result-panel h2 { font-size: 32px; color: var(--ink); }
#resStars { display: flex; justify-content: center; gap: 10px; margin: -2px 0 6px; }
#resStars span { width: 58px; height: 58px; }
#resStars span:nth-child(2) { transform: translateY(-10px); width: 66px; height: 66px; }
#resStars span.pop { animation: starPop .45s cubic-bezier(.2, 1.6, .4, 1); }
#resStars span:nth-child(2).pop { animation-name: starPop2; }
@keyframes starPop { from { transform: scale(.2) rotate(-40deg); } }
@keyframes starPop2 { from { transform: translateY(-10px) scale(.2) rotate(-40deg); } }
#resTaps { font-size: 18px; font-weight: 900; }
#resBest .mini { color: #E0A800; letter-spacing: 1px; }
#resBest .mini i { color: #CDB99A; font-style: normal; }
#resBest em { font-style: normal; color: #D9363E; font-weight: 900; }
.result-panel .row { margin-top: 14px; flex-wrap: nowrap; }
.result-panel button.big { flex: 1; padding: 10px 10px; min-width: 0; }
button.big span { white-space: nowrap; }

.panel.wide { max-width: 760px; height: min(640px, 100%); display: flex; flex-direction: column; padding: 14px 14px 10px; }
.lhead { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 8px; }
.lhead h2 { margin: 0; white-space: nowrap; }
.lbtns { display: flex; gap: 8px; }
.lhead button { white-space: nowrap; }
@media (max-width: 420px) { .lhead h2 { font-size: 22px; } .lhead button.small { padding: 6px 10px; } }
#levelList { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 0 6px 8px; text-align: left; }
#levelList section h3 { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 2px 8px; font-size: 17px; font-weight: 900; }
#levelList section h3 small { font-size: 13px; opacity: .75; }
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.lv {
  position: relative; height: 58px; border-radius: 14px; border: 3px solid var(--ink); background: var(--cream2);
  box-shadow: 0 3px 0 rgba(62, 42, 30, .4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0;
}
.lv b { font-size: 19px; font-weight: 900; line-height: 1; }
.lv .st { font-size: 12px; color: #E0A800; letter-spacing: 0; }
.lv .st i { color: #C9B597; font-style: normal; }
.lv .lock { width: 14px; height: 14px; opacity: .55; stroke: var(--ink); }
.lv.cur { background: var(--pinkL); border-style: dashed; border-width: 4px; }
.lv.cur::before { content: '▶'; position: absolute; top: 3px; left: 5px; font-size: 12px; line-height: 1; }
.lv.gold { background: linear-gradient(#FFF1B8, #FFE27A); }
.lv.locked { opacity: .5; }

@media (max-height: 520px) {
  .panel { padding: 10px 18px 14px; }
  #mascot { width: 170px; height: 80px; margin-bottom: -4px; }
  html h1.logo { font-size: clamp(32px, 10vh, 54px); }
  .pitch { font-size: 13px; margin-bottom: 8px; }
  .sub { margin: 10px 0 4px; }
  button.big { min-height: 52px; font-size: 20px; }
  #btnPlay { min-height: 56px; font-size: 22px; }
  h2 { font-size: 24px; margin-bottom: 6px; }
  #resStars span { width: 46px; height: 46px; }
  #resStars span:nth-child(2) { width: 52px; height: 52px; }
  .row { margin-top: 6px; }
  .col { gap: 8px; margin-top: 8px; }
  button.mid { min-height: 44px; font-size: 15px; }
  .rules { font-size: 12px; padding: 5px 10px; margin-bottom: 6px; }
  .hatb { width: 44px; height: 44px; }
  .hatb canvas { width: 36px; height: 36px; }
}
@media (min-aspect-ratio: 6/5) and (max-height: 520px) {
  .pause-panel { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: 18px; max-width: 720px; align-items: center; }
  .pause-panel h2 { grid-column: 1 / -1; }
  .pause-panel .pleft, .pause-panel .pright { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
  .pause-panel .rules { margin: 0 0 10px; max-width: none; }
  .pause-panel .hats { margin-top: 0; }
  .pause-panel .col { margin-top: 10px; }
}
/* 세로 화면에서 도구가 없으면 무르기·다시·힌트를 가운데로 */
@media (max-aspect-ratio: 6/5) { #tools.hidden + #actions { margin-left: auto; margin-right: auto; } }

/* 홍보 커버 캡처 모드 (?cover=1|en): UI 숨기고 로고만 */
body.cover #ui, body.cover #tip, body.cover #toast, body.cover #title .corner { display: none !important; }
body.cover #title { background: none; align-items: flex-start; padding-top: 6vh; }
body.cover .title-panel { background: none; border: 0; box-shadow: none; animation: none; max-width: none; width: 100%; }
body.cover .title-panel > :not(h1):not(.sub) { display: none; }
body.cover h1.logo { font-size: min(12vw, 15vh); white-space: nowrap; text-align: center; }

/* ---------------- 2단계: 설정 모서리·마라톤·바구니·코치·전환 ---------------- */
#title .corner { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 1; }
.ib.sm { width: 44px; height: 44px; box-shadow: 0 3px 0 rgba(62, 42, 30, .35); }
.ib.sm svg { width: 22px; height: 22px; }
.ib.lang { font-size: 15px; font-weight: 900; }
.row.modes { gap: 8px; }
.row.modes button.small { padding: 6px 12px; }
button.marathon { position: relative; display: inline-flex; align-items: center; gap: 6px; background: linear-gradient(#FFE9D2, #FFC79A); }
button.marathon .lock { display: none; width: 16px; height: 16px; stroke: var(--ink); }
button.marathon.locked { background: var(--cream2); border-style: dashed; }
button.marathon.locked .lock { display: inline-block; }
button.marathon.locked span { opacity: .75; }
button.marathon.loading { animation: pulse .8s ease-in-out infinite; cursor: progress; }
.badge.new { min-width: 0; width: auto; padding: 0 5px; background: #E5383B; color: #fff; font-size: 12px; line-height: 14px; }
button.shake { animation: shakeX .4s; }
@keyframes shakeX { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* 마라톤 바구니 (사과 수) */
#basket { position: relative; display: flex; align-items: center; gap: 4px; padding: 0 4px; }
#basket canvas { width: 28px; height: 28px; display: block; }
#basketN { display: inline-block; font-size: 26px; font-weight: 900; line-height: 1; min-width: 1.2em; text-align: left; }
#basket.bump #basketN { animation: bump .3s ease-out; }
#basket.gain #basketN { animation: gain .5s ease-out; }
@keyframes gain { 30% { transform: scale(1.45); color: #2E8B2E; } }
#basket.low #basketN { color: #C42A2A; }
#basket.low { animation: lowShake 1.2s ease-in-out infinite; }
@keyframes lowShake { 0%, 70%, 100% { transform: none; } 75%, 85%, 95% { transform: translateX(-2px); } 80%, 90% { transform: translateX(2px); } }
#basketWarn { position: absolute; top: -10px; right: -12px; width: 20px; height: 20px; border-radius: 50%; background: #E5383B; color: #fff; border: 2px solid var(--ink); font-style: normal; font-weight: 900; font-size: 13px; line-height: 16px; text-align: center; }
#lvlBox.marathon #chProg { display: none !important; }
.act .cost { position: absolute; top: -9px; right: -9px; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 12px; background: #E5383B; color: #fff; border: 2px solid var(--ink); font-style: normal; font-size: 12px; font-weight: 900; display: grid; place-items: center; }

/* 일시정지 버튼 줄 */
.row2 { display: flex; gap: 10px; }
.row2 > button { flex: 1; min-width: 0; padding-left: 10px; padding-right: 10px; }
.row2 button.marathon { justify-content: center; }
.row3 { display: flex; gap: 8px; justify-content: center; }
.row3 > button { flex: 1; min-width: 0; padding-left: 8px; padding-right: 8px; white-space: nowrap; }

/* 첫 실행 안내(코치): 판 팁보다 밝게 + 느낌표 원 (색만으로 구분하지 않게 모양도 다름) */
#tip.coach { background: var(--cream); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 4px 0 rgba(62, 42, 30, .35); gap: 8px; }
#tip.coach::before { content: '!'; flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--star); border: 2px solid var(--ink); font-size: 14px; line-height: 19px; font-weight: 900; text-align: center; }
#tip.pop { animation: coachIn .45s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes coachIn { from { opacity: 0; transform: translate(-50%, -100%) scale(.7); } }

/* 레벨 선택: 장 문턱 */
#levelList .gate { display: flex; align-items: center; gap: 6px; margin: -4px 2px 8px; font-size: 14px; font-weight: 800; color: #8A3B12; }
#levelList .gate .lock { width: 16px; height: 16px; stroke: currentColor; fill: currentColor; }
#levelList section h3 small { white-space: nowrap; }

/* 마라톤 끝 결과 */
#result.mover h2 { color: #B5262A; }
#result.mover #resTaps { font-size: 24px; }

/* 판 전환: 진흙색 원이 화면을 덮었다 걷힘 (가운데 돼지 코) */
#wipe { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, #B07A47 0, #8B5A2B 45%, #6B4220 100%); clip-path: circle(0 at 50% 50%); }
#wipe svg { width: min(22vmin, 140px); height: auto; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .25)); }

/* 새 모자 축하: 흔들흔들 */
.newhat:not(.next) canvas { animation: hatWiggle 1s ease-in-out .9s 2; }
@keyframes hatWiggle { 25% { transform: rotate(-12deg) scale(1.15); } 75% { transform: rotate(12deg) scale(1.15); } }

/* 움직임 줄이기 */
@media (prefers-reduced-motion: reduce) {
  .pulse, #btnPlay, #basket.low, button.daily.loading, button.marathon.loading { animation: none !important; }
  .pulse { outline: 4px solid var(--star); outline-offset: 2px; }
  .panel, #tip.pop, #toast.pop { animation-duration: .01s !important; }
}
.newhat.unlock { color: #8A3B12; font-size: 14px; }
.newhat.unlock svg { width: 22px; height: 22px; fill: var(--star); stroke: var(--ink); stroke-width: 1.6; flex: none; }
@media (max-height: 420px) {
  .result-panel { padding-top: 8px; padding-bottom: 10px; }
  .result-panel h2 { margin-bottom: 2px; }
  .result-panel p { margin: 3px 0; }
  .newhat { margin: 2px 0 0; }
  .newhat canvas { width: 32px; height: 32px; }
  .result-panel .row { margin-top: 8px; }
}
