/* 앵~ 찰싹! (Bzz… Slap! / 嗡~啪!) — Matte Gouache Picture-Book UI */
:root {
  --ink: #3a2418;
  --ink-soft: #6a4a35;
  --cream: #fff8ea;
  --parchment: #f4e4c5;
  --bg-page: #ead7b7;
  --coral: #e85d3f;
  --coral-dark: #c44327;
  --gold: #f5bd41;
  --gold-soft: #ffe596;
  --celadon: #7eb59b;
  --ad-bg: #dfd0b6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "PingFang SC", "Noto Sans KR", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
  -webkit-user-drag: none;
}

button,
a {
  font-family: inherit;
  color: inherit;
}

.is-hidden {
  display: none !important;
}

/* Fixed 3-zone portrait shell (APP_SPEC_KO.md Section 3) */
#app-shell {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Zone 1: Top bar */
#top-bar {
  flex: 0 0 54px;
  height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 46px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.hud-pill-left {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ink);
  max-height: 40px;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.hud-pill-center {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 5px 11px;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.combo-tag {
  background: var(--coral);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  padding: 1px 7px;
  border-radius: 8px;
}

.gear-btn {
  width: 46px;
  height: 46px;
  padding: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gear-btn img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.gear-btn:active {
  transform: scale(0.94);
}

/* Zone 2: Main Play Board (leaves generous gap above Ad Slot) */
#board-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  margin: 2px 12px 18px 12px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--parchment);
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Shared button styles — strictly >= 44px height */
.btn-primary,
.btn-secondary,
.btn-chip {
  min-height: 46px;
  min-width: 46px;
  padding: 8px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.btn-primary {
  background: var(--coral);
  color: #fffdf8;
}

.btn-secondary {
  background: var(--cream);
  color: var(--ink);
}

.btn-chip {
  background: var(--gold-soft);
  color: var(--ink);
}

.btn-primary:active,
.btn-secondary:active,
.btn-chip:active {
  transform: translateY(1px);
}

/* Screen 1: Title Screen (all controls in upper-middle, far above bottom/ad) */
#screen-title {
  cursor: pointer;
}

.full-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
}

.title-overlay {
  position: relative;
  z-index: 2;
  padding: 12px 14px 0 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.title-logo-wrap {
  width: 92%;
  max-width: 320px;
  height: 138px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#title-logo-img {
  max-width: 100%;
  max-height: 138px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.stamp-enter {
  animation: titleStamp 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.18) both;
}

@keyframes titleStamp {
  0% {
    opacity: 0;
    transform: scale(1.48) rotate(-3deg);
  }
  70% {
    opacity: 1;
    transform: scale(0.95) rotate(0.5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.title-prompt-card {
  background: rgba(255, 248, 234, 0.95);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 14px;
  text-align: center;
  max-width: 100%;
}

.title-prompt-main {
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
}

.title-prompt-sub {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
}

.title-btn-row {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 300px;
  justify-content: center;
}

.title-btn-row > button {
  flex: 1 1 0;
}

/* Screen 2: Safety Guide Screen (compact upper-middle layout) */
#screen-guide {
  background: var(--parchment);
  padding: 12px 12px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.guide-header-banner {
  background: var(--gold-soft);
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.guide-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.guide-card {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.guide-card img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  border-radius: 10px;
}

.guide-card-title {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 900;
  color: var(--coral-dark);
}

.guide-card-body {
  margin-top: 3px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.28;
  overflow-wrap: anywhere;
  color: var(--ink);
}

#btn-guide-start {
  width: 100%;
  max-width: 310px;
}

/* Screen 3: Play Screen (strictly <= 4 HUD elements total, locked camera plates) */
#screen-play {
  background: #2b1d14;
  cursor: pointer;
}

#plate-stack {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mission-plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0;
  pointer-events: none;
}

.mission-plate.is-active {
  opacity: 1;
}

.play-cue-banner {
  background: rgba(255, 248, 234, 0.95);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 12px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.22;
  color: var(--ink);
  pointer-events: none;
  overflow-wrap: anywhere;
}

.play-cue-banner.is-urgent {
  background: var(--gold-soft);
  color: var(--coral-dark);
  font-size: 23px;
}

/* Cue banner + (mission 5) aim track share one column so a 2-line cue never overlaps the aim bar */
#play-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* Mission 5 Golden Aim Track (uses ui-aim-gem.webp) */
.aim-track-wrap {
  position: relative;
  margin: 0 10%;
  height: 40px;
  flex: 0 0 40px;
  background: rgba(58, 36, 24, 0.82);
  border: 2.5px solid var(--cream);
  border-radius: 20px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aim-sweet-zone {
  width: 34%;
  height: 100%;
  background: rgba(245, 189, 65, 0.38);
  border-left: 2px dashed var(--gold);
  border-right: 2px dashed var(--gold);
}

#m5-aim-gem {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  object-fit: contain;
}

/* Board Shake animations */
.shake-weak {
  animation: boardShakeWeak 0.14s ease-out;
}

.shake-strong {
  animation: boardShakeStrong 0.2s ease-out;
}

@keyframes boardShakeWeak {
  0% { transform: translate(0, 0); }
  30% { transform: translate(-3px, 3px); }
  65% { transform: translate(3px, -2px); }
  100% { transform: translate(0, 0); }
}

@keyframes boardShakeStrong {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 6px); }
  45% { transform: translate(7px, -5px); }
  70% { transform: translate(-4px, 3px); }
  100% { transform: translate(0, 0); }
}

/* Screen 4: Mission End Screen (buttons strictly in upper-middle of board) */
#screen-end {
  background: var(--parchment);
  padding: 12px 14px 0 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.end-title-banner {
  font-size: 22px;
  font-weight: 900;
  color: var(--coral-dark);
  text-align: center;
}

.end-btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 330px;
  justify-content: center;
}

