* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: #f5f4ef; color: #2b2b2b; user-select: none; -webkit-user-select: none;
  display: flex; flex-direction: column;
}

/* 상단바 */
#topbar {
  height: 46px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; padding-top: env(safe-area-inset-top);
  background: #ffffff; border-bottom: 1px solid #e6e5df; z-index: 5;
}
#topbar .back { color: #2c7be5; text-decoration: none; font-size: 14px; font-weight: 600; }
#topbar .brand { font-weight: 800; font-size: 16px; letter-spacing: -.01em; display: flex; align-items: center; gap: 5px; }
#topbar .brand .ic { font-size: 18px; }
#topbar .spacer { flex: 1; }
#topbar .hs { font-size: 12px; color: #8a8a86; }
#topbar .hs b { color: #1aa564; font-size: 15px; }

/* 무대 */
#stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#game { display: block; touch-action: none; }

/* 오버레이 */
.ov {
  position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(245, 244, 239, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ov.hidden { display: none; }
.ovcard {
  width: 100%; max-width: 400px; max-height: 88vh; overflow: auto;
  background: #fff; border: 1px solid #e6e5df; border-radius: 22px;
  padding: 26px 22px; text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, .18);
}
.ovcard h1 { font-size: 30px; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.ovcard h1 .sub2 { display: block; font-size: 15px; font-weight: 700; color: #2c7be5; letter-spacing: 6px; margin-top: 8px; }
.ovcard h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.lead { font-size: 14px; line-height: 1.6; color: #595955; margin: 14px 0 18px; text-align: left; }
.lead b { color: #2b2b2b; }

.ovbtns { display: flex; gap: 10px; justify-content: center; }
button { font-family: inherit; cursor: pointer; }
.primary {
  background: #2c7be5; color: #fff; border: 0; border-radius: 13px;
  padding: 13px 26px; font-size: 16px; font-weight: 800; transition: transform .12s, background .2s;
}
.primary:active { transform: scale(.96); }
.link { display: block; margin: 14px auto 0; background: none; border: 0; color: #8a8a86; font-size: 13px; text-decoration: underline; }

.rules { text-align: left; list-style: none; display: flex; flex-direction: column; gap: 9px; margin: 6px 0 18px; }
.rules li { font-size: 13.5px; line-height: 1.5; color: #555; padding-left: 4px; }
.rules b { color: #2b2b2b; }

/* 업그레이드 */
.upopts { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.upcard {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: #faf9f5; border: 2px solid #e6e5df; border-radius: 15px; padding: 14px 16px; transition: border-color .15s, transform .1s;
}
.upcard:active { transform: scale(.98); }
.upcard:hover { border-color: #2c7be5; }
.upcard .upic { font-size: 26px; }
.upcard b { font-size: 16px; font-weight: 800; }
.upcard small { font-size: 12.5px; color: #8a8a86; }

/* 게임오버 통계 */
.overstats { display: flex; justify-content: center; gap: 14px; margin: 18px 0 8px; }
.overstats > div { flex: 1; background: #faf9f5; border: 1px solid #e6e5df; border-radius: 14px; padding: 14px 6px; }
.overstats span { display: block; font-size: 26px; font-weight: 900; color: #2c7be5; }
.overstats small { font-size: 11px; color: #8a8a86; }
.bestline { font-size: 14px; color: #1aa564; font-weight: 700; margin: 6px 0 16px; min-height: 18px; }
