@font-face {
  font-family: "RW Escape Mincho";
  src: url("./assets/fonts/escape-mincho.woff2") format("woff2");
  font-weight: 600 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #07080a;
  --panel: rgba(10, 13, 16, .72);
  --panel-strong: rgba(8, 10, 13, .9);
  --line: rgba(223, 235, 235, .2);
  --cyan: #7fd3e6;
  --red: #e03a2e;
  --gold: #c9a24a;
  --ivory: #f2efe7;
  --muted: #aeb7b8;
  --safe-x: max(5vw, env(safe-area-inset-left));
  --safe-y: max(2.5vh, env(safe-area-inset-top));
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  background: var(--ink);
  color: var(--ivory);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #030405;
}

body { display: grid; place-items: center; }
button, a { font: inherit; }
button { color: inherit; }

#game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #080a0c;
  isolation: isolate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#game-canvas.dragging { cursor: grabbing; }

.screen-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
}

.screen-panel.is-visible { display: flex; }

.title-screen {
  align-items: center;
  justify-content: center;
  padding: max(5vh, env(safe-area-inset-top)) var(--safe-x) max(6vh, env(safe-area-inset-bottom));
  text-align: center;
  background: #090a0d;
}

.title-key-art,
.title-shade {
  position: absolute;
  inset: -3%;
  width: 106%;
  height: 106%;
}

.title-key-art {
  object-fit: cover;
  filter: saturate(.82) contrast(1.06) brightness(.72);
  animation: ken-burns 20s ease-in-out infinite alternate;
}

.title-shade {
  background:
    radial-gradient(circle at 50% 44%, transparent 0 22%, rgba(2, 3, 5, .28) 55%, rgba(2, 3, 5, .9) 100%),
    linear-gradient(180deg, rgba(3, 5, 7, .62), transparent 27%, transparent 62%, rgba(3, 4, 6, .94));
}

@keyframes ken-burns {
  from { transform: scale(1.01) translate3d(0, 0, 0); }
  to { transform: scale(1.09) translate3d(-.8%, -1.4%, 0); }
}

.title-content {
  position: relative;
  width: min(100%, 600px);
  margin-top: 8vh;
  text-shadow: 0 2px 2px #000, 0 6px 24px #000;
}

.eyebrow {
  margin: 0 0 12px;
  color: #ddc783;
  font-size: clamp(14px, 1.5vw, 17px);
  font-weight: 700;
  letter-spacing: .32em;
}

h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .12em;
  margin: 0;
  font: 800 clamp(45px, 10vw, 86px)/1.04 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  letter-spacing: .05em;
}

