* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #322d29;
  --paper: #fffaf0;
  --yellow: #ffd45d;
  --orange: #f47b50;
  --green: #4c9a73;
  --blue: #4e83b8;
  --red: #cf4e4e;
}
html, body {
  width: 100%; height: 100%; overflow: hidden; background: var(--paper);
  font-family: "Comic Sans MS", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
button, select { font-family: inherit; }
#viewport { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--paper); }
#viewport[data-screen='screen-title'] { background: #ffe29a; }
#viewport[data-screen='screen-select'] { background: linear-gradient(#ffe9a8, #ffd781); }
#viewport[data-screen='screen-hard-list'] { background: linear-gradient(#3a2e27, #211b18); }
#viewport[data-screen='screen-hard'] {
  background: linear-gradient(var(--ink), var(--ink)) top / 100% env(safe-area-inset-top, 0px) no-repeat var(--paper);
}
#play-area {
  position: absolute; inset: 0;
  inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
#stage {
  --extra-height: calc(var(--stage-height, 1280px) - 1280px);
  position: absolute; left: 50%; top: 50%; width: 720px; height: var(--stage-height, 1280px);
  overflow: hidden; background: var(--paper);
  transform: translate(-50%, -50%) scale(var(--stage-scale, 1));
  transform-origin: center center; user-select: none;
}
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; }

#screen-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; padding: 65px; background: var(--paper); color: var(--ink); text-align: center;
}
#loading-title { font-size: 38px; line-height: 1.5; overflow-wrap: anywhere; }
#loading-progress { font-size: 26px; line-height: 1.6; min-height: 42px; }
#screen-loading .big-btn { margin-top: 0; }
.loading-mark {
  width: 68px; height: 68px; border: 7px solid #efdfba; border-top-color: var(--orange);
  border-radius: 50%; animation: loadingTurn 1s linear infinite;
}
#screen-loading[data-phase="error"] .loading-mark { animation: none; border-color: var(--orange); }
@keyframes loadingTurn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-mark { animation: none; } }

/* 타이틀 */
#screen-title {
  display: flex; flex-direction: column; align-items: center; padding-top: calc(94px + var(--extra-height) / 3);
  background: radial-gradient(circle at 50% 35%, #fff7c7 0 24%, transparent 56%), #ffe29a;
}
.language-switch {
  position: absolute; z-index: 5; top: 24px; right: 24px; display: flex; gap: 6px;
  padding: 5px; border: 3px solid var(--ink); border-radius: 999px; background: rgba(255,255,255,.82);
}
.language-switch button {
  padding: 7px 13px; border: 0; border-radius: 999px; background: transparent; color: #6d5c42;
  font-size: 19px; font-weight: 900; cursor: pointer;
}
.language-switch button.active { background: var(--ink); color: #fff; }
.language-switch .sound-toggle {
  min-width: 43px; padding-inline: 8px; background: #fff6cf; color: var(--ink);
}
.language-switch select {
  max-width: 290px; padding: 7px 12px; border: 0; border-radius: 999px;
  background: var(--paper); color: var(--ink); font-size: 21px; font-weight: 800;
  cursor: pointer;
}
.language-switch select:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.sound-toggle[aria-pressed="false"] { background: #e6e3dc !important; color: #766e68 !important; }
.game-title {
  position: relative; z-index: 2; max-width: 650px; color: var(--ink); text-align: center; font-size: 88px; line-height: 1.1;
  letter-spacing: -5px; transform: rotate(-3deg); text-shadow: 4px 4px 0 #fff, 7px 7px 0 #efa13c;
}
html[lang="en"] .game-title { font-size: 96px; line-height: 1.02; letter-spacing: -3px; }
html[lang="en"] .stage-mini { font-size: 15px; word-break: normal; }
html[lang="en"] #puzzle-story,
html[lang="en"] #puzzle-objective,
html[lang="en"] #puzzle-rules { word-break: normal; }
html:not([lang="ko"]):not([lang="en"]) .game-title { font-size: 72px; line-height: 1.18; letter-spacing: -1px; }
html[lang="hi"] .game-title, html[lang="ar"] .game-title { letter-spacing: 0; line-height: 1.35; font-size: 68px; }
html[lang="hi"] body, html[lang="ar"] body { font-family: system-ui, sans-serif; }
html:not([lang="ko"]) .stage-mini { font-size: 15px; word-break: normal; overflow-wrap: anywhere; }
#title-sub {
  z-index: 2; margin-top: 24px; padding: 10px 24px; border: 4px solid var(--ink); border-radius: 999px;
  color: var(--ink); background: #fff; font-size: 28px; font-weight: 800; transform: rotate(1deg);
}
.truth-revealed #title-sub { color: #fff; background: var(--red); }
#title-boy { width: 290px; margin-top: 14px; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-14px) rotate(1deg); } }
.credit { position: absolute; bottom: 20px; color: #937843; font-size: 20px; }
#btn-privacy { position: absolute; bottom: 100px; font-size: 22px; }
.big-btn {
  margin-top: 30px; padding: 19px 64px; border: 5px solid var(--ink); border-radius: 22px;
  background: var(--orange); color: #fff; box-shadow: 0 8px 0 #b94e2c; font-size: 38px; font-weight: 900;
  cursor: pointer;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #b94e2c; }
.small-btn {
  padding: 10px 22px; border: 4px solid var(--ink); border-radius: 15px; background: #fff;
  color: var(--ink); box-shadow: 0 5px 0 #bbb; font-size: 25px; font-weight: 800; cursor: pointer;
}
.small-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #bbb; }

/* 선택 화면 */
#screen-select {
  display: flex; flex-direction: column; align-items: center; padding-top: 38px;
  background: linear-gradient(#ffe9a8, #ffd781);
}
.select-title { color: var(--ink); font-size: 48px; transform: rotate(-2deg); }
#select-legend { margin: -6px 0 12px; color: #7a6544; font-size: 19px; font-weight: 800; }
#select-progress {
  margin: 7px 0 14px; padding: 7px 20px; border-radius: 999px; background: rgba(255,255,255,.72);
  color: #6d5c42; font-size: 22px; font-weight: 800;
}
#stage-grid {
  display: grid;
  grid-template-columns: repeat(5, 116px);
  gap: 13px;
  max-height: 1050px;
  padding: 8px 14px 38px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ad8752 transparent;
}
.stage-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 116px; height: 142px; padding: 6px; border: 4px solid var(--ink); border-radius: 20px;
  background: #fff; color: var(--ink); box-shadow: 0 6px 0 #c8ad72; cursor: pointer;
}
.stage-cell.map-stage-cell { width: 180px; height: 190px; padding: 12px; }
.stage-cell.map-stage-cell .stage-number { font-size: 43px; }
.stage-cell.map-stage-cell .stage-mini { margin-top: 12px; font-size: 21px; line-height: 1.18; }
.stage-cell.capture-day { background: #f3f7ff; border-color: #365b7f; }
.stage-cell.locked { background: #d9d5cd; color: #888; box-shadow: 0 6px 0 #aaa; cursor: default; }
.stage-number { font-size: 34px; font-weight: 900; line-height: 1; }
.stage-mini { max-width: 100%; margin-top: 8px; font-size: 17px; line-height: 1.12; font-weight: 800; word-break: keep-all; }
.stage-cell.cleared::after {
  content: "✓"; position: absolute; right: 6px; top: 3px; width: 25px; height: 25px; border-radius: 50%;
  background: var(--green); color: #fff; font-size: 18px; line-height: 25px;
}
#btn-back-title { position: absolute; z-index: 3; bottom: 14px; right: 25px; }
#btn-album { position: absolute; z-index: 3; bottom: 14px; left: 25px; }
.stage-cell.no-hint::before { content: '★'; position: absolute; left: 7px; top: 3px; color: #a35b00; font-size: 21px; }

/* 게임 공통 */
#screen-game { background: var(--paper); }
#game-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: saturate(.65) brightness(1.1); opacity: .24; transform: scale(1.03);
}
#game-hud {
  position: absolute; z-index: 20; left: 0; right: 0; top: 0; height: 86px; padding: 14px 18px;
  display: flex; align-items: center; gap: 15px; background: rgba(255,250,240,.94); border-bottom: 4px solid var(--ink);
}
#game-hud .small-btn { width: 62px; height: 54px; padding: 0; font-size: 30px; }
#game-hud .sound-toggle { flex: 0 0 62px; font-size: 25px; }
#hud-stage { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink); font-size: 29px; font-weight: 900; }
#hud-mode {
  margin-left: auto; flex: 0 0 auto; padding: 7px 12px; border: 3px solid var(--ink); border-radius: 999px;
  background: var(--yellow); color: var(--ink); font-size: 19px; font-weight: 900;
}
#hud-mode.capture { background: #617ea2; color: #fff; }

