@font-face {
  font-family: "RoomGame";
  src: url("assets/fonts/NotoSansSC-Medium.otf") format("opentype");
  font-style: normal;
  font-weight: 500;
  font-display: block;
}

:root {
  color-scheme: dark;
  font-family: "RoomGame", sans-serif;
  letter-spacing: 0;
  --ink: #3c210f;
  --cream: #fff0ca;
  --hover: #a62e20;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #20130b;
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
}

html,
body {
  min-height: 100%;
  min-height: 100dvh;
  overscroll-behavior: none;
}

#boot-status {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
  background: #20130b;
  color: #ffe5aa;
  font-size: 28px;
  text-align: center;
  pointer-events: none;
  transition: opacity 120ms linear;
}

#app.ready #boot-status {
  visibility: hidden;
  opacity: 0;
}

#app.booting #game-stage {
  visibility: hidden;
  pointer-events: none;
}

#stage-wrap {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #20130b;
}

#game-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1530px;
  height: 1028px;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--stage-scale, 1));
  transform-origin: center;
  background: #d59639;
  color: var(--ink);
  isolation: isolate;
  contain: layout paint size;
}

#room-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

#items-layer,
#room-controls,
#intro-layer,
#modal-root,
#ending-root {
  position: absolute;
  inset: 0;
}

#items-layer { z-index: 10; }
#room-controls { z-index: 30; }
#intro-layer { z-index: 50; pointer-events: none; }
#modal-root { z-index: 70; pointer-events: none; }
#ending-root { z-index: 100; pointer-events: none; }

.item-visual {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  pointer-events: none;
  -webkit-user-drag: none;
  will-change: transform;
  transition: none;
  filter: drop-shadow(0 5px 3px rgb(45 25 9 / 28%));
}

img.asset-failed {
  background: #3a2114;
  color: #fff0ca;
  font-size: 24px;
  text-align: center;
}

.view-enter {
  animation: view-fade-in 130ms ease-out both;
}

@keyframes view-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.item-visual.pending {
  cursor: pointer;
}

.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  color: #2f190c;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.hotspot::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  box-shadow: inset 0 0 0 5px rgb(255 241 166 / 52%);
  transition: opacity 100ms linear;
  pointer-events: none;
}

.hotspot:hover::after,
.hotspot:focus-visible::after { opacity: 1; }

.hotspot:focus-visible,
.text-option:focus-visible,
.close-control:focus-visible,
.price-button:focus-visible {
  outline: 5px solid #fff1a6;
  outline-offset: 5px;
}

.store-hotspot,
.submit-hotspot { overflow: hidden; }

.intro-overlay {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: auto;
  cursor: pointer;
  background: rgb(22 13 7 / 48%);
}

.intro-character {
  position: absolute;
  left: 30px;
  bottom: -65px;
  width: 560px;
  height: 780px;
  object-fit: contain;
  filter: drop-shadow(10px 12px 8px rgb(20 10 4 / 35%));
}

.intro-dialogue {
  position: absolute;
  left: 510px;
  right: 90px;
  bottom: 106px;
  min-height: 246px;
  padding: 48px 62px;
  border: 12px solid #5c351b;
  background: rgb(255 231 179 / 96%);
  box-shadow: inset 0 0 0 7px #c58a43, 12px 14px 0 rgb(34 18 8 / 32%);
}

.intro-speaker {
  margin: 0 0 20px;
  color: #4d2812;
  font-size: 45px;
  font-weight: 700;
  line-height: 1.15;
}

.intro-line {
  margin: 0;
  color: #2f190d;
  font-size: 52px;
  line-height: 1.35;
  animation: dialogue-in 220ms ease-out;
}

@keyframes dialogue-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: rgb(19 10 5 / 48%);
}

.modal-canvas {
  position: absolute;
  inset: 0;
}

.modal-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.modal-choice-row {
  position: absolute;
  left: 775px;
  top: 786px;
  width: 612px;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.choice-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 96px);
  min-width: 0;
  padding: 28px 42px 30px;
  border: 8px solid #5a3218;
  background: #ffe7b4;
  box-shadow: inset 0 0 0 4px #bd8240, 8px 10px 0 rgb(31 16 7 / 30%);
  transform: translate(-50%, -50%);
}