h1 span {
  color: transparent;
  background: linear-gradient(180deg, #fff3bc 0%, #c9a24a 48%, #7f5e21 100%);
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 2px 0 #3a270a) drop-shadow(0 0 17px rgba(201, 162, 74, .28));
}

h1 em {
  color: #f1eee5;
  font-size: .57em;
  font-style: normal;
  text-shadow: 0 0 16px rgba(127, 211, 230, .3);
}

.title-rule {
  position: relative;
  width: min(78%, 380px);
  height: 15px;
  margin: 12px auto 0;
}

.title-rule::before,
.title-rule::after {
  content: "";
  position: absolute;
  top: 7px;
  width: 44%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.title-rule::before { left: 0; }
.title-rule::after { right: 0; transform: scaleX(-1); }
.title-rule span { position: absolute; left: 50%; top: 3px; width: 8px; height: 8px; transform: translateX(-50%) rotate(45deg); border: 1px solid var(--gold); }

.lead {
  margin: 24px 0 20px;
  color: #e2e2dd;
  font-family: "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(16px, 2.3vw, 20px);
  line-height: 1.9;
  letter-spacing: .04em;
}

.loading-text {
  min-height: 24px;
  margin: 0 0 12px;
  color: #bbc6c8;
  font-size: 14px;
  letter-spacing: .08em;
}

.primary-button,
#retry-btn,
.confirm-actions button {
  min-height: 52px;
  border: 1px solid rgba(201, 162, 74, .92);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, color 180ms ease, background 180ms ease, transform 120ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: min(280px, 80vw);
  padding: 13px 28px;
  color: #17130c;
  background: linear-gradient(180deg, #dfc26f, #ae8434);
  box-shadow: inset 0 1px rgba(255, 255, 255, .38), 0 8px 30px rgba(0, 0, 0, .45);
  font-weight: 800;
  letter-spacing: .1em;
  text-decoration: none;
}

.primary-button:hover,
.primary-button:focus-visible {
  border-color: #ffe7a0;
  box-shadow: inset 0 1px rgba(255, 255, 255, .5), 0 0 22px rgba(201, 162, 74, .52), 0 8px 30px rgba(0, 0, 0, .55);
  transform: translateY(-1px);
}

.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .52; filter: grayscale(.45); box-shadow: none; transform: none; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid #dffaff;
  outline-offset: 3px;
}

.title-footer {
  position: absolute;
  left: var(--safe-x);
  bottom: max(2.5vh, env(safe-area-inset-bottom));
  color: rgba(224, 229, 228, .62);
  font-size: 14px;
  letter-spacing: .08em;
}

.mute-toggle {
  position: absolute;
  z-index: 26;
  right: var(--safe-x);
  bottom: max(2.5vh, env(safe-area-inset-bottom));
  min-width: 84px;
  min-height: 48px;
  padding: 9px 13px;
  border: 1px solid rgba(220, 227, 226, .38);
  border-radius: 2px;
  color: #e1e7e5;
  background: rgba(5, 8, 10, .66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  text-shadow: 0 2px 3px #000;
}

.mute-toggle:hover,
.mute-toggle:focus-visible { border-color: var(--cyan); color: #fff; box-shadow: 0 0 14px rgba(127, 211, 230, .25); }

#game-shell[data-mode="result"] .mute-toggle {
  top: max(12px, env(safe-area-inset-top));
  bottom: auto;
}

#game-shell[data-mode="game"] .mute-toggle {
  right: auto;
  left: var(--safe-x);
}

.game-ui { position: absolute; inset: 0; z-index: 8; pointer-events: none; }

.hud {
  position: absolute;
  top: var(--safe-y);
  left: var(--safe-x);
  right: var(--safe-x);
  max-width: 640px;
  margin-inline: auto;
  padding: 14px 16px 12px;
  border: 1px solid var(--line);
  border-top-color: rgba(255, 255, 255, .38);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(21, 26, 30, .75), rgba(5, 8, 11, .57));
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 10px 34px rgba(0, 0, 0, .26);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  text-shadow: 0 2px 3px #000;
}

.hud-topline { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.room-heading { display: flex; flex-direction: column; min-width: 0; gap: 4px; text-align: left; }
.room-heading span { color: var(--gold); font: 700 14px/1 "Oswald", sans-serif; letter-spacing: .16em; }
.room-heading strong { overflow: hidden; font: 800 clamp(16px, 2.4vw, 21px)/1.2 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .12em; text-overflow: ellipsis; white-space: nowrap; }
.timer-readout { display: flex; align-items: baseline; gap: 5px; color: #f4ebd5; }
.timer-readout #timer-text { min-width: 70px; font: 400 clamp(34px, 5vw, 45px)/.9 "Bebas Neue", "Oswald", sans-serif; letter-spacing: .04em; text-align: right; }
.timer-readout small { color: #9ea9aa; font: 700 14px/1 "Oswald", sans-serif; letter-spacing: .1em; }

.timer-track {
  height: 7px;
  margin-top: 11px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 5px;
  background: rgba(0, 0, 0, .48);
  box-shadow: inset 0 1px 3px #000;
}

.timer-bar {
  width: 100%;
  height: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, #9d762b, #f1d37c);
  box-shadow: 0 0 9px rgba(218, 181, 81, .55);
  transition: background 180ms ease;
}

.timer-bar.critical { background: linear-gradient(90deg, #9f1818, #ff5b4e); animation: critical-pulse 440ms steps(2) infinite; }
.timer-track.critical { animation: critical-shake 440ms steps(2) infinite; }
@keyframes critical-pulse { 50% { opacity: .42; filter: brightness(1.35); } }
@keyframes critical-shake { 25% { transform: translateX(-1px); } 75% { transform: translateX(1px); } }

.compass { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; margin-top: 10px; }
.compass span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px 2px;
  border: 1px solid rgba(123, 134, 137, .34);
  border-radius: 2px;
  color: #687174;
  background: rgba(4, 7, 9, .46);
  font-size: clamp(14px, 1.7vw, 16px);
  text-align: center;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.compass i { color: #465053; font-size: .7em; font-style: normal; }
.compass span.seen { color: #ddf9ff; border-color: rgba(127, 211, 230, .72); background: rgba(22, 87, 99, .48); box-shadow: inset 0 0 12px rgba(86, 205, 225, .15); }
.compass span.seen i { color: var(--cyan); }
.compass span.current { border-color: #f4fcff; box-shadow: 0 0 0 1px rgba(127, 211, 230, .7), 0 0 12px rgba(127, 211, 230, .32); }

.tutorial {
  position: absolute;
  top: min(25vh, 196px);
  left: 50%;
  width: max-content;
  max-width: 90%;
  padding: 10px 15px;
  transform: translate(-50%, 7px);
  border: 1px solid rgba(201, 162, 74, .72);
  border-radius: 3px;
  color: #fff4d6;
  background: rgba(7, 9, 11, .84);
  box-shadow: 0 7px 24px #000;
  font-size: clamp(14px, 2vw, 17px);
  letter-spacing: .04em;
  opacity: 0;
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-shadow: 0 2px 3px #000;
}

.tutorial.show { opacity: 1; transform: translate(-50%, 0); }

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(227, 248, 251, .64);
  border-radius: 50%;
  box-shadow: 0 0 7px #000, inset 0 0 5px rgba(127, 211, 230, .22);
}

.reticle span { position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(240, 253, 255, .86); box-shadow: 0 0 5px var(--cyan); }

.feedback {
  position: absolute;
  left: 50%;
  bottom: max(8vh, calc(env(safe-area-inset-bottom) + 28px));
  width: min(90%, 680px);
  padding: 13px 18px;
  transform: translate(-50%, 10px);
  border-block: 1px solid rgba(201, 162, 74, .35);
  background: linear-gradient(90deg, transparent, rgba(5, 7, 10, .9) 12%, rgba(5, 7, 10, .9) 88%, transparent);
  color: #f5f0e7;
  font: 800 clamp(15px, 2.2vw, 19px)/1.65 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  letter-spacing: .04em;
  text-align: center;
  white-space: pre-line;
  opacity: 0;
  transition: opacity 190ms ease, transform 190ms ease;
  text-shadow: 0 2px 3px #000, 0 0 14px #000;
}

.feedback.show { opacity: 1; transform: translate(-50%, 0); }

.penalty-float {
  position: absolute;
  left: 50%;
  top: 31%;
  color: #ff6659;
  font: 700 clamp(32px, 6vw, 52px)/1 "Bebas Neue", "Oswald", sans-serif;
  letter-spacing: .06em;
  text-shadow: 0 2px 3px #000, 0 0 17px rgba(224, 58, 46, .62);
  opacity: 0;
}

.penalty-float.show { animation: penalty-float 760ms ease-out; }
@keyframes penalty-float { 0% { opacity: 1; transform: translate(-50%, 8px) scale(.92); } 100% { opacity: 0; transform: translate(-50%, -36px) scale(1.04); } }

.keypad-panel {
  position: absolute;
  z-index: 11;
  right: var(--safe-x);
  bottom: max(7vh, calc(env(safe-area-inset-bottom) + 18px));
  width: 180px;
  padding: 11px;
  border: 1px solid #667174;
  border-top-color: #a1aaab;
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .06), transparent 35%),
    linear-gradient(180deg, rgba(29, 34, 36, .96), rgba(10, 12, 14, .96));
  box-shadow: inset 0 1px rgba(255, 255, 255, .11), inset 0 -8px 18px #0006, 0 14px 38px #000c;
}

.keypad-label { margin-bottom: 8px; color: #8d9999; font: 700 14px/1 "Oswald", sans-serif; letter-spacing: .14em; text-align: center; }
.code-display { padding: 10px 7px; margin-bottom: 9px; border: 1px solid #243b32; background: #07110d; color: #aaf8c7; box-shadow: inset 0 2px 6px #000, 0 0 10px rgba(62, 211, 133, .09); font: 700 23px/1.2 "Oswald", monospace; text-align: center; letter-spacing: .12em; text-shadow: 0 0 8px rgba(112, 255, 177, .62); }
.key-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.key-grid button {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid #596164;
  border-bottom-color: #16191a;
  border-radius: 3px;
  color: #f0f2ef;
  background: linear-gradient(#3c4244, #232729);
  box-shadow: inset 0 1px rgba(255, 255, 255, .12), 0 3px 0 #101213;
  font: 700 18px/1 "Oswald", sans-serif;
  cursor: pointer;
}

.key-grid button:hover,
.key-grid button:focus-visible { border-color: var(--cyan); color: #dffbff; box-shadow: inset 0 0 12px rgba(127, 211, 230, .14), 0 3px 0 #101213; }
.key-grid button:active { transform: translateY(3px); box-shadow: inset 0 2px 5px #000; }
.key-grid button:disabled { cursor: wait; opacity: .38; }

.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: max(6vh, env(safe-area-inset-top)) var(--safe-x) max(6vh, env(safe-area-inset-bottom));
  background: rgba(2, 3, 5, .76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.glass-card {
  width: min(100%, 470px);
  padding: 20px;
  border: 1px solid rgba(224, 232, 231, .22);
  border-top-color: rgba(255, 255, 255, .4);
  border-radius: 5px;
  background: linear-gradient(150deg, rgba(31, 37, 40, .88), rgba(8, 11, 13, .92));
  box-shadow: inset 0 1px rgba(255, 255, 255, .06), 0 20px 64px #000;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.zoom-card { color: inherit; cursor: pointer; text-align: center; }
.modal-kicker { display: block; margin-bottom: 13px; color: var(--cyan); font-size: 14px; font-weight: 700; letter-spacing: .22em; text-align: left; }
.modal-kicker.warning { color: #ff766a; }
.zoom-card p,
.confirm-card p { margin: 16px 0; font: 800 18px/1.8 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .04em; white-space: pre-line; text-shadow: 0 2px 3px #000; }
.zoom-card small { color: #a6b0b1; font-size: 14px; }

/* 背景画像はシーン内と同じ手がかり canvas を JS が差し込む。色は透明部分の下地(壁・床)役 */
.zoom-art { height: min(30vh, 190px); border: 1px solid #596062; background: #2a2f31 center / contain no-repeat; box-shadow: inset 0 0 30px #0008; }
.zoom-art.paper,
.zoom-art.memo,
.zoom-art.calendar { background-color: #14161a; }
.zoom-art.bolts-note { background-color: #4a5052; }
.zoom-art.clock { background-color: #111; }
.zoom-art.stars { background-color: #121a20; }
.zoom-art.scratch { background-color: #3a3f42; }
.zoom-art.poster { background-color: #2b0a20; box-shadow: inset 0 0 20px #0008, 0 0 19px rgba(255, 44, 168, .28); }

.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.confirm-actions button,
#retry-btn { padding: 12px 15px; border-color: #747e80; color: #edf0ed; background: linear-gradient(#313638, #1d2022); box-shadow: inset 0 1px rgba(255, 255, 255, .1); }
.confirm-actions button:hover,
.confirm-actions button:focus-visible,
#retry-btn:hover,
#retry-btn:focus-visible { border-color: var(--cyan); box-shadow: 0 0 14px rgba(127, 211, 230, .24); }
.confirm-actions .danger-button { border-color: #f56b5d; background: linear-gradient(#a62b25, #6f1714); box-shadow: inset 0 1px rgba(255, 255, 255, .16), 0 0 14px rgba(224, 58, 46, .16); }
.confirm-actions .danger-button:hover,
.confirm-actions .danger-button:focus-visible { border-color: #ffb1aa; box-shadow: 0 0 20px rgba(224, 58, 46, .48); }

.result-panel {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  /* 上部の音量ボタン(48px)とカードが重ならないだけ余白を取る */
  padding: max(4vh, calc(env(safe-area-inset-top) + 12px + 48px + 12px)) var(--safe-x) max(8vh, calc(env(safe-area-inset-bottom) + 56px));
  background: #090913 url("./assets/ui/result_bg.webp") center / cover fixed;
  text-align: center;
}

.result-shade { position: fixed; inset: 0; background: radial-gradient(circle at 50% 34%, rgba(19, 10, 32, .12), rgba(3, 4, 7, .72) 58%, rgba(2, 3, 5, .94)); }
.result-card {
  position: relative;
  width: min(100%, 700px);
  margin: auto;
  padding: clamp(20px, 4vw, 38px);
  border: 1px solid rgba(201, 162, 74, .38);
  border-top-color: rgba(255, 240, 183, .65);
  border-radius: 5px;
  background: linear-gradient(155deg, rgba(20, 17, 28, .84), rgba(5, 7, 10, .9));
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 24px 80px #000b;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform-origin: 50% 20%;
}

.result-panel.is-visible .result-card { animation: card-reveal 420ms cubic-bezier(.2, .8, .2, 1) both; }
@keyframes card-reveal { from { opacity: 0; transform: perspective(900px) rotateY(-10deg) scale(.96); } to { opacity: 1; transform: perspective(900px) rotateY(0) scale(1); } }
.result-icon { display: block; width: min(55vw, 320px); max-height: 34vh; margin: 2px auto -4px; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .72)); }
.result-panel h2 { margin: 0 0 4px; font: 800 clamp(30px, 6vw, 48px)/1.2 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .08em; text-shadow: 0 2px 3px #000, 0 0 18px currentColor; }
.result-subtitle { margin: 0 0 15px; color: #d7d1c4; font: 800 clamp(15px, 2.3vw, 19px)/1.5 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .05em; text-shadow: 0 2px 3px #000; }
.result-description { max-width: 580px; margin: 0 auto 18px; color: #e5e1d9; font-size: clamp(14px, 2vw, 17px); line-height: 1.85; text-align: left; text-shadow: 0 2px 3px #000; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-meta { min-width: 0; padding: 12px 4px; border: 1px solid rgba(127, 211, 230, .18); background: rgba(7, 14, 19, .64); box-shadow: inset 0 1px rgba(255, 255, 255, .05); }
.result-meta span { display: block; margin-bottom: 5px; color: #aeb9ba; font-size: clamp(11px, 3vw, 14px); letter-spacing: 0; white-space: nowrap; }
.result-meta strong { display: block; color: #edfaff; font: 400 clamp(24px, 4vw, 34px)/1 "Bebas Neue", "Oswald", sans-serif; letter-spacing: .06em; text-shadow: 0 0 12px rgba(127, 211, 230, .35); }
.result-room-times { margin: 10px 0 0; color: #bfc7c7; font: 700 14px/1.6 "Oswald", "Noto Sans JP", sans-serif; }
.behavior-box { margin: 17px 0; padding: 13px 16px 11px 20px; border-left: 2px solid var(--gold); background: rgba(5, 7, 10, .58); text-align: left; }
.behavior-box h3 { margin: 0 0 10px; color: #ddc783; font: 800 16px/1.2 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .12em; }
.behavior-box ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; color: #d9d8d2; font-size: 14px; line-height: 1.65; }
.behavior-box li { position: relative; padding-left: 17px; text-shadow: 0 2px 3px #000; }
.behavior-box li::before { content: ""; position: absolute; left: -5px; top: .75em; width: 7px; height: 7px; border: 1px solid var(--gold); transform: rotate(45deg); background: #131015; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .primary-button { min-width: 0; }
.result-actions b { margin-right: 6px; font-size: 1.2em; }
.result-more-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; color: #ddc783; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.room-fade {
  position: absolute;
  inset: 0;
  z-index: 31;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: #000;
  opacity: 0;
}

.transition-card { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.transition-card span { color: var(--cyan); font: 700 16px/1 "Oswald", sans-serif; letter-spacing: .24em; }
.transition-card strong { font: 800 clamp(26px, 6vw, 44px)/1.2 "RW Escape Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif; letter-spacing: .13em; text-shadow: 0 3px 8px #000; }
.room-fade.play { animation: room-transition 1.28s ease-in-out both; }
.room-fade.play .transition-card { animation: transition-title 1.28s ease-in-out both; }
@keyframes room-transition { 0% { opacity: 1; } 62.5% { opacity: 1; } 100% { opacity: 0; } }
@keyframes transition-title { 0% { opacity: 0; transform: scale(.98); } 10% { opacity: 1; transform: scale(1); } 62.5% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 600px) {
  :root { --safe-x: max(18px, env(safe-area-inset-left)); --safe-y: max(14px, env(safe-area-inset-top)); }
  .title-content { margin-top: 2vh; }
  .hud { padding: 11px 12px 10px; }
  .timer-readout #timer-text { min-width: 58px; }
  .compass { gap: 3px; }
  .compass span { flex-direction: column; gap: 0; min-height: 38px; padding: 3px 1px; }
  .feedback { bottom: max(7vh, calc(env(safe-area-inset-bottom) + 30px)); }
  .game-ui.keypad-open .feedback { bottom: max(50vh, calc(env(safe-area-inset-bottom) + 360px)); width: calc(100% - 36px); }
  .keypad-panel { width: 174px; }
  .result-panel { justify-content: flex-start; }
  .result-card { margin: 0 auto; }
}

@media (max-height: 700px) {
  .title-content { margin-top: 0; }
  .lead { margin-block: 15px 12px; line-height: 1.6; }
  .hud { top: max(8px, env(safe-area-inset-top)); }
  .tutorial { top: 150px; }
  .result-icon { max-height: 27vh; width: min(38vw, 240px); }
}

@media (orientation: landscape) and (min-width: 760px) {
  .title-key-art { object-position: center 58%; }
  .title-content { margin-top: 0; }
  .result-panel { padding-top: max(3vh, env(safe-area-inset-top)); }
  .result-card { padding-block: 22px; }
  .result-icon { width: min(22vw, 210px); max-height: 28vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .title-key-art { transform: none !important; }
}

/* Keep the room visible while exploring, and every control reachable. */
.keypad-toggle { position: absolute; right: var(--safe-x); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 11; min-height: 48px; padding: 10px 16px; border: 1px solid #7fd3e6; border-radius: 4px; color: #e5faff; background: #14272ded; cursor: pointer; }
.keypad-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.keypad-heading .keypad-label { margin: 0; }
#keypad-close { min-height: 44px; padding: 7px; border: 1px solid #667174; border-radius: 3px; background: #20282c; cursor: pointer; }
.pause-overlay { z-index: 40; text-align: center; }
.pause-overlay p { line-height: 1.8; }
.transitioning .keypad-toggle, .transitioning .keypad-panel { visibility: hidden; pointer-events: none; }
@media (max-height: 480px) and (orientation: landscape) {
  .hud { width: min(56%, 520px); left: 18px; transform: none; }
  .compass span { min-height: 24px; }
  .tutorial { top: auto; bottom: 60px; }
  .keypad-panel { top: 8px; bottom: 8px; overflow-y: auto; }
  .key-grid button { min-height: 42px; }
  .modal-overlay { padding: 12px; overflow-y: auto; }
  .zoom-art { height: 95px; }
  .zoom-card p, .confirm-card p { margin-block: 8px; }
}