#puzzle-shell {
  position: absolute; z-index: 5; left: 18px; right: 18px; top: 100px; bottom: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.puzzle-brief {
  flex: 0 0 auto; min-height: 255px; padding: 17px 21px 14px; border: 4px solid var(--ink); border-radius: 23px;
  background: rgba(255,255,255,.94); box-shadow: 0 6px 0 rgba(50,45,41,.17);
}
#puzzle-act { color: var(--red); font-size: 19px; font-weight: 900; letter-spacing: .4px; }
#puzzle-story { margin-top: 7px; color: var(--ink); font-size: 24px; line-height: 1.26; font-weight: 700; word-break: keep-all; }
#puzzle-objective {
  display: block; margin-top: 10px; padding: 8px 12px; border-left: 7px solid var(--orange);
  background: #fff1d6; color: #663c25; font-size: 23px; line-height: 1.22; word-break: keep-all;
}
#puzzle-rules { margin: 9px 0 0 28px; color: #554d48; font-size: 19px; line-height: 1.27; font-weight: 700; }
#puzzle-rules li + li { margin-top: 3px; }
.puzzle-toolbar { display: flex; align-items: center; min-height: 48px; gap: 10px; }
#move-counter {
  margin-right: auto; padding: 7px 13px; border-radius: 12px; background: var(--ink); color: #fff;
  font-size: 20px; font-weight: 900;
}
.tool-btn {
  padding: 7px 13px; border: 3px solid var(--ink); border-radius: 12px; background: #fff;
  color: var(--ink); font-size: 18px; font-weight: 900; box-shadow: 0 3px 0 #bbb; cursor: pointer;
}
.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #bbb; }
#btn-hint { background: var(--yellow); }

.puzzle-board {
  flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px;
}