.choice-title {
  max-width: 100%;
  margin: 0 0 24px;
  color: #44230f;
  font-size: 34px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.choice-popup .action-options {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  width: max-content;
  max-width: 100%;
  pointer-events: none;
}

.choice-popup .action-options .text-option {
  flex: none;
  font-size: 42px;
}

.text-option {
  display: inline-block;
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #4b2813;
  font-size: 44px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
}

.text-option:hover { color: var(--hover); }
.text-option:active { opacity: 0.58; }
.text-option:disabled { opacity: 0.38; cursor: default; }

.close-control {
  position: absolute;
  right: 96px;
  top: 104px;
  width: 68px;
  height: 68px;
  border: 0;
  padding: 0;
  color: #4a260f;
  background: transparent;
  font-size: 66px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
}

.action-title,
.action-message {
  position: absolute;
  left: 190px;
  right: 190px;
  margin: 0;
  text-align: center;
  color: #44230f;
}

.action-title {
  top: 160px;
  font-size: 56px;
  line-height: 1.2;
}

.action-options {
  position: absolute;
  inset: 320px 170px 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 118px;
  pointer-events: none;
}

.action-options .text-option {
  font-size: 56px;
}

.action-message {
  top: 420px;
  font-size: 62px;
  line-height: 1.45;
}

.store-view {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  background: #1e0e04;
}

.store-background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.store-balance {
  position: absolute;
  left: 181px;
  top: 105px;
  z-index: 5;
  min-width: 56px;
  padding: 2px 4px 6px;
  background: #d08a35;
  color: #fff0c8;
  font-size: 54px;
  line-height: 1;
  text-align: center;
  text-shadow: 4px 0 #251208, -4px 0 #251208, 0 4px #251208, 0 -4px #251208;
}

.store-balance.zero { opacity: 0; }

.store-close {
  right: 91px;
  top: 82px;
  width: 99px;
  height: 111px;
  color: transparent;
  text-shadow: none;
}

.store-product {
  position: absolute;
  pointer-events: none;
}

.store-product.purchased::before {
  content: "";
  position: absolute;
  left: var(--dim-x);
  top: var(--dim-y);
  width: var(--dim-width);
  height: var(--dim-height);
  background: rgb(35 24 18 / 55%);
  filter: grayscale(0.8);
  pointer-events: none;
}

.price-button {
  position: absolute;
  z-index: 4;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.purchase-dialog {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgb(19 10 5 / 50%);
}

.purchase-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.purchase-reason {
  position: absolute;
  left: 330px;
  right: 330px;
  top: 610px;
  margin: 0;
  color: #4c270e;
  font-size: 37px;
  line-height: 1.3;
  text-align: center;
}

.transparent-close {
  color: transparent;
  text-shadow: none;
}

#toast {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 90;
  display: none;
  padding: 18px 34px;
  border: 6px solid #5b3217;
  background: #ffe5aa;
  color: #4b2711;
  font-size: 52px;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow: 8px 10px 0 rgb(37 19 7 / 36%);
  pointer-events: none;
}

#toast.visible { display: block; animation: toast-in 180ms ease-out; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.ending-view {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: auto;
  background-color: #f0bd68;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
}

.ending-view::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgb(36 17 7 / 55%);
}

.ending-character {
  position: absolute;
  left: -250px;
  bottom: -30px;
  width: 800px;
  height: 1000px;
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(10px 12px 5px rgb(22 11 4 / 45%));
}

.ending-grid {
  position: absolute;
  left: 268px;
  right: 24px;
  top: 24px;
  bottom: 24px;
  z-index: 3;
  display: grid;
  grid-auto-rows: auto;
  align-content: center;
  gap: 12px;
}

.ending-grid.compact {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.ending-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  aspect-ratio: 1530 / 1028;
}

.ending-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.ending-card p {
  position: absolute;
  left: 11%;
  right: 11%;
  top: 29%;
  bottom: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  overflow: hidden;
  color: #3f210e;
  font-size: 27px;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.ending-grid.compact .ending-card p { font-size: 22px; }

.summary-card p {
  left: 46%;
  right: 38%;
  top: 31.3%;
  bottom: 32.7%;
  color: #ffd34e;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 3px 0 #2b1609, -3px 0 #2b1609, 0 3px #2b1609, 0 -3px #2b1609, 4px 5px #2b1609;
}

.ending-grid.compact .summary-card p {
  top: 31.3%;
  bottom: 32.7%;
}

.summary-total {
  display: block;
  font: inherit;
  font-weight: 700;
}

#rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  place-content: center;
  gap: 24px;
  background: #20130b;
  color: #ffe5aa;
  text-align: center;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
}

#rotate-overlay p {
  margin: 0;
  font-size: 28px;
  line-height: 1.4;
}

.rotate-mark {
  font-size: 72px;
  line-height: 1;
}

@media (orientation: portrait) and (pointer: coarse) {
  #rotate-overlay { display: grid; }
  #game-stage { pointer-events: none; }
}

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