:root {
  color-scheme: dark;
  --gold: #d6b985;
  --ivory: #fcf0e0;
  --heading: Cinzel, 'Palatino Linotype', Georgia, serif;
  --edge: clamp(10px, 2vw, 28px);
  --secondary-background: #261c31;
  --secondary-hover: #473350;
  --secondary-border: #a88b62;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #181422; color: var(--ivory); font: .9375rem Georgia, serif; -webkit-user-select: none; user-select: none; }
button { cursor: pointer; color: inherit; font: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: background-color .2s ease, color .2s ease, opacity .24s ease, box-shadow .24s ease; }
button:focus-visible { outline: 2px solid #fff2be; outline-offset: 3px; }
#game {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #302739, #191421 72%);
  --top: max(var(--edge), env(safe-area-inset-top));
  --right: max(var(--edge), env(safe-area-inset-right));
  --bottom: max(var(--edge), env(safe-area-inset-bottom));
  --left: max(var(--edge), env(safe-area-inset-left));
  --gift-size: clamp(44px, 6vw, 56px);
  -webkit-touch-callout: none;
}
#backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
#art-bleed { position: absolute; inset: -20px; background: center / cover no-repeat; filter: blur(20px) brightness(.47) saturate(.8); }
#art { position: absolute; background: center / contain no-repeat; }
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.place { position: absolute; bottom: var(--ui-bottom, var(--bottom)); left: 50%; transform: translateX(-50%); text-align: center; padding: .42rem .9rem; background: #181321ed; border: 1px solid #a083579e; box-shadow: 0 .3rem 1.2rem #100b1c65; }
h1, h2 { font-family: var(--heading); font-weight: 600; color: #efd3a5; }
h1 { font-size: .82rem; margin: 0; letter-spacing: .07em; white-space: nowrap; }
#game[data-screen=scene] .place { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.gifts { position: absolute; top: var(--ui-top, var(--top)); right: var(--ui-right, var(--right)); display: flex; gap: 6px; }
.gift, .inventory-item { display: grid; place-items: center; border: 1px solid #ac8b60; background: radial-gradient(ellipse at center, #493347, #201828 80%); box-shadow: 0 .2rem .65rem #120c1f70; }
.gift { pointer-events: auto; width: var(--gift-size); height: var(--gift-size); padding: 4px; border-radius: 7px; }
img { display: block; max-width: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.gift img, .inventory-item img { width: 100%; height: 100%; min-width: 0; min-height: 0; }
.panel {
  background: radial-gradient(ellipse at 50% 0%, #35263c, #191421 87%);
  border: 1px solid var(--gold);
  border-radius: 7px;
  box-shadow: inset 0 0 0 4px #211828, inset 0 0 0 5px #99784b74, 0 .6rem 2.25rem #140d20ad;
}
.dialogue {
  position: absolute;
  left: var(--ui-left, var(--left));
  right: var(--ui-right, var(--right));
  bottom: var(--ui-bottom, var(--bottom));
  width: min(800px, 82vw, calc(100% - var(--ui-left, var(--left)) - var(--ui-right, var(--right))));
  margin-inline: auto;
  padding: 8px 12px;
  border-color: #c5a876;
  border-radius: 5px;
  background: linear-gradient(145deg, #2e2135f5, #191421f5);
  box-shadow: inset 0 0 0 2px #231b2a, inset 0 0 0 3px #a78b5b65, 0 .4rem 1.4rem #130c21a0;
}
.dialogue h2 { font-size: .94rem; margin: 0 0 .25rem; }
#lines { line-height: 1.35; font-size: .9375rem; overflow-wrap: anywhere; }
#lines p { margin: 0; }
#lines p + p { margin-top: .45em; }
.dialogue-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: .4rem; }
.action { min-height: 44px; min-width: 44px; font-family: var(--heading); font-size: .77rem; font-weight: 700; letter-spacing: .035em; color: #2f2032; background: #e3c698; padding: .35rem .85rem; border: 1px solid #f7ddab; border-radius: 4px; }
.action:disabled { opacity: .4; cursor: default; }
.action:hover { background: #f4dbb0; }
.action.secondary { color: #f0d6a9; background: var(--secondary-background); border-color: var(--secondary-border); }
.action.secondary:hover { background: var(--secondary-hover); }
.dialogue-actions .action { position: relative; min-height: 30px; padding: .2rem .65rem; }
.dialogue-actions .action::after { content: ''; position: absolute; inset: -7px 0; }
.dialogue-choices { display: flex; flex-wrap: wrap; gap: 6px; justify-content: end; }
.dialogue-choices:empty { display: none; }
.dialogue-choices .action { text-align: left; }
#hotspots { position: absolute; inset: 0; padding: var(--top) var(--right) var(--bottom) var(--left); pointer-events: none; }
.anchored { position: absolute; top: var(--y); left: var(--x); transform: translate(-50%, -50%); pointer-events: auto; }
.map-pin { min-width: 44px; min-height: 44px; max-width: calc(100vw - 32px); border: 0; background: transparent; color: #fff1da; text-shadow: 0 1px 3px #160d20, 0 0 7px #160d20, 0 0 9px #000; font: 700 .76rem var(--heading); }
.clue { background: #21172df0; border: 1px solid currentColor; padding: .36rem .55rem; border-radius: 5px; text-align: center; box-shadow: 0 .25rem .85rem #160e26a0; }
.contour { position: absolute; overflow: visible; pointer-events: none; --halo-width: 19px; --light-width: 7px; --halo-blur: 14px; --light-blur: 8px; --glow-strength: 1; }
.contour path { vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.contour .halo { fill: var(--glow); fill-opacity: .11; stroke: var(--glow); stroke-width: var(--halo-width); opacity: calc(.56 * var(--power, 1) * var(--reveal, 1) * var(--glow-strength)); filter: blur(var(--halo-blur)); transition: opacity .32s ease-in-out; }
.contour .light { fill: none; stroke: var(--glow); stroke-width: var(--light-width); opacity: calc(.32 * var(--power, 1) * var(--reveal, 1) * var(--glow-strength)); filter: blur(var(--light-blur)); transition: opacity .32s ease-in-out; }
.item-contour { --halo-width: 11px; --light-width: 5px; --halo-blur: 9px; --light-blur: 5px; }
.item-contour .halo { fill-opacity: .04; }
.map-next .halo { animation: destination-pulse 2.8s ease-in-out infinite; }
@keyframes destination-pulse {
  0%, 100% { stroke-width: var(--halo-width); }
  50% { stroke-width: calc(var(--halo-width) * 1.65); }
}
.contour .hit-shape { fill: transparent; pointer-events: fill; cursor: pointer; }
.contour.map-visited { --reveal: 0; }
.contour.map-visited:has(.hit-shape:hover, + .map-pin:hover, + .map-pin:focus-visible) { --reveal: 1; }
.map-pin.map-visited { opacity: .76; }
.map-pin.map-visited:hover, .map-pin.map-visited:focus-visible { opacity: 1; }
.map-pin:focus-visible, .pickup button:focus-visible { outline: none; }
.map-pin:focus-visible { text-decoration: underline; text-underline-offset: 4px; }
.map-exit { position: absolute; right: var(--ui-right, var(--right)); bottom: var(--ui-bottom, var(--bottom)); pointer-events: auto; min-height: 32px; }
.scene-actions { position: absolute; right: var(--ui-right, var(--right)); bottom: var(--ui-bottom, var(--bottom)); left: var(--ui-left, var(--left)); display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.scene-actions button { pointer-events: auto; }
.pickup { min-width: 48px; min-height: 48px; width: min(var(--target-width), 42vw); height: min(var(--target-height), 29dvh); }
.pickup button { width: 100%; height: 100%; border: 0; border-radius: 8px; background: transparent; }
.clue { position: absolute; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(14rem, calc(100vw - 32px)); bottom: calc(100% + 12px); color: #ffe2a8; pointer-events: none; }
.pickup.clue-below .clue { top: calc(100% + 12px); bottom: auto; }
.sound-control svg { display: block; width: 22px; height: 22px; }
.time-picker { --y: 50%; pointer-events: none; }
.time-buttons { --time-icon-size: 26px; display: grid; justify-items: start; gap: 3px; }
.time-buttons button { pointer-events: auto; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--secondary-border); border-radius: 50%; background: var(--secondary-background); box-shadow: 0 2px 6px #100b1cb0; }
.time-buttons button:hover { background: var(--secondary-hover); }
.purse-times .time-buttons button:nth-child(2), .purse-times .time-buttons button:nth-child(3) { margin-left: 17px; }
.time-icon { width: var(--time-icon-size); height: var(--time-icon-size); filter: drop-shadow(0 1px 2px #000) drop-shadow(0 0 3px #21172d); transition: filter .24s ease; }
.time-buttons button[aria-pressed=true] { border-color: #f7ddab; box-shadow: 0 2px 6px #100b1cb0, 0 0 6px #ffd58390; }
.time-buttons button[aria-pressed=true] .time-icon { filter: drop-shadow(0 1px 2px #000) drop-shadow(0 0 4px #ffd583); }
.time-buttons button:focus-visible { outline: 1px solid #fff0c6; outline-offset: 2px; }
.time-hint { position: absolute; top: var(--hint-y, auto); left: var(--ui-left, var(--left)); right: var(--ui-right, var(--right)); margin: 0; text-align: center; color: #f2d7af; font-size: .85rem; text-shadow: 0 1px 4px #000, 0 0 8px #000; }
dialog {
  color: var(--ivory);
  width: min(480px, calc(100% - var(--ui-left, var(--left)) - var(--ui-right, var(--right))));
  max-width: none;
  max-height: calc(100% - var(--ui-top, var(--top)) - var(--ui-bottom, var(--bottom)));
  inset: var(--ui-top, var(--top)) var(--ui-right, var(--right)) var(--ui-bottom, var(--bottom)) var(--ui-left, var(--left));
  margin: auto;
  padding: clamp(19px, 4vw, 32px);
  overflow: auto;
  text-align: center;
}
dialog::backdrop { background: #130d21a6; animation: backdrop-in 220ms ease both; }
dialog[data-closing]::backdrop { animation: backdrop-out 180ms ease both; }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }
dialog h2 { font-size: clamp(1rem, 2.2vw, 1.2rem); margin: 0; }
#popup-title:focus { outline: none; }
dialog p { margin: .65rem 0 0; font-size: .9375rem; line-height: 1.4; }
.popup-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.popup-art { margin: .65rem auto 0; width: min(100%, 235px); height: min(33dvh, 235px); }
.inventory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; margin-top: .9rem; }
.inventory-item { padding: .35rem; border-radius: 5px; aspect-ratio: 1; min-width: 0; }
dialog.compact-inventory { overflow: hidden; padding: 8px 12px; }
.compact-inventory h2 { font-size: 1rem; }
.compact-inventory .inventory-grid {
  --item: clamp(16px, calc((var(--art-height, 100dvh) - 114px) / var(--rows, 1)), 86px);
  grid-template-columns: repeat(3, var(--item));
  grid-auto-rows: var(--item);
  justify-content: center;
  gap: 4px;
  margin-top: 5px;
}
.compact-inventory .inventory-item { width: var(--item); height: var(--item); padding: 3px; }
.compact-inventory .popup-actions { margin-top: 6px; }
.compact-inventory .popup-actions .action { min-height: 32px; }
.flying-gift { position: absolute; z-index: 10; pointer-events: none; }
.inventory-nudge { position: absolute; left: 50%; top: calc(var(--ui-top, var(--top)) + var(--art-height, 100dvh) * .38); translate: -50% -50%; padding: .4rem .65rem; border: 1px solid #bb9764; border-radius: 5px; background: #20172bec; color: #ffdda0; white-space: nowrap; text-shadow: 0 1px 4px #140b1f; box-shadow: 0 4px 16px #20112788; }
dialog.photo-popup { width: min(680px, calc(100% - var(--ui-left, var(--left)) - var(--ui-right, var(--right)))); }
.photo-print { margin: .55rem auto 0; }
.photo-print img { width: auto; height: auto; max-height: min(320px, calc(var(--art-height, 100dvh) - 115px)); margin-inline: auto; border: 1px solid #b59060; }
.photo-flash { position: absolute; inset: 0; z-index: 6; background: #fff9e7; animation: photo-flash 320ms ease-out both; pointer-events: none; }
@keyframes photo-flash { to { opacity: 0; } }
.final-avatar { width: 68px; height: 68px; margin: .45rem auto 0; border: 1px solid #b59060; border-radius: 50%; }
.menu-toggle { position: absolute; top: var(--ui-top, var(--top)); left: var(--ui-left, var(--left)); pointer-events: auto; z-index: 3; border: 1px solid #b89c6f; border-radius: 4px; background: #1d1728e8; color: #f1d9b2; font-size: .72rem; padding: 5px 7px; }
.sound-control { position: absolute; z-index: 3; left: var(--ui-left, var(--left)); bottom: var(--ui-bottom, var(--bottom)); display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #b89c6f; border-radius: 6px; background: #1e1629e8; color: #f1d6a9; }
.dialogue { bottom: calc(var(--ui-bottom, var(--bottom)) + 7px); width: min(800px, 82vw, calc(100% - var(--ui-left, var(--left)) - var(--ui-right, var(--right)) - 94px)); }
.save-status { position: absolute; z-index: 4; bottom: calc(var(--ui-bottom, var(--bottom)) + 48px); right: var(--ui-right, var(--right)); max-width: min(330px, 80vw); margin: 0; padding: 6px 9px; background: #20162aed; border: 1px solid #ac8b60; border-radius: 5px; color: #ffe6b8; }
#gate { display: grid; align-items: center; min-height: 100vh; min-height: 100dvh; padding: 7vh 0 0 6.5vw; background: #302738 url('assets/login-gate-dawn-v2.webp') center / cover no-repeat; }
#entrance { width: min(30vw, 330px); min-width: 240px; padding: clamp(18px, 3vw, 32px); display: grid; gap: 12px; background: linear-gradient(145deg, #33283de8, #1b1628ed); }
#entrance h1, #admin-panel h1 { font-size: clamp(1.25rem, 3vw, 1.8rem); margin-bottom: .15rem; }
#entrance label { display: grid; gap: 5px; font: 600 .86rem var(--heading); color: #efd3a5; }
#entrance input { min-width: 0; width: 100%; min-height: 40px; padding: 7px 9px; border: 1px solid #a28558; border-radius: 4px; color: var(--ivory); background: #1c1529; font: 1rem Georgia, serif; user-select: text; -webkit-user-select: text; }
#entrance input:focus { outline: 2px solid #ddbe86; outline-offset: 1px; }
#gate-status:empty { display: none; }
#gate-status { margin: 0; line-height: 1.35; }
#gate[data-checking] #entrance { visibility: hidden; }
#admin-panel { min-height: 100vh; min-height: 100dvh; padding: 24px 12px; background: linear-gradient(#1c142bdc, #171220f5), #302738 url('assets/login-gate-dawn-v2.webp') center / cover fixed; }
.admin-card { max-width: 740px; margin-inline: auto; padding: clamp(16px, 4vw, 32px); }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
#admin-summary { display: grid; grid-template-columns: minmax(85px, 1fr) 3fr; gap: .6rem 1rem; }
#admin-summary dt { color: #e9cda1; }
#admin-summary dd { margin: 0; }
#admin-activity { line-height: 1.45; padding-left: 1.45rem; }
#admin-activity li { margin-bottom: .5rem; }
@media (hover: none) and (pointer: coarse) {
  .contour { --halo-width: 9px; --light-width: 3px; --halo-blur: 7px; --light-blur: 4px; --glow-strength: .72; }
  .item-contour { --halo-width: 5px; --light-width: 2px; --halo-blur: 5px; --light-blur: 3px; }
}
@media (max-height: 530px) { dialog { padding: 15px; } .popup-art { height: 29dvh; } }
@media (max-width: 500px) and (orientation: portrait) {
  .dialogue { width: auto; max-width: 355px; bottom: calc(var(--ui-bottom, var(--bottom)) + 35px); }
  .sound-control { width: 34px; height: 34px; }
  #gate { justify-items: center; padding: 15vh 14px 0; background-position: 12% center; }
  #entrance { width: min(100%, 310px); min-width: 0; }
  .time-buttons { gap: 1px; }
  .time-buttons button { width: 34px; height: 34px; }
  .map-pin { max-width: 74px; padding-inline: 3px; font-size: .67rem; line-height: 1.05; }
  dialog { padding: 10px 12px; }
  .popup-actions { margin-top: .55rem; }
  .popup-art { height: min(15dvh, 88px); }
  .illustrated-popup .popup-art { height: clamp(36px, calc(var(--art-height, 100dvh) - 143px), 88px); }
  .popup-actions .action { min-height: 34px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