/* 2D 맵 레벨링: 자유 좌표 대신 5×7 정수 타일만 사용한다. */
.puzzle-board.tile-map {
  --map-columns: 5;
  --map-rows: 7;
  flex: 1 1 auto;
  align-self: center;
  width: min(100%, 455px);
  max-height: 625px;
  aspect-ratio: var(--map-columns) / var(--map-rows);
  display: grid;
  grid-template-columns: repeat(var(--map-columns), minmax(0, 1fr));
  grid-template-rows: repeat(var(--map-rows), minmax(0, 1fr));
  gap: 5px;
  padding: 9px;
  border: 5px solid var(--ink);
  border-radius: 22px;
  background: #d4b278;
  box-shadow: 0 7px 0 rgba(50,45,41,.25), inset 0 0 0 4px rgba(255,255,255,.35);
}
.map-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(71,58,44,.45);
  border-radius: 9px;
  overflow: visible;
}
button.map-tile { padding: 0; font-family: inherit; cursor: pointer; }
.map-tile.floor {
  background: repeating-linear-gradient(135deg, #f9e3ae 0 8px, #f4d99d 8px 16px);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.36);
}
.map-tile.wall {
  background: repeating-linear-gradient(0deg, #755e4c 0 9px, #654d3f 9px 18px);
  border-color: #49382f;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.08);
}
.map-tile.placement-allowed::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 17px;
  height: 17px;
  margin: -8.5px;
  border-radius: 50%;
  background: #36a66d;
  box-shadow: 0 0 0 5px rgba(54,166,109,.22);
  animation: destinationPulse .7s ease-in-out infinite alternate;
}
.map-tile.vision {
  background: repeating-linear-gradient(135deg, #ffd2a5 0 8px, #f7a078 8px 16px);
  box-shadow: inset 0 0 0 3px rgba(206,55,55,.35);
}
.map-tile.caught-cell {
  z-index: 2;
  border-color: #a82020;
  background: #ff8c7d;
  box-shadow: 0 0 0 6px rgba(207,78,78,.38), inset 0 0 0 3px #fff;
  animation: caughtPulse .3s ease-in-out 4 alternate;
}
@keyframes caughtPulse { from { transform: scale(.92); } to { transform: scale(1.06); } }
.map-piece {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 90%;
  height: 90%;
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(255,255,255,.8));
}
.map-piece.marker { z-index: 2; opacity: .9; }
.map-piece.marker.switch { font-size: 30px; }
.map-piece.prop {
  z-index: 5;
  border: 3px solid #684f37;
  border-radius: 12px;
  background: rgba(255,250,225,.92);
  cursor: pointer;
}
.map-piece.prop.selected { border-color: #185a91; box-shadow: 0 0 0 4px #76b9ed; }
.map-piece.prop b,
.map-piece.npc b {
  position: absolute;
  right: -2px;
  top: -5px;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  color: var(--red);
  font-size: 18px;
  line-height: 1;
}
.map-piece.actor, .map-piece.npc { z-index: 7; }

#placement-tray {
  flex: 0 0 92px;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 7px 10px;
  border: 4px solid var(--ink);
  border-radius: 17px;
  background: rgba(255,255,255,.94);
}
.tray-prop {
  position: relative;
  min-width: 205px;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid #8e7e6e;
  border-radius: 14px;
  background: #fff8e8;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}
.tray-prop .tray-icon { font-size: 35px; }
.tray-prop em { color: var(--blue); font-size: 23px; font-style: normal; }
.tray-prop.selected { border-color: #185a91; background: #dcedff; box-shadow: 0 0 0 3px #78b8ee; }
.tray-prop.placed { opacity: .66; }
.puzzle-board.zones-5, .puzzle-board.zones-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: minmax(0, 2fr) minmax(0, 1.2fr);
}
.puzzle-zone {
  position: relative; min-height: 0; padding: 10px; overflow: hidden; border: 4px solid #83766e; border-radius: 20px;
  background: rgba(255,255,255,.91); box-shadow: inset 0 0 0 3px rgba(255,255,255,.7); cursor: default;
  transition: transform .12s, background .12s, border-color .12s;
}
.puzzle-zone.valid-destination {
  border-color: var(--green); background: #e9fff1; box-shadow: 0 0 0 5px rgba(76,154,115,.23), inset 0 0 0 3px #fff;
  cursor: pointer; animation: destinationPulse .8s ease-in-out infinite alternate;
}
.puzzle-zone.selection-source { border-color: var(--blue); }
@keyframes destinationPulse { from { transform: scale(.985); } to { transform: scale(1); } }
.zone-heading {
  display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px;
  border-bottom: 2px dashed #c5bbb2; color: var(--ink); font-size: 19px; text-align: center;
}
.zone-heading span { font-size: 26px; }
.zone-tokens {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 7px;
  padding-top: 9px; height: calc(100% - 39px); overflow-y: auto;
}
.puzzle-token {
  position: relative; min-width: 0; min-height: 78px; padding: 6px 4px; border: 3px solid var(--ink); border-radius: 15px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fff8e8; color: var(--ink); box-shadow: 0 4px 0 #b9aa94; cursor: pointer;
}
.puzzle-token:active { transform: translateY(2px); box-shadow: 0 2px 0 #b9aa94; }
.puzzle-token.selected {
  border-color: #154f80; background: #dcedff; box-shadow: 0 0 0 4px #78b8ee, 0 4px 0 #41739b;
  transform: translateY(-2px);
}
.puzzle-token.locked-token { border-style: dashed; background: #efefeb; opacity: .84; cursor: default; }
.token-icon { font-size: 36px; line-height: 1; }
.token-label { margin-top: 4px; max-width: 100%; overflow: hidden; color: var(--ink); font-size: 16px; line-height: 1.05; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.token-weight {
  position: absolute; right: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 14px; line-height: 22px; font-weight: 900;
}
.selection-bar {
  flex: 0 0 68px; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 4px solid var(--ink); border-radius: 17px; background: #fff;
}
#selection-label { flex: 1; min-width: 0; color: var(--ink); font-size: 17px; line-height: 1.15; font-weight: 900; }
.run-btn {
  flex: 0 0 auto;
  min-width: 137px;
  padding: 10px 13px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: var(--green);
  color: #fff;
  box-shadow: 0 4px 0 #2c694d;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}
.run-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #2c694d; }
.run-btn:disabled { opacity: .55; cursor: default; }

.board-message {
  position: absolute; z-index: 32; left: 50%; bottom: 91px; max-width: 600px; transform: translateX(-50%);
  padding: 12px 21px; border: 4px solid var(--ink); border-radius: 15px; background: #fff; color: var(--ink);
  box-shadow: 0 6px 0 rgba(0,0,0,.18); font-size: 21px; font-weight: 900; text-align: center;
}
.board-message.warn { background: #ffe2dc; border-color: var(--red); }
.board-message.move { background: #e3f4ff; border-color: var(--blue); }

/* 힌트와 결과 */
.mini-overlay, .overlay {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
}
.mini-overlay { background: rgba(30,25,20,.56); }
.hint-card {
  width: 610px; padding: 34px; border: 6px solid var(--ink); border-radius: 26px; background: #fff6ce;
  box-shadow: 0 12px 0 rgba(0,0,0,.25); text-align: center;
}
.hint-card h3 { color: var(--ink); font-size: 38px; transform: rotate(-2deg); }
#hint-panel-text { margin: 23px 0; color: #4b443f; font-size: 26px; line-height: 1.42; text-align: left; }
#hint-panel-text p + p { margin-top: 12px; }

.overlay { flex-direction: column; padding: 52px 35px; text-align: center; }
#overlay-fail { background: rgba(255,244,218,.97); }
#fail-mom { width: 370px; max-height: 410px; object-fit: contain; animation: failIn .45s cubic-bezier(.3,1.4,.6,1); }
#overlay-fail .overlay-text { color: #604630; font-size: 62px; text-shadow: 3px 3px 0 #efc992; }
#overlay-fail .overlay-sub { color: #604630; text-shadow: none; }
#overlay-fail .flash { display: none; }
#overlay-fail[data-kind='gentle'] #fail-mom,
#overlay-fail[data-kind='sleepy'] #fail-mom { animation: quietIn .4s ease-out; }
@keyframes quietIn { from { transform: translateY(25px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes failIn { from { transform: translateY(260px) scale(.4) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.overlay-text {
  margin-top: 10px; color: #fff; font-size: 75px; line-height: 1.06; font-weight: 900;
  text-shadow: 5px 5px 0 #a52d26; transform: rotate(-3deg); word-break: keep-all;
}
.overlay-text.good { text-shadow: 5px 5px 0 #db8f24; }
.overlay-sub {
  max-width: 630px; margin-top: 18px; color: #fff; font-size: 29px; line-height: 1.34;
  font-weight: 800; text-shadow: 2px 2px 0 rgba(0,0,0,.35); word-break: keep-all;
}
.fail-meta, .clear-stats {
  margin-top: 12px; padding: 8px 15px; border-radius: 11px; background: rgba(255,255,255,.9);
  color: #6b2b27; font-size: 19px; font-weight: 900;
}
#overlay-fail .big-btn { margin-top: 24px; }
#overlay-clear {
  justify-content: flex-start; padding-top: 170px; background: linear-gradient(rgba(255,207,75,.94), rgba(244,123,80,.94));
}
#overlay-clear .overlay-sub { max-width: 610px; font-size: 32px; }
.clear-stats { margin-top: 24px; color: var(--ink); background: #fff; font-size: 24px; line-height: 1.45; white-space: pre-line; text-align: center; }
#clear-next { max-width: 610px; margin-top: 26px; color: #fff; font-size: 26px; font-weight: 900; text-shadow: 2px 2px 0 rgba(0,0,0,.3); word-break: keep-all; text-align: center; }
.twist-title { max-width: 650px; font-size: 68px; color: #fff7a9; text-shadow: 5px 5px 0 #62213e !important; }
#overlay-clear .small-btn { margin-top: 18px; }

#overlay-final-choice { background: radial-gradient(circle, #fff6b8, #e5a864); }
.final-phone { font-size: 145px; animation: phoneFloat 1.2s ease-in-out infinite alternate; }
@keyframes phoneFloat { to { transform: translateY(-15px) rotate(5deg); } }
#overlay-final-choice .overlay-text { font-size: 68px; }
.final-actions { display: flex; gap: 20px; margin-top: 35px; }
.choice-btn {
  min-width: 278px; padding: 22px 17px; border: 5px solid var(--ink); border-radius: 20px;
  color: #fff; box-shadow: 0 7px 0 rgba(0,0,0,.28); font-size: 28px; font-weight: 900; cursor: pointer;
}
.phone-choice { background: #587aa1; }
.spoon-choice { background: var(--orange); }
.choice-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0,0,0,.28); }

#overlay-end { justify-content: center; gap: 34px; padding: 50px 30px; background: #fff3d7; }
#end-scene {
  width: 660px; height: 660px; flex: 0 0 auto; object-fit: contain; border-radius: 25px;
  animation: quietIn .65s ease-out;
}
.end-caption { width: 100%; color: #604630; }
#end-title { font-size: 48px; line-height: 1.2; }
#end-line { margin: 22px auto 35px; max-width: 620px; font-size: 29px; line-height: 1.45; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.end-actions .small-btn { max-width: 310px; white-space: normal; }

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

/* 30일 완성본: 두 방을 오가며 찾은 물건을 장면에 직접 쓰는 탈출 퍼즐. */
#screen-game { background: #f5dfad; }
#screen-game #game-bg {
  inset: 86px 0 185px;
  opacity: 1;
  filter: none;
  transform: none;
  background-size: cover;
  background-position: center;
}
#game-layer {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  /* The artwork covers the taller room while the puzzle keeps its authored coordinate space. */
  top: calc(86px + var(--extra-height) / 2);
  height: 1009px;
  overflow: hidden;
}
.scene-object {
  position: absolute;
  display: block;
  height: auto;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  transform-origin: 50% 80%;
  transition: left .42s cubic-bezier(.2,.85,.3,1), top .42s cubic-bezier(.2,.85,.3,1), transform .42s cubic-bezier(.2,.85,.3,1);
}
.scene-object img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 4px 2px rgba(56,39,20,.14));
}
.scene-object.interactive { cursor: pointer; touch-action: manipulation; }
.scene-object.interactive:active { filter: brightness(1.08); transform: scale(.97); }
.scene-object.interactive:focus-visible {
  border-radius: 18px;
  outline: 7px solid rgba(255,210,52,.9);
  outline-offset: 5px;
}
.scene-object.decorative { pointer-events: none; }
.scene-object[data-motion='teeter'] img { transform-origin: 50% 100%; animation: phoneTeeter 1.8s ease-in-out infinite; }
@keyframes phoneTeeter { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg); } }
.scene-object[data-motion='blink'] img { animation: phoneBlink 1.3s ease-in-out infinite; }
@keyframes phoneBlink { 0%, 100% { filter: drop-shadow(0 0 0 rgba(70, 160, 255, 0)); } 50% { filter: drop-shadow(0 0 16px rgba(70, 160, 255, .95)) drop-shadow(0 0 6px rgba(140, 210, 255, .9)); } }
.scene-object[data-motion='fan-running'] img { animation: fanRunning .18s ease-in-out infinite alternate; }
#game-layer .scene-object[data-motion='wind'] {
  border: 0; padding: 0; background: transparent; box-shadow: none; overflow: visible;
  transform: rotate(-12deg) !important; transform-origin: left center;
}
.scene-object[data-motion='wind']::before,
.scene-object[data-motion='wind']::after {
  content: ''; position: absolute; left: 0; width: 100%; height: 34px;
  border-top: 5px dashed #72a9cb; border-radius: 45%;
  animation: fanWind .8s linear infinite;
}
.scene-object[data-motion='wind']::before { top: 10px; }
.scene-object[data-motion='wind']::after { top: 54px; animation-delay: -.4s; width: 84%; }
@keyframes fanRunning { from { transform: translateX(-1px) rotate(-.3deg); } to { transform: translateX(1px) rotate(.3deg); } }
@keyframes fanWind { from { opacity: .3; translate: -8px 0; } to { opacity: .85; translate: 13px 0; } }
.scene-object.moving { transition-duration: .62s; }
.scene-object.shaking { animation: sceneShake .34s ease-in-out 2; }
@keyframes sceneShake {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -13px; transform: rotate(-3deg); }
  75% { margin-left: 13px; transform: rotate(3deg); }
}
.scene-object.phone-glow img {
  animation: phoneGlow .7s ease-in-out infinite alternate;
}
.scene-object[data-reaction] img { transform-origin: 50% 80%; }
.scene-object[data-reaction='peek'] img { animation: spritePeek .8s ease-out both; }
.scene-object[data-reaction='shiver'] img { animation: spriteShiver .16s ease-in-out 5; }
.scene-object[data-reaction='fumble'] img { animation: spriteFumble .3s ease-in-out 3; }
.scene-object[data-reaction='bounce'] img { animation: spriteBounce .65s ease-out; }
.scene-object[data-reaction='tumble'] img { animation: spriteTumble .7s ease-out; }
.scene-object[data-reaction='unfurl'] img { animation: spriteUnfurl .6s ease-out; }
.scene-object[data-reaction='slide'] img { animation: spriteSlide .6s ease-out; }
.scene-object[data-reaction='cozy'] img { animation: spriteCozy 1s ease-in-out; }
@keyframes spritePeek { from { transform: translateY(70px) rotate(-8deg); opacity: 0; } 70% { transform: translateY(-6px) rotate(3deg); } to { transform: none; opacity: 1; } }
@keyframes spriteShiver { 25% { transform: translateX(-4px) rotate(-1deg); } 75% { transform: translateX(4px) rotate(1deg); } }
@keyframes spriteFumble { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes spriteBounce { 25% { transform: translateY(-36px) scale(.97,1.05); } 60% { transform: scale(1.06,.94); } 80% { transform: translateY(-10px); } }
@keyframes spriteTumble { from { transform: translateY(-25px) rotate(-28deg); } 60% { transform: rotate(14deg); } to { transform: none; } }
@keyframes spriteUnfurl { from { transform: scale(.3,.1) rotate(-14deg); opacity: .2; } 65% { transform: scale(1.03,1.07); } to { transform: none; opacity: 1; } }
@keyframes spriteSlide { from { transform: translateX(65px) rotate(10deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spriteCozy { 45% { transform: translateY(-4px) rotate(2deg); filter: drop-shadow(0 0 12px rgba(245,183,78,.55)); } }
@keyframes phoneGlow {
  from { filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 8px #ffcb39); }
  to { filter: drop-shadow(0 0 13px #fff) drop-shadow(0 0 27px #ff7c31); transform: scale(1.08); }
}
#scene-title {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 99px;
  transform: translateX(-50%);
  padding: 8px 18px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  white-space: nowrap;
}
.scene-nav {
  direction: ltr;
  position: absolute;
  z-index: 17;
  top: calc(515px + var(--extra-height) / 2);
  width: 68px;
  height: 96px;
  border: 4px solid var(--ink);
  background: rgba(255,255,255,.88);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(50,45,41,.25);
  font-size: 65px;
  line-height: 72px;
  font-weight: 900;
  cursor: pointer;
}
.scene-nav.left { left: 0; border-left: 0; border-radius: 0 20px 20px 0; }
.scene-nav.right { right: 0; border-right: 0; border-radius: 20px 0 0 20px; }
.scene-nav:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(50,45,41,.25); }
.hint-fab {
  position: absolute;
  z-index: 17;
  top: 103px;
  right: 18px;
  padding: 9px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 4px 0 #bd9635;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}
#bubble {
  position: absolute;
  z-index: 23;
  left: 50%;
  bottom: 205px;
  width: min(620px, calc(100% - 80px));
  transform: translateX(-50%);
  padding: 17px 22px;
  border: 4px solid var(--ink);
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 7px 0 rgba(50,45,41,.24);
  font-size: 23px;
  line-height: 1.3;
  font-weight: 900;
  text-align: center;
  word-break: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}
#bubble.top { top: 168px; bottom: auto; }
#inventory-bar {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  height: 185px;
  padding: 12px 20px;
  border-top: 5px solid var(--ink);
  background: rgba(255,250,240,.97);
  box-shadow: 0 -7px 20px rgba(50,45,41,.16);
}
.inventory-heading {
  display: flex;
  align-items: baseline;
  gap: 14px;
  color: var(--ink);
}
.inventory-heading strong { font-size: 23px; }
.inventory-heading span { min-width: 0; color: #766a5f; font-size: 15px; font-weight: 800; }
.inventory-heading strong { flex-shrink: 0; }
#inventory-items {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  height: 125px;
}
.inventory-item {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  width: 184px;
  height: 102px;
  padding: 8px 12px;
  border: 4px solid var(--ink);
  border-radius: 17px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 #bfae94;
  font-size: 18px;
  font-weight: 900;
  cursor: grab;
  touch-action: none;
}
.inventory-item img { width: 68px; max-height: 82px; object-fit: contain; pointer-events: none; }
.inventory-item span { min-width: 0; line-height: 1.18; word-break: normal; overflow-wrap: anywhere; pointer-events: none; }
/* Text follows Arabic reading order; physical room coordinates and arrows stay fixed. */
html[dir="rtl"] #hud-stage,
html[dir="rtl"] #scene-title,
html[dir="rtl"] #bubble,
html[dir="rtl"] .overlay-sub { unicode-bidi: plaintext; }
.inventory-item.selected {
  border-color: #1d659c;
  background: #dff1ff;
  box-shadow: 0 0 0 5px rgba(74,150,207,.45), 0 5px 0 #6f9fbd;
  transform: translateY(-2px);
}
#inventory-empty {
  display: grid;
  place-items: center;
  height: 118px;
  color: #8d7c6b;
  font-size: 20px;
  font-weight: 800;
}
#drag-ghost {
  position: absolute;
  z-index: 80;
  width: 105px;
  height: 105px;
  margin: -53px 0 0 -53px;
  padding: 8px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: rgba(255,255,255,.93);
  box-shadow: 0 9px 20px rgba(0,0,0,.25);
  pointer-events: none;
}
#drag-ghost img { width: 100%; height: 100%; object-fit: contain; }
#overlay-clear { z-index: 60; }
#overlay-clear .small-btn { margin-top: 20px; }

/* Challenge controls remain visible and reachable when the lights go out. */
.scene-object.puzzle-control {
  display: flex; align-items: center; justify-content: center; height: 82px;
  border: 4px solid #40362c; border-radius: 16px; padding: 8px;
  background: #fff3c7; color: #40362c; font-size: 36px; font-weight: 900;
  box-shadow: 0 5px 0 rgba(64,54,44,.3); white-space: nowrap;
}
.object-badge { position: absolute; z-index: 2; min-width: 42px; padding: 3px 8px; border: 3px solid #40362c; border-radius: 50%; background: white; font-size: 30px; font-weight: 900; color: #40362c; }
#screen-game[data-effect='dim'] #game-bg { opacity: .6; filter: saturate(.5) brightness(.6); }
#screen-game[data-effect='dark'] { background: #141722; }
#screen-game[data-effect='dark'] #game-bg { opacity: .6; filter: saturate(.3) brightness(.23); }
#screen-game[data-effect='dim'] .scene-object:not(.lit) img { filter: brightness(.65); }
#screen-game[data-effect='dark'] .scene-object:not(.lit) img { filter: brightness(.28); }
#screen-game[data-effect='dark'] .lit { box-shadow: 0 0 32px #f5e686; }
#btn-clue-log { left: 30px; right: auto; top: 104px; bottom: auto; max-width: 270px; font-size: 23px; }
.puzzle-dialog { width: 630px; max-height: 1020px; padding: 28px; border: 5px solid var(--ink); border-radius: 25px; background: #fff8e8; color: var(--ink); text-align: center; overflow-y: auto; }
.puzzle-dialog h2 { font-size: 34px; margin-bottom: 20px; }
#reader-lines { max-height: 780px; overflow-y: auto; text-align: start; }
#reader-lines p { padding: 18px 0; border-bottom: 2px dashed #c2a77d; font-size: 26px; line-height: 1.45; }
#overlay-reader { z-index: 70; }
#reader-lines.album-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.album-card { padding: 18px; border: 2px solid #dec7a3; border-radius: 18px; background: #fffdf5; }
.album-card img { display: block; width: 100%; height: 155px; object-fit: contain; margin-bottom: 14px; }
.album-card strong { display: block; font-size: 22px; line-height: 1.35; }
#reader-lines .album-card p { padding: 12px 0 0; border: 0; font-size: 21px; line-height: 1.45; }
#btn-reader-close { margin-top: 24px; }
#code-display { display: block; font-family: monospace; font-size: 60px; letter-spacing: 16px; margin: 15px 0 25px; }
#code-digits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
#code-digits button { padding: 16px; border: 3px solid var(--ink); border-radius: 12px; background: white; font-size: 40px; min-height: 87px; }
#code-digits button:first-child { grid-column: 2; grid-row: 4; }
#code-feedback { min-height: 72px; margin: 22px 0; font-size: 24px; line-height: 1.4; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; }
button:disabled { opacity: .65; cursor: default; }

#btn-stages { margin-top: 26px; }
#privacy-policy { position: absolute; bottom: 58px; left: 40px; right: 40px; color: #594836; text-align: center; font-size: 21px; text-decoration: underline; }

/* 하드모드 */
#btn-hard { margin-top: 18px; background: var(--ink); color: var(--yellow); box-shadow: 0 5px 0 #0f0c0a; }
#btn-hard:disabled { background: #e3ddd2; color: #7b746b; box-shadow: 0 5px 0 #b8b0a3; opacity: 1; font-size: 21px; }
#screen-hard-list {
  display: flex; flex-direction: column; align-items: center; padding-top: 30px;
  background: radial-gradient(circle at 50% 18%, #5b4636 0 22%, transparent 60%), linear-gradient(#3a2e27, #211b18);
}
#screen-hard-list .select-title { color: var(--yellow); text-shadow: 3px 3px 0 #000; }
#hard-key-art { width: 190px; height: 190px; object-fit: contain; animation: bob 2.4s ease-in-out infinite; }
#hard-tagline { margin-top: 10px; padding: 8px 20px; border-radius: 999px; background: var(--red); color: #fff; font-size: 23px; font-weight: 900; text-align: center; }
#hard-progress { margin: 10px 0 14px; color: #f5dfae; font-size: 22px; font-weight: 800; }
#hard-cards { display: grid; gap: 12px; width: 640px; max-height: 790px; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: #ad8752 transparent; }
.hard-card {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 16px; min-height: 84px; padding: 10px 20px;
  border: 5px solid var(--ink); border-radius: 22px; background: #fff8e8; color: var(--ink); box-shadow: 0 7px 0 #0f0c0a; cursor: pointer; text-align: start;
}
.hard-card:active { transform: translateY(5px); box-shadow: 0 2px 0 #0f0c0a; }
.hard-card-number { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: var(--yellow); font-size: 32px; font-weight: 900; }
.hard-card-name { font-size: 28px; font-weight: 900; line-height: 1.2; word-break: keep-all; overflow-wrap: anywhere; }
.hard-card-stars { color: #c98400; font-size: 30px; letter-spacing: 2px; }
#btn-hard-back { position: absolute; bottom: 24px; right: 25px; }

#screen-hard { background: var(--paper); }
#hard-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: saturate(.65) brightness(1.1); opacity: .2; }
#hard-hud {
  position: absolute; z-index: 20; left: 0; right: 0; top: 0; height: 86px; padding: 14px 18px;
  display: flex; align-items: center; gap: 15px; background: var(--ink); border-bottom: 4px solid #000;
}
#hard-hud .small-btn { flex: 0 0 62px; height: 54px; padding: 0; font-size: 28px; }
#hard-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--yellow); font-size: 28px; font-weight: 900; }
#btn-hard-rules { margin-inline-start: auto; }
#hard-brief-layer { position: absolute; z-index: 40; inset: 86px 0 0; display: flex; align-items: flex-start; justify-content: center; padding: 26px 22px; background: rgba(50,45,41,.5); }
#hard-brief {
  width: 100%; max-height: 1100px; overflow-y: auto; padding: 28px 28px 30px; text-align: center;
  border: 5px solid var(--ink); border-radius: 26px; background: #fff8e8; color: var(--ink); box-shadow: 0 12px 0 rgba(0,0,0,.25);
}
#hard-brief h2 { font-size: 32px; line-height: 1.25; transform: rotate(-1deg); }
#hard-story { margin-top: 18px; font-size: 26px; line-height: 1.42; font-weight: 900; text-align: start; }
#hard-rules { margin-top: 16px; padding-inline-start: 30px; font-size: 24px; line-height: 1.4; font-weight: 700; text-align: start; }
#hard-rules li + li { margin-top: 10px; }
#btn-hard-brief-ok { margin-top: 26px; }
#hard-meter { position: absolute; z-index: 5; left: 18px; right: 18px; top: 98px; height: 40px; display: flex; align-items: center; gap: 12px; }
.hard-meter-label { padding: 5px 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--yellow); color: var(--ink); font-size: 19px; font-weight: 900; white-space: nowrap; }
.hard-steps { display: flex; gap: 7px; }
.hard-steps i { width: 22px; height: 22px; border: 3px solid var(--ink); border-radius: 50%; background: var(--orange); transition: background .3s, opacity .3s; }
.hard-steps i.used { background: transparent; opacity: .35; }
#hard-board { position: absolute; z-index: 5; left: 0; right: 0; top: calc(148px + var(--extra-height) / 2); height: 924px; }
#hard-status {
  position: absolute; z-index: 6; left: 24px; right: 24px; top: calc(1080px + var(--extra-height) / 2); min-height: 52px;
  color: var(--ink); font-size: 21px; line-height: 1.3; font-weight: 900; text-align: center; word-break: keep-all; overflow-wrap: anywhere;
}
#hard-actions { position: absolute; z-index: 6; left: 18px; right: 18px; bottom: 18px; height: 112px; display: flex; align-items: center; justify-content: center; gap: 14px; }
#hard-actions .big-btn { margin-top: 0; padding: 16px 24px; font-size: 27px; }
#hard-actions .big-btn:disabled { background: #d9d5cd; color: #8a837a; box-shadow: 0 8px 0 #aaa; }
.hard-hint { flex: 0 0 auto; background: var(--yellow); font-size: 21px; }
.hard-hint.used { background: #fff; }
#hard-hint-line {
  position: absolute; z-index: 30; left: 40px; right: 40px; bottom: 150px; padding: 16px 20px;
  border: 4px solid var(--ink); border-radius: 20px; background: #fffbe0; color: var(--ink);
  box-shadow: 0 7px 0 rgba(50,45,41,.24); font-size: 22px; line-height: 1.35; font-weight: 900; text-align: center;
}

.hard-sprite { position: relative; display: block; overflow: hidden; pointer-events: none; }
.hard-sprite img { position: absolute; max-width: none; }
#hard-board button { cursor: pointer; touch-action: manipulation; }
/* Zero-specificity reset so each puzzle's own button styles win. */
#hard-board :where(button:not(.small-btn):not(.big-btn)) { padding: 0; border: 0; background: transparent; }

/* 개·수달·폰 옮기기 */
.hard-room {
  position: absolute; left: 18px; right: 18px; height: 372px; overflow: hidden;
  border: 4px solid var(--ink); border-radius: 22px; background-size: cover; background-position: center 64%;
}
/* Rooms stack by position (top room, band, bottom room), whatever the rooms are called. */
#hard-board > .hard-room:first-child { top: 0; }
#hard-board > .hard-room:last-child { top: 500px; }
.hard-room-label { position: absolute; left: 12px; top: 10px; padding: 4px 14px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); font-size: 20px; font-weight: 900; }
#hard-board .hard-boy { position: absolute; left: 22px; bottom: 6px; }
#hard-board .hard-friend { position: absolute; bottom: 14px; transition: transform .15s; }
#hard-board .hard-friend:active { transform: scale(.94); }
.hard-friend.slot-dog { left: 240px; }
.hard-friend.slot-otter { left: 410px; }
.hard-friend.slot-phone { left: 580px; bottom: 26px; }
.hard-boy.arrive { animation: hardArrive .42s cubic-bezier(.3,1.4,.6,1); }
@keyframes hardArrive { from { transform: translateY(40px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.hard-door { position: absolute; left: 0; right: 0; top: 372px; height: 128px; display: flex; align-items: center; justify-content: center; }
.hard-door::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 120px; transform: translateX(-50%); background: repeating-linear-gradient(#c8a46a 0 14px, #b48d55 14px 28px); border-inline: 4px solid var(--ink); }
.hard-door-btn { position: relative; margin-top: 0 !important; padding: 14px 34px !important; font-size: 28px !important; border: 5px solid var(--ink) !important; background: var(--orange) !important; color: #fff !important; box-shadow: 0 8px 0 #b94e2c !important; }

/* 상자 9개·저울 두 번 */
.hard-scale { position: absolute; left: 0; top: 0; width: 720px; height: 440px; }
.hard-stand { position: absolute !important; left: 50%; top: 60px; transform: translateX(-50%); }
.hard-beam { position: absolute !important; left: 360px; top: 110px; transform-origin: 50% 50%; transition: transform .6s cubic-bezier(.3,1.5,.5,1); z-index: 2; }
.hard-pan { position: absolute; z-index: 3; transform: translateX(-50%); transition: left .6s cubic-bezier(.3,1.5,.5,1), top .6s cubic-bezier(.3,1.5,.5,1); }
.hard-pile { position: absolute; z-index: 2; left: 50%; bottom: 28px; width: 192px; transform: translateX(-50%); display: flex; flex-wrap: wrap-reverse; justify-content: center; }
.hard-floor { position: absolute; left: 18px; right: 18px; top: 460px; display: grid; grid-template-columns: repeat(5, 1fr); justify-items: center; row-gap: 6px; }
.hard-box { position: relative; }
.hard-box-number {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); min-width: 38px; padding: 0 6px;
  border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); font-size: 22px; font-weight: 900; line-height: 30px; text-align: center;
}
.hard-pile .hard-box-number { min-width: 28px; font-size: 16px; line-height: 22px; border-width: 2px; }
#hard-board.opening .hard-box { animation: hardWobble .9s ease-in-out infinite; }
#hard-board.opening .hard-box-number { background: var(--yellow); }
@keyframes hardWobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
.hard-log { position: absolute; left: 30px; right: 30px; top: 724px; list-style: none; color: var(--ink); font-size: 20px; line-height: 1.4; font-weight: 800; }

/* 증언 추리 */
.hard-speakers { position: absolute; left: 18px; right: 18px; top: 0; max-height: 548px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.hard-speaker { display: flex; align-items: center; gap: 10px; }
.hard-speaker > .hard-sprite { flex: 0 0 auto; }
.hard-speaker .hard-sprite { min-width: 112px; }
.hard-bubble {
  flex: 1; padding: 9px 14px; border: 3px solid var(--ink); border-radius: 16px; background: #fff;
  color: var(--ink); font-size: 21px; line-height: 1.32; font-weight: 800;
}
.hard-bubble strong { display: block; color: #9b5d00; font-size: 17px; }
.hard-spots { position: absolute; left: 18px; right: 18px; top: 566px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#hard-board .hard-spot {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 158px; padding: 10px;
  border: 4px solid var(--ink); border-radius: 18px; background: rgba(255,255,255,.92);
}
.hard-spot-name { color: var(--ink); font-size: 19px; font-weight: 900; line-height: 1.15; }
.hard-spot.marked > * { opacity: .35; }
.hard-spot.marked::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-size: 92px; font-weight: 900; }

#hard-result[data-result="fail"] { background: rgba(255,244,218,.97); }
#hard-result[data-result="win"] { background: linear-gradient(rgba(255,207,75,.95), rgba(244,123,80,.95)); }
#hard-result-art { width: 360px; max-height: 380px; object-fit: contain; animation: failIn .45s cubic-bezier(.3,1.4,.6,1); }
#hard-result[data-result="fail"] .overlay-text { color: #604630; font-size: 62px; text-shadow: 3px 3px 0 #efc992; }
#hard-result[data-result="fail"] .overlay-sub { color: #604630; text-shadow: none; }
#hard-result .big-btn { margin-top: 22px; }
#hard-result .small-btn { margin-top: 16px; }
html[dir="rtl"] #hard-name, html[dir="rtl"] #hard-status, html[dir="rtl"] .hard-bubble { unicode-bidi: plaintext; }
#hard-board .hard-speaker { position: relative; width: 100%; color: var(--ink); text-align: start; }
.hard-speaker.accused .hard-bubble { border-color: var(--red); background: #fff0ec; box-shadow: 0 0 0 3px var(--red); }
.hard-accused {
  position: absolute; top: -8px; inset-inline-end: 12px; padding: 2px 12px; border: 3px solid var(--ink); border-radius: 999px;
  background: var(--red); color: #fff; font-size: 17px; font-weight: 900; transform: rotate(3deg);
}

/* 두 방 사이를 오가는 퍼즐 공통 */
.hard-room.dark { filter: brightness(.42) saturate(.6); }
#hard-board .hard-rider, #hard-board .hard-walker { position: absolute; bottom: 12px; transition: transform .15s, left .3s, bottom .3s; }
#hard-board .hard-rider:active, #hard-board .hard-walker:active { transform: scale(.94); }

/* 과자를 지켜라 */
.hard-sled { position: absolute; left: 285px; bottom: 6px; }
.hard-sled.arrive { animation: hardArrive .42s cubic-bezier(.3,1.4,.6,1); }
.hard-rider.slot-cousin1 { left: 16px; }
.hard-rider.slot-cousin2 { left: 100px; }
.hard-rider.slot-cousin3 { left: 184px; }
.hard-rider.slot-dog1 { left: 445px; }
.hard-rider.slot-dog2 { left: 522px; }
.hard-rider.slot-dog3 { left: 599px; }
#hard-board .hard-rider.slot-aboard0 { left: 290px; bottom: 46px; z-index: 3; }
#hard-board .hard-rider.slot-aboard1 { left: 362px; bottom: 46px; z-index: 3; }
.hard-rider.aboard { filter: drop-shadow(0 0 8px #ffd45d); }

/* 정전 복도 */
.hard-walker.slot-boy { left: 20px; }
.hard-walker.slot-dog { left: 165px; }
.hard-walker.slot-dad { left: 285px; }
.hard-walker.slot-grandma { left: 475px; }
#hard-board .hard-walker.picked { transform: translateY(-14px); filter: drop-shadow(0 0 10px #ffd45d); }
.hard-walker-tag {
  position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 4px; padding: 2px 10px; white-space: nowrap;
  border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); font-size: 16px; font-weight: 900;
}
.hard-walker.picked .hard-walker-tag { background: var(--yellow); }
.hard-torch { position: absolute; top: 10px; right: 16px; filter: drop-shadow(0 0 14px #fff2a0) drop-shadow(0 0 28px #ffd45d); }
.hard-torch.arrive { animation: hardArrive .42s cubic-bezier(.3,1.4,.6,1); }

/* 엄마의 금고 */
.hard-notes { position: absolute; left: 18px; right: 18px; top: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.hard-note {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 10px;
  background: #fff27a; color: var(--ink); box-shadow: 0 5px 0 rgba(50,45,41,.2); transform: rotate(-1deg);
}
.hard-note:nth-child(even) { transform: rotate(1.2deg); }
.hard-note-digits { display: flex; gap: 8px; }
.hard-note-digits b { display: grid; place-items: center; width: 46px; height: 50px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; font-size: 32px; }
.hard-note-text { font-size: 18px; line-height: 1.3; font-weight: 800; }
.hard-lock { position: absolute; left: 18px; right: 18px; top: 450px; display: grid; grid-template-columns: 170px 1fr; grid-template-rows: auto 1fr; gap: 12px 18px; align-items: center; }
.hard-lock > .hard-sprite { grid-row: 1 / span 2; justify-self: center; }
.hard-code { display: block; padding: 8px 0; border: 4px solid var(--ink); border-radius: 16px; background: #1f2a33; color: #8ff0a4; font-family: monospace; font-size: 54px; letter-spacing: 12px; text-align: center; }
.hard-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
#hard-board .hard-key { height: 70px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); font-size: 32px; font-weight: 900; box-shadow: 0 4px 0 #bbb; }
#hard-board .hard-key:active { transform: translateY(3px); box-shadow: 0 1px 0 #bbb; }

/* 정확히 4리터 */
.hard-dad { position: absolute; top: 0; right: 30px; }
.hard-pots { position: absolute; left: 18px; right: 18px; top: 150px; display: flex; justify-content: center; align-items: flex-end; gap: 40px; }
.hard-pot-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hard-pot-name { padding: 3px 14px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); font-size: 19px; }
.hard-pot {
  position: relative; width: 190px; overflow: hidden; border: 6px solid var(--ink); border-top-width: 3px; border-radius: 6px 6px 34px 34px;
  background: rgba(255,255,255,.75); box-shadow: inset 0 0 0 4px rgba(255,255,255,.6);
}
.hard-water { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(#9ddcff, #3d8fd6); transition: height .55s ease; }
.hard-pot-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 270px; }
#hard-board .hard-pot-actions .small-btn { padding: 8px 6px; font-size: 18px; line-height: 1.2; }
#hard-board .hard-pot-pour { grid-column: 1 / -1; }
#hard-board .hard-pot-give { grid-column: 1 / -1; background: var(--yellow); }

/* 아빠의 꼬인 스위치 */
.hard-mom-nap { position: absolute; top: 0; left: 50%; transform: translateX(-50%); }
.hard-devices { position: absolute; left: 18px; right: 18px; top: 168px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hard-device {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 140px; padding: 8px;
  border: 4px solid var(--ink); border-radius: 18px; background: #e7e2d8; transition: background .3s, box-shadow .3s;
}
.hard-device .hard-sprite { filter: grayscale(.85) brightness(.7); transition: filter .3s; }
.hard-device.on { background: #fff6c4; box-shadow: 0 0 26px #ffd45d; }
.hard-device.on .hard-sprite { filter: none; }
.hard-device.on[data-device="fan"] .hard-sprite { animation: hardSpin 1.1s linear infinite; }
.hard-device.flipped { animation: hardFlip .45s ease; }
@keyframes hardSpin { to { transform: rotate(360deg); } }
@keyframes hardFlip { 40% { transform: scale(1.08); } }
.hard-device-name { color: var(--ink); font-size: 18px; font-weight: 900; }
.hard-switches { position: absolute; left: 18px; right: 18px; top: 478px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#hard-board .hard-switch {
  display: flex; flex-direction: column; align-items: center; gap: 8px; height: 150px; padding: 10px;
  border: 4px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: 0 6px 0 #bbb;
}
#hard-board .hard-switch:active { transform: translateY(4px); box-shadow: 0 2px 0 #bbb; }
.hard-switch-number { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--ink); color: var(--yellow); font-size: 26px; }
.hard-switch-icons { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