.end-btn-row > button {
  flex: 1 1 0;
  padding: 8px 6px;
  font-size: 16px;
}

.end-score-box {
  width: 100%;
  max-width: 330px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: center;
}

.score-stat-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink-soft);
}

.score-stat-val {
  font-size: 24px;
  font-weight: 900;
  color: var(--ink);
}

.end-specimen-card {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 240px;
}

.end-specimen-badge {
  font-size: 16px;
  text-align: center;
  font-weight: 900;
  color: var(--coral-dark);
  margin-bottom: 4px;
}

#end-specimen-img {
  width: 126px;
  height: 126px;
  object-fit: contain;
  border-radius: 10px;
}

#end-specimen-name {
  margin-top: 5px;
  font-size: 16px;
  text-align: center;
  font-weight: 900;
  color: var(--ink);
}

/* Screen 5: Specimen Collection (Album) — compact 2x4 grid well above bottom */
#screen-album {
  background: var(--parchment);
  padding: 10px 10px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.album-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.album-hint-text {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink-soft);
  text-align: right;
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.album-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 7px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 470px;
}

.album-slot-btn {
  min-height: 0;
  height: 100%;
  padding: 5px 8px;
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 13px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-areas:
    "img best"
    "title title"
    "sub sub";
  grid-template-rows: auto auto auto;
  align-content: center;
  align-items: center;
  row-gap: 2px;
  column-gap: 6px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.album-slot-btn:active {
  transform: scale(0.98);
}

.album-slot-btn img {
  grid-area: img;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
}

/* title / sub / best become direct grid items of the slot button */
.album-slot-meta {
  display: contents;
}

.album-slot-title,
.album-slot-sub,
.album-slot-best {
  font-size: 16px;
  line-height: 1.14;
  overflow-wrap: break-word;
  min-width: 0;
}

.album-slot-title {
  grid-area: title;
  font-weight: 900;
  color: var(--ink);
}

.album-slot-sub {
  grid-area: sub;
  font-weight: 700;
  color: var(--ink-soft);
}

.album-slot-best {
  grid-area: best;
  justify-self: end;
  text-align: right;
  font-weight: 900;
  color: var(--coral-dark);
}

/* Settings Modal (inside #board-stage, anchored near top so bottom stays clear) */
#modal-settings {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(42, 26, 16, 0.58);
  padding: 10px 10px 0 10px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.settings-card {
  width: 100%;
  max-width: 340px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-title {
  font-size: 20px;
  font-weight: 900;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.settings-label {
  font-size: 16px;
  font-weight: 800;
}

.toggle-btn {
  min-width: 82px;
  min-height: 44px;
  padding: 6px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  background: var(--parchment);
  color: var(--ink-soft);
}

.toggle-btn.is-on {
  background: var(--celadon);
  color: #1d2d24;
}

.lang-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.lang-btn {
  min-height: 44px;
  padding: 6px 4px;
  border: 2.5px solid var(--ink);
  border-radius: 11px;
  background: var(--parchment);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.lang-btn.is-selected {
  background: var(--gold);
  color: var(--ink);
}

.settings-actions-row {
  display: flex;
  gap: 6px;
}

.settings-actions-row > * {
  flex: 1 1 0;
  min-height: 46px;
  font-size: 16px;
  padding: 6px 8px;
}

.settings-links-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.settings-link {
  min-height: 44px;
  padding: 6px 6px;
  border: 2px solid var(--ink-soft);
  border-radius: 10px;
  background: var(--parchment);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.settings-ad-row {
  display: grid;
  grid-template-columns: 1fr;
}

/* Zone 3: Fixed 320x50 Banner Ad Placeholder (never moves across screens) */
#ad-slot-wrap {
  flex: 0 0 56px;
  height: 56px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#ad-slot {
  width: 320px;
  height: 50px;
  flex: 0 0 320px;
  border: 2px dashed var(--ink-soft);
  border-radius: 8px;
  background: var(--ad-bg);
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Inside the iPhone app the real banner covers the slot, so the placeholder box & wording are hidden
   (clean empty background stays until an ad has loaded). In a browser the placeholder is shown as before. */
.in-app #ad-slot {
  color: transparent;
  background: transparent;
  border-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ORDER-05: all navigation stays in the upper board, with a reserved lower gap. */
.title-logo-wrap {height:100px;}
#title-logo-img {max-height:100px;}
.title-flick {width:72px;height:72px;object-fit:contain;border-radius:12px;animation:wrist-demo 2s ease-in-out infinite;}
@keyframes wrist-demo {0%,40%,100%{transform:rotate(0deg) translateY(0)}60%{transform:rotate(18deg) translateY(7px)}}
.title-menu {display:grid;grid-template-columns:1fr 1fr;gap:7px;width:100%;max-width:340px;}
#title-stars {font-weight:900;color:var(--coral-dark);}
#unlock-hint {font-size:16px;line-height:1.3;text-align:center;max-width:340px;}
button:disabled {opacity:.65;cursor:default;}
#coach {position:absolute;top:100px;left:12px;right:12px;z-index:5;pointer-events:none;background:rgba(255,248,234,.95);border:3px solid var(--ink);border-radius:16px;padding:10px;text-align:center;}
#coach img {display:inline-block;width:65px;height:65px;object-fit:contain;border-radius:10px;margin:0 6px;}
#coach p {margin:5px 0;font-size:16px;font-weight:800;line-height:1.35;}
#mode-cue {position:absolute;bottom:16%;left:10px;right:10px;text-align:center;pointer-events:none;font-weight:900;background:var(--cream);border-radius:12px;}
#mode-cue:empty {display:none;}
#end-stars {font-size:40px;color:#a56606;letter-spacing:5px;line-height:1.2;}
.new-stars {animation:star-pop .65s ease-out;}
@keyframes star-pop {0% {transform:scale(.5);opacity:.3}70%{transform:scale(1.2)}100%{transform:scale(1);opacity:1}}
#end-mode {font-weight:800;text-align:center;font-size:16px;}
#screen-challenge {background:var(--parchment);padding:16px;}
#screen-challenge p {background:var(--cream);border:2px solid var(--ink);border-radius:14px;padding:16px;line-height:1.5;font-weight:800;}
#screen-challenge h1 {font-size:26px;}
.album-grid {grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:none;grid-auto-rows:minmax(144px,auto);overflow-y:auto;align-content:start;max-height:calc(100% - 140px);padding:3px 3px 12px;}
.album-slot-btn {display:flex;flex-direction:column;justify-content:flex-start;gap:4px;min-height:144px;padding:7px 4px;text-align:center;border-width:4px;}
.album-slot-btn img {width:48px;height:48px;flex-shrink:0;}
.album-slot-title,.album-slot-sub {font-size:15px;line-height:1.22;}
.tier-1 {border-color:#a46c42;}.tier-2 {border-color:#8695a4;}.tier-3 {border-color:#d39918;}
.locked {border-style:dashed;background:#e9ddca;}
@media(max-height:740px) {
 .title-overlay {padding-top:5px;gap:5px;}
 .title-logo-wrap,#title-logo-img {height:64px;max-height:64px;}
 .title-flick {width:45px;height:45px;}
 .title-prompt-card {padding:5px 8px;}
 .title-prompt-main,.title-prompt-sub {font-size:16px;}
 .title-menu .btn-secondary,.title-menu .btn-chip {font-size:15px;padding:5px;}
 #unlock-hint {font-size:16px;}
 #end-stars {font-size:32px;}
 #end-specimen-img {width:85px;height:85px;}
}

@media(max-height:740px) { .title-flick{position:absolute;right:8px;top:5px;width:42px;height:42px;} .title-prompt-sub{display:none;} .title-menu{gap:5px;} .title-overlay{gap:4px;} .title-logo-wrap,#title-logo-img{height:55px;max-height:55px;} #unlock-hint{line-height:1.15;} }

#fast-missions {display:grid;grid-template-columns:1fr 1fr;gap:8px;}
#fast-missions:empty {display:none;}
#fast-missions button {min-height:60px;}
#challenge-record:empty {display:none;}

/* ORDER-05B: readable menus and two text lines per specimen slot. */
.title-menu-card {
 width:100%;max-width:364px;padding:10px;display:flex;flex-direction:column;
 align-items:center;gap:7px;background:rgba(255,248,234,.92);
 border:2px solid var(--ink-soft);border-radius:16px;
}
.title-menu-card .title-btn-row,.title-menu-card .title-menu {max-width:none;}
.title-menu button {min-width:0;overflow-wrap:anywhere;}
.title-menu button:disabled {opacity:1;color:var(--ink-soft);background:#eee1cb;}
.title-menu button:disabled::before {
 content:'';display:inline-block;width:20px;height:20px;margin-right:3px;
 vertical-align:middle;background:url('../assets/ui-locked.webp') center/contain no-repeat;
}
#screen-challenge {padding:10px;overflow-y:auto;padding-bottom:70px;}
#screen-challenge h1 {margin:14px 0 8px;}
#screen-challenge p {margin:8px 0;padding:12px;}
#challenge-specimen {display:block;width:min(65%,240px);height:auto;aspect-ratio:1;object-fit:contain;margin:12px auto;}
#screen-challenge #challenge-modifier {text-align:center;}
.album-grid {grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr));grid-auto-rows:144px;}
.album-slot-btn {min-width:0;width:100%;height:144px;}
.album-slot-title,.album-slot-sub {
 flex:0 0 auto;width:100%;max-width:100%;white-space:nowrap;
 overflow-wrap:normal;
 font-size:15px;line-height:1.4;
}

@media(max-height:740px) {
 .title-menu-card {padding:6px;gap:5px;}
 #challenge-specimen {width:min(45%,180px);margin:8px auto;}
}
