@import url("https://fonts.googleapis.com/css2?family=Fraunces:wght@500;700&family=Space+Grotesk:wght@400;500;600&display=swap");

:root {
  --ink: #1d2129;
  --muted: rgba(29, 33, 41, 0.65);
  --paper: #f4f5f7;
  --accent: #ff6a4a;
  --accent-dark: #cc4c32;
  --shadow: rgba(15, 23, 42, 0.14);
  --panel: rgba(255, 255, 255, 0.92);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.96), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(255, 240, 228, 0.85), transparent 55%),
    linear-gradient(160deg, #f3f5f9 0%, #e7edf5 40%, #d8e1ec 100%);
  color: var(--ink);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px 18px 32px;
}

.back-link {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  border: 1px solid rgba(29, 33, 41, 0.12);
  box-shadow: 0 12px 24px var(--shadow);
}

.back-link:hover,
.back-link:focus-visible {
  transform: translateY(-2px);
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.scene {
  width: min(980px, 100%);
  display: grid;
  gap: 20px;
}

.title {
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.95), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(247, 248, 250, 0.92) 100%);
  border-radius: 22px;
  padding: 18px 22px 16px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 16px 32px var(--shadow);
}

.subtitle {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(21, 25, 31, 0.55);
}

h1 {
  margin: 8px 0 6px;
  font-family: "Fraunces", "Yu Mincho", serif;
  font-size: clamp(2rem, 3vw, 2.6rem);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.tagline {
  margin: 0 0 12px;
  color: var(--muted);
}

.title-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.language-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.language-select {
  border-radius: 999px;
  border: 1px solid rgba(29, 33, 41, 0.18);
  padding: 6px 12px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.room {
  position: relative;
  border-radius: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(246, 248, 251, 0.92) 100%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 18px 36px var(--shadow);
  padding: 20px;
  overflow: hidden;
}

.walls {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  min-height: 360px;
  border-radius: 22px;
  overflow: hidden;
}

.wall {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f5f6f8;
}

.wall.is-active {
  opacity: 1;
  pointer-events: auto;
}

.wall[data-wall="0"] {
  background-image: url("assets/north.png");
}

.wall[data-wall="1"] {
  background-image: url("assets/east.png");
}

.wall[data-wall="2"] {
  background-image: url("assets/south.png");
}

.wall[data-wall="3"] {
  background-image: url("assets/west.png");
}

.hotspot {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.hotspot:hover {
  border-color: rgba(255, 106, 74, 0.6);
  background: rgba(255, 106, 74, 0.08);
}

.hotspot:focus-visible {
  outline: 2px solid rgba(255, 106, 74, 0.9);
  outline-offset: 2px;
}

.door-status {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
  color: #fff;
  background: rgba(21, 25, 31, 0.72);
  padding: 2px 6px;
  border-radius: 999px;
}


.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  gap: 12px;
}

.nav-btn {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font: inherit;
}

.compass {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.compass-face {
  display: block;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink);
}

.panels {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(220px, 1fr);
}

.inventory {
  background: var(--panel);
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
  min-height: 140px;
}

.inventory h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.items {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.item {
  border: 1px solid rgba(29, 33, 41, 0.15);
  background: #fff;
  border-radius: 12px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
.item[aria-hidden="true"] {
  display: none;
}

.inventory-empty {
  margin: 0;
  color: var(--muted);
}

.room-message {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 10px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(28, 35, 45, 0.62);
  color: #f8f4ef;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
  max-width: min(92%, 540px);
  text-align: center;
}

.room-message.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-lead,
.modal-note,
.modal-result {
  color: var(--muted);
}

.shelf-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.shelf-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.shelf-preview {
  position: relative;
  width: min(520px, 100%);
  aspect-ratio: var(--crop-aspect, 2.15);
  margin: 12px auto 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
  background-color: #f7f5f1;
  background-image: url("assets/north.png");
  background-repeat: no-repeat;
  background-size: var(--crop-scale, 100%);
  background-position: var(--crop-pos-x, 50%) var(--crop-pos-y, 50%);
}

.shelf-preview .shelf-grid {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
}

.shelf-preview .symbol {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 0.95rem;
  font-weight: 800;
  color: #c7b7a5;
  -webkit-text-stroke: 0.6px #c7b7a5;
  background: rgba(255, 255, 255, 0.75);
  border: none;
  border-radius: 6px;
}

.shelf-preview .symbol.triangle,
.shelf-preview .symbol.circle,
.shelf-preview .symbol.square {
  color: #e2d9cc;
}

.shelf-preview .symbol.triangle {
  background: linear-gradient(90deg, #8f4f34 0%, #b5744f 50%, #8f4f34 100%);
}

.shelf-preview .symbol.circle {
  background: linear-gradient(90deg, #2f4c73 0%, #4b76a6 50%, #2f4c73 100%);
}

.shelf-preview .symbol.square {
  background: linear-gradient(90deg, #3a6447 0%, #5a8a67 50%, #3a6447 100%);
}
.symbol {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}

.symbol.triangle {
  background: #f0a85e;
}

.symbol.circle {
  background: #5c9bd6;
}

.symbol.square {
  background: #7abf86;
}

.card-order {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--w) * 1%);
  height: calc(var(--h) * 1%);
  transform: translate(0, 0);
  display: flex;
  gap: 12px;
  justify-content: space-evenly;
  align-items: center;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.card-preview {
  position: relative;
  width: min(420px, 100%);
  margin: 12px auto 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.card-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.card-symbol {
  display: inline-block;
  padding: 0 2px;
}

.card-order.size-sm {
  font-size: 1.1rem;
}

.card-order.size-md {
  font-size: 1.4rem;
}

.card-order.size-lg {
  font-size: 1.8rem;
}

.card-order.font-serif {
  font-family: "Fraunces", "Yu Mincho", serif;
}

.card-order.font-shippori {
  font-family: "Shippori Mincho", "Yu Mincho", serif;
}

.card-order.font-tenor {
  font-family: "Tenor Sans", "Space Grotesk", sans-serif;
}

.card-order.color-ink {
  color: #2b2f35;
}

.card-order.color-sepia {
  color: #4a3628;
}

.card-order.color-gold {
  color: #a2672f;
}

.card-order.color-blue {
  color: #2f4e73;
}

.page-grid {
  position: absolute;
  inset: 14.273% 22.175% 13.241% 22.65%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  pointer-events: none;
}

.page-cell {
  display: grid;
  place-items: center;
  position: relative;
  font-family: "Fraunces", "Yu Mincho", serif;
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: #a2672f;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.page-visual {
  position: relative;
  width: min(520px, 100%);
  aspect-ratio: 3 / 2;
  margin: 12px auto 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
  background-color: #f7f5f1;
  background-image: url("assets/page-grid.png");
  background-repeat: no-repeat;
  background-size: var(--page-bg-size, 140%) auto;
  background-position: var(--page-bg-x, 80%) var(--page-bg-y, 78%);
}

.page-visual.is-revealed .page-cell {
  opacity: 0.15;
}

.page-visual.is-revealed .page-cell.is-hole {
  opacity: 1;
  color: #a2672f;
}

.page-visual.is-revealed .page-cell.is-hole::after {
  content: "";
  width: 70%;
  height: 70%;
  border-radius: 50%;
  border: 1px solid rgba(162, 103, 47, 0.45);
  background: rgba(255, 255, 255, 0.85);
  position: absolute;
  z-index: -1;
}

.page-items {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(247, 245, 241, 0.7);
  border: 1px solid rgba(29, 33, 41, 0.08);
}

.page-items-label {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.page-items-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-items .item {
  padding: 6px 12px;
}

.page-items-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.primary,
.ghost {
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  cursor: pointer;
  border: none;
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 18px rgba(255, 106, 74, 0.28);
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost {
  background: #f2f4f7;
  color: var(--muted);
}

a.ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-error {
  margin: 6px 0 0;
  color: #c23828;
  min-height: 1.1em;
}

#door-form {
  display: grid;
  justify-items: center;
  gap: 6px;
}

#door-form input {
  text-align: center;
}

#door-form .form-error {
  text-align: center;
  width: 100%;
}

#desk-form {
  display: grid;
  justify-items: center;
  gap: 6px;
}

#desk-form input {
  text-align: center;
}

#desk-form .form-error {
  text-align: center;
  width: 100%;
}

.item-card .item-preview {
  display: grid;
  place-items: center;
  padding: 12px;
  background: #f7f7f7;
  border-radius: 12px;
  margin-bottom: 10px;
  position: relative;
}

.item-preview img {
  width: 140px;
  height: auto;
}

.item-card.is-bookmark .item-preview::after {
  content: "";
  position: absolute;
  inset: 12px;
  background:
    radial-gradient(circle at 36% 30%, #f7f7f7 0 10px, transparent 11px),
    radial-gradient(circle at 62% 50%, #f7f7f7 0 10px, transparent 11px),
    radial-gradient(circle at 38% 70%, #f7f7f7 0 10px, transparent 11px);
  pointer-events: none;
}

.item-card.is-bookmark img {
  width: 170px;
}

.door-preview {
  width: min(420px, 100%);
  margin: 10px auto 12px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.door-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.desk-preview {
  width: min(420px, 100%);
  margin: 10px auto 12px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.12);
}

.desk-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.epilogue {
  color: var(--muted);
}

@media (max-width: 720px) {
  .back-link {
    top: 12px;
    left: 12px;
  }

  .door-status {
    font-size: 0.55rem;
  }
}
