/* Lucky Bones: the door and the shelf. No outside fonts or scripts. Day is not offered here: the bog is always night. */
:root {
  --bog: #0a0c0a;
  --peat: #161a15;
  --moss: #2f3d2c;
  --felt: #4c6b45;
  --bone: #d9cfae;
  --bone-dim: #a39b7e;
  --brass: #a8863d;
  --moon: #e8ecdd;
  --socket: #7dff6a;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", Georgia, serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}
* { box-sizing: border-box; }
html { background: var(--bog); color: var(--bone); scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  background: var(--bog);
  -webkit-font-smoothing: antialiased;
}
body.shut { overflow: auto; }
@media (min-width: 900px) { body.shut { overflow: hidden; height: 100dvh; } }
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a { color: var(--bone); }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--socket); outline-offset: 3px; }
h1, h2, h3 { font-weight: 400; margin: 0; }
p { margin: 0; }

/* ---------- The door ---------- */
.door {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 46dvh) auto;
  align-items: end;
  transform-origin: 50% 40%;
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}
.bog {
  position: absolute; inset: 0;
  background: url(assets/bog.jpg) center 35% / cover no-repeat;
}
.bog::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(10,12,10,.05), rgba(10,12,10,.7) 75%),
    linear-gradient(180deg, rgba(10,12,10,.05), rgba(10,12,10,.9) 90%);
}
.moonlight {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 24% 12%, rgba(232,236,221,.22), transparent 28%);
}
.skull-stage {
  position: relative; z-index: 1;
  display: flex; justify-content: center; align-items: flex-end;
  height: 100%;
  padding: 2vh 16px 0;
}
.skull {
  position: relative;
  width: min(72vw, 46dvh, 460px);
  aspect-ratio: 1;
  filter: drop-shadow(0 30px 40px rgba(0,0,0,.8));
}
.skull-img {
  width: 100%; height: 100%; object-fit: contain;
  /* the render is on solid black; the mask melts that black into the bog so no square edge shows */
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 62%, transparent 78%);
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 62%, transparent 78%);
}
/* The sockets. Measured on the 1024 px face: left socket centered near 39% 53%, right near 62% 53%. */
.socket {
  position: absolute; width: 17%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(125,255,106,.95) 0%, rgba(90,220,80,.55) 35%, rgba(40,120,40,0) 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.4s var(--ease);
}
.socket-l { left: 39.5%; top: 53.5%; }
.socket-r { left: 62%; top: 53.5%; }
body.lit .socket { opacity: 1; }
body.lit .skull { filter: drop-shadow(0 30px 40px rgba(0,0,0,.8)) drop-shadow(0 0 28px rgba(125,255,106,.18)); }

.door-words {
  position: relative; z-index: 1;
  padding: 2vh 16px max(20px, 4vh);
  text-align: center;
  max-width: 620px;
  margin: 0 auto;
}
.wordmark {
  font-size: clamp(44px, 9vw, 84px);
  line-height: .95;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bone);
  text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 40px rgba(168,134,61,.25);
}
.wordmark span { display: inline-block; }
.voices { margin-top: 14px; display: grid; max-width: 52ch; margin-inline: auto; cursor: pointer; }
.voice { grid-area: 1 / 1; font-size: clamp(16px, 2.1vw, 19px); color: var(--bone); opacity: 0; transition: opacity 1.2s var(--ease); pointer-events: none; }
.voice.is-on { opacity: 1; pointer-events: auto; }
.voice .who { display: block; margin-top: 4px; font-size: 15px; font-style: italic; color: var(--brass); }
.voice .who::before { content: "\2014\00a0"; }
@media (prefers-reduced-motion: reduce) {
  .voices { display: block; }
  .voice { opacity: 1; transition: none; }
  .voice + .voice { margin-top: 10px; }
}
.status { margin-top: 10px; color: var(--bone-dim); font-style: italic; }

.keyhole {
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 18px;
  align-items: center;
  text-align: left;
  padding: 14px;
  border: 1px solid rgba(168,134,61,.45);
  background: rgba(10,12,10,.6);
  max-width: 560px;
}
.key-stage { position: relative; height: 210px; }
.key3d { position: absolute; inset: 0; cursor: grab; touch-action: none; }
.key3d:active { cursor: grabbing; }
.key3d canvas { width: 100% !important; height: 100% !important; display: block; }
.key-fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%; opacity: 1; transition: opacity .6s var(--ease); }
.key3d.is-ready + .key-fallback { opacity: 0; }
.lock { display: grid; gap: 10px; }
.lock-lead { font-size: 15px; color: var(--bone-dim); }
.lock-ways-box { min-height: 118px; }
.lock-way { display: grid; gap: 8px; }
.lock-way label { display: grid; gap: 3px; font-size: 14px; color: var(--bone-dim); }
.lock-way input, .bit select {
  font-family: var(--serif); font-size: 16px; color: var(--bone); background: var(--peat);
  border: 1px solid rgba(217,207,174,.3); padding: 7px 10px; width: 100%;
}
.lock-way input::placeholder { color: rgba(163,155,126,.5); }
.bit { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bit label { display: grid; gap: 3px; font-size: 14px; color: var(--bone-dim); }
.bit-lead { font-size: 15px; color: var(--bone-dim); }
.scan { position: relative; height: 118px; background: #000; border: 1px solid rgba(217,207,174,.2); overflow: hidden; }
.scan video { width: 100%; height: 100%; object-fit: cover; }
.scan-said { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 10px; font-size: 14px; color: var(--bone); background: rgba(10,12,10,.7); }
.lock-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 42px; }
.lock-said { font-size: 14px; color: var(--brass); }
.lock-ways { display: flex; gap: 18px; flex-wrap: wrap; }
.way { font-family: var(--serif); font-size: 14px; color: var(--bone-dim); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.way:hover { color: var(--bone); }
.turn {
  display: inline-block;
  padding: 8px 18px;
  color: var(--bog); background: var(--brass);
  font-family: var(--serif); font-size: 16px;
  border: 1px solid #c7a24f; cursor: pointer;
  transition: background .2s var(--ease);
}
.turn:hover { background: #c7a24f; }
.turn[disabled] { opacity: .6; cursor: default; }

@media (min-width: 560px) {
  .keyhole { grid-template-columns: 190px 1fr; }
  .key-stage { height: 100%; min-height: 230px; }
}

@media (min-width: 900px) {
  .door { grid-template-columns: 1.05fr 1fr; grid-template-rows: 100dvh; align-items: center; }
  .skull-stage { align-items: center; padding: 0 0 0 4vw; }
  .skull { width: min(40vw, 78dvh, 620px); }
  .door-words { text-align: left; margin: 0; padding: 0 6vw 0 0; max-width: 560px; }
  .voices, .keyhole { margin-inline: 0; }
  .door-words { max-width: 600px; }
}

/* door → shelf */
body.opening .door { opacity: 0; transform: scale(1.03); }
body.open .door { display: none; }
body.open { overflow: auto; height: auto; }

/* ---------- The shelf ---------- */
.shelf { opacity: 0; transition: opacity .9s var(--ease); }
body.open .shelf { opacity: 1; }

.mast {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background: rgba(10,12,10,.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(217,207,174,.12);
  transition: padding .35s var(--ease);
}
body.scrolled .mast { padding: 8px 20px; }
.mast-mark { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.mast-mark img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: 50% 42%; transition: width .35s var(--ease), height .35s var(--ease); }
body.scrolled .mast-mark img { width: 28px; height: 28px; }
.mast-nav { display: flex; gap: 18px; margin-left: 8px; }
.mast-nav a { text-decoration: none; color: var(--bone-dim); font-size: 15px; white-space: nowrap; }
@media (max-width: 520px) { .mast { gap: 10px; padding: 14px 14px; } .mast-mark { font-size: 16px; } .mast-nav { gap: 12px; margin-left: 0; } .mast-nav a { font-size: 14px; } }
.mast-nav a:hover { color: var(--bone); }
.keyhole-badge { color: var(--bone) !important; }

.shelf-hero { position: relative; max-height: 72vh; overflow: hidden; }
.shelf-hero img { width: 100%; height: 72vh; object-fit: cover; object-position: 50% 30%; }
.shelf-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,12,10,.1) 30%, rgba(10,12,10,.92) 100%); }
.shelf-hero-words { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 0 20px 34px; max-width: 760px; margin: 0 auto; }
.greet { color: var(--brass); font-style: italic; }
.shelf-hero-words h2 { font-size: clamp(36px, 6vw, 60px); line-height: 1; margin: 6px 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.shelf-hero-words p:last-child { max-width: 58ch; }

.keeper-bar {
  max-width: 1120px; margin: 24px auto 0; padding: 14px 20px;
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between;
  border: 1px solid rgba(168,134,61,.45); background: rgba(47,61,44,.25);
}
.keeper-bar code { font-family: inherit; color: var(--brass); }
.keeper-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.keeper-actions label { color: var(--bone-dim); font-size: 15px; }
select, .keeper-actions button, .card-tools select, .card-tools button {
  font-family: var(--serif); font-size: 15px;
  color: var(--bone); background: var(--peat);
  border: 1px solid rgba(217,207,174,.3); padding: 6px 10px;
}
.keeper-actions button:hover, .card-tools button:hover { border-color: var(--brass); }

.rooms-head { max-width: 1120px; margin: 44px auto 0; padding: 0 20px; }
.rooms-head h3, .ledger h3 { font-size: 30px; text-transform: uppercase; letter-spacing: .05em; }
.rooms-key { color: var(--bone-dim); font-size: 15px; margin-top: 6px; }
.pip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; }
.pip-dealt { background: var(--bone); }
.pip-hand { background: var(--brass); }
.pip-pot { background: var(--moss); border: 1px solid var(--bone-dim); }

.rooms {
  list-style: none; margin: 18px auto 0; padding: 0 20px;
  max-width: 1120px;
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.card {
  display: grid; grid-template-rows: auto 1fr;
  background: var(--peat);
  border: 1px solid rgba(217,207,174,.14);
  min-height: 100%;
}
.card-face {
  position: relative; aspect-ratio: 5 / 7; overflow: hidden;
  background: var(--moss);
}
.card-face img { width: 100%; height: 100%; object-fit: cover; }
.card-face img.contain { object-fit: contain; background: #000; }
.card-face .hour {
  position: absolute; top: 8px; left: 10px;
  font-size: 15px; color: var(--bone); text-shadow: 0 1px 2px #000;
}
.card-face .hour::after { content: ""; display: block; width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; background: var(--hour, var(--bone)); box-shadow: 0 0 10px var(--hour, var(--bone)); }
.card.pot .card-face img { filter: saturate(.25) brightness(.5); }
.card.pot .card-face::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(160deg, color-mix(in srgb, var(--hour) 35%, transparent), rgba(10,12,10,.7));
}
.card.pot .ground {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 1;
  font-size: 22px; font-style: italic; color: var(--bone); text-shadow: 0 2px 6px #000;
}
.card:not(.pot) .ground { display: none; }
.card-body { padding: 14px 14px 16px; display: grid; gap: 8px; align-content: start; }
.card-body h4 { margin: 0; font-size: 22px; font-weight: 400; line-height: 1.15; }
.card-body .what { color: var(--bone); font-size: 15px; }
.card-body .holds { color: var(--bone-dim); font-size: 14px; }
.card-body .stands { font-size: 14px; color: var(--bone-dim); }
.card-body .stands .pip { margin-right: 6px; }
.card-body .note { font-size: 14px; color: var(--brass); font-style: italic; }
.card-body .open-link { font-size: 15px; margin-top: 2px; }
.card-tools { display: grid; gap: 6px; padding-top: 8px; border-top: 1px dashed rgba(217,207,174,.2); }
.card-tools textarea {
  font-family: var(--serif); font-size: 14px; color: var(--bone); background: var(--peat);
  border: 1px solid rgba(217,207,174,.3); padding: 6px 8px; min-height: 48px; resize: vertical; width: 100%;
}
.card-tools .order { display: flex; gap: 6px; }
.card-tools .order button { flex: 1; }

.ledger { max-width: 1120px; margin: 56px auto 0; padding: 0 20px; }
.ledger p { color: var(--bone-dim); margin-top: 6px; }
.ledger table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 15px; }
.ledger th { text-align: left; font-weight: 400; color: var(--brass); border-bottom: 1px solid rgba(168,134,61,.45); padding: 8px 10px 8px 0; }
.ledger td { vertical-align: top; padding: 10px 10px 10px 0; border-bottom: 1px solid rgba(217,207,174,.1); }
.ledger td:nth-child(3), .ledger td:nth-child(5) { color: var(--bone-dim); }
@media (max-width: 680px) {
  .ledger table, .ledger thead, .ledger tbody, .ledger tr, .ledger td { display: block; }
  .ledger thead { display: none; }
  .ledger tr { padding: 10px 0; border-bottom: 1px solid rgba(217,207,174,.14); }
  .ledger td { border: 0; padding: 2px 0; }
  .ledger td::before { content: attr(data-l) ": "; color: var(--brass); }
}

.shelf-foot { text-align: center; color: var(--bone-dim); padding: 60px 20px 40px; font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .door, .socket, .shelf, .mast, .mast-mark img, .turn { transition: none; }
}
