/* Copyright (c) 2026 Peter Mayhew. All rights reserved. Not licensed for copying or reuse. */
/* An old bathhouse: bottle-green glazed brick, cream enamel signs, brass edges. */
:root {
  --deep: #12302d; --brick: #1d443f; --glaze: #2c6a60; --cream: #f7eed8; --paper: #fffaf0;
  --ink: #14211f; --brass: #d9a441; --brass-dark: #7c5518; --red: #a8321f; --orange: #f08a2c;
  --sign: Rockwell, "Roboto Slab", "Bookman Old Style", "Sitka Heading", Georgia, serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%; color: var(--cream); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--deep);
  background-image: linear-gradient(rgba(0, 0, 0, .18) 2px, transparent 2px), linear-gradient(90deg, rgba(0, 0, 0, .18) 2px, transparent 2px);
  background-size: 64px 32px, 64px 32px;
}
[hidden] { display: none !important; }
h1, h2 { font-family: var(--sign); line-height: 1.1; margin: 0; }
.loading { padding: 3rem 1rem; text-align: center; }
.small { font-size: .9rem; margin: .4rem 0; opacity: .92; }
.lead { font-size: 1.08rem; max-width: 34em; margin: .4rem auto; text-align: center; }

button {
  font: 600 1rem/1.2 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--cream);
  border: 2px solid var(--brass-dark); border-radius: 10px; padding: .65rem 1rem; min-height: 46px; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 3px 0 var(--brass-dark);
}
button:hover:not(:disabled) { background: #fff; }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--brass-dark); }
button:disabled { opacity: .5; cursor: default; box-shadow: none; }
button.big { background: var(--brass); font-size: 1.15rem; }
button.big:hover:not(:disabled) { background: #eab95a; }
button.round { min-width: 46px; padding: .3rem .5rem; }
:focus-visible { outline: 3px solid #ffe27a; outline-offset: 3px; }
dialog :focus-visible { outline-color: var(--red); }

.screen { max-width: 46rem; margin: 0 auto; padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.2rem, env(safe-area-inset-bottom)); }
.bar { display: flex; align-items: center; gap: .5rem; }
.bar h1 { flex: 1; font-size: 1.25rem; min-width: 0; }
.stack { display: grid; gap: .7rem; width: min(20rem, 100%); margin: 1rem auto; }
.pair { display: grid; grid-template-columns: 1fr auto; gap: .6rem; }
dialog .pair { grid-template-columns: 1fr 1fr; }

/* Title */
#title { text-align: center; }
.sign { position: relative; border: 5px solid var(--brass); border-radius: 22px; overflow: hidden; background: #2b9a9a; box-shadow: 0 0 0 3px var(--brass-dark), 0 12px 30px rgba(0, 0, 0, .4); }
#pond { display: block; width: 100%; height: clamp(190px, 34vh, 300px); }
.sign h1 { background: var(--cream); color: var(--ink); font-size: clamp(2.2rem, 10vw, 4rem); letter-spacing: .01em; padding: .25em .3em .3em; border-top: 5px solid var(--brass); }

/* Rooms */
.wing { background: rgba(0, 0, 0, .22); border: 2px solid var(--glaze); border-radius: 14px; padding: .8rem; margin: .8rem 0; }
.wing h2 { font-size: 1.25rem; color: #ffe2a0; }
.wing p { margin: .2rem 0 .6rem; }
.doors { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr)); }
.door { width: 100%; height: 100%; display: grid; justify-items: center; align-content: start; gap: .15rem; padding: .55rem .4rem; }
.door .num { font: 700 1.5rem/1 var(--sign); }
.door .nm { font-size: .85rem; }
.door.won { background: #d7efdc; }
.badges { letter-spacing: .25em; font-size: 1.05rem; margin-right: -.25em; }
.badges span { opacity: .22; }
.badges .on { opacity: 1; color: #74480a; }

/* Playing: the room takes whatever space is left */
#play { max-width: none; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: .35rem; padding: max(.4rem, env(safe-area-inset-top)) .4rem max(.5rem, env(safe-area-inset-bottom)); overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#play .bar { width: 100%; max-width: 46rem; margin: 0 auto; }
#play .bar button { min-height: 44px; }
#leave { padding: .2rem .8rem; font-size: 1.4rem; }
#roomName { font-size: clamp(.95rem, 4vw, 1.25rem); }
#efts { letter-spacing: .12em; font-size: 1.1rem; white-space: nowrap; }
#efts span { color: transparent; -webkit-text-stroke: 1.5px #ffd75a; }
#efts .on { color: #ffd75a; }
#plugMark { opacity: .3; font-size: 1.3rem; }
#plugMark.on { opacity: 1; color: var(--brass); }
#tip { min-height: 2.7em; margin: 0 auto; max-width: 40rem; text-align: center; font-size: .95rem; line-height: 1.35; display: flex; align-items: center; justify-content: center; padding: 0 .4rem; }
#roomBox { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#room { display: block; border-radius: 8px; touch-action: none; outline-offset: 2px; box-shadow: 0 0 0 3px var(--brass-dark), 0 0 0 6px var(--brass); }
#gl { display: none; }
.deep { position: relative; }
.deep #gl { display: block; position: absolute; left: 50%; top: 0; transform: translateX(-50%); border-radius: 10px; }
.deep #room { position: absolute; left: 50%; top: 0; transform: translateX(-50%); border-radius: 10px; box-shadow: inset 0 0 0 2px var(--brass-dark); }
#controls { display: none; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .6rem 0; touch-action: none; }
.lefty #controls { flex-direction: row-reverse; }
.middle { display: grid; gap: .5rem; }
.middle button { min-height: 44px; padding: .4rem .7rem; font-size: .9rem; }
#pad { position: relative; width: 148px; height: 148px; flex: none; border-radius: 50%; background: rgba(0, 0, 0, .3); border: 3px solid var(--brass); touch-action: none; }
#pad i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 10px; background: var(--cream); pointer-events: none; }
#pad i::after { content: ''; position: absolute; inset: 13px; background: var(--ink); clip-path: polygon(50% 12%, 100% 82%, 0 82%); }
#pad i:nth-child(1) { transform: translateY(-46px); }
#pad i:nth-child(2) { transform: translateX(46px) rotate(90deg); }
#pad i:nth-child(3) { transform: translateY(46px) rotate(180deg); }
#pad i:nth-child(4) { transform: translateX(-46px) rotate(-90deg); }
#pad[data-dir="0"] i:nth-child(1), #pad[data-dir="1"] i:nth-child(2), #pad[data-dir="2"] i:nth-child(3), #pad[data-dir="3"] i:nth-child(4) { background: var(--brass); }
#act { width: 104px; height: 104px; flex: none; border-radius: 50%; padding: .3rem; touch-action: none; opacity: .75; }
#act.live { opacity: 1; background: var(--orange); }
.keys { text-align: center; font-size: .88rem; margin: .2rem 0 0; opacity: .85; }
@media (pointer: coarse), (max-width: 620px) { #controls { display: flex; } .keys { display: none; } }
@media (pointer: fine) and (min-width: 621px) { #controls { display: flex; justify-content: center; padding-top: .3rem; } #pad { display: none; } #act { width: auto; height: auto; border-radius: 10px; min-width: 8rem; order: -1; } .middle { display: flex; } }
/* A phone on its side: controls either side of the room. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 560px) {
  #play { display: grid; grid-template: auto 1fr / 168px 1fr 148px; column-gap: .5rem; }
  #play .bar { grid-column: 1 / -1; max-width: none; }
  #tip { grid-column: 1; grid-row: 2; align-self: start; font-size: .82rem; }
  #roomBox { grid-column: 2; grid-row: 2; }
  #controls { display: contents; }
  #pad { grid-column: 1; grid-row: 2; align-self: end; }
  .middle { grid-column: 3; grid-row: 2; align-self: start; }
  #act { grid-column: 3; grid-row: 2; align-self: end; justify-self: center; }
}

/* Dialogs: enamel signs */
dialog { width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem); overflow: auto; border: 5px solid var(--brass); border-radius: 18px; background: var(--paper); color: var(--ink); padding: 1.1rem; box-shadow: 0 0 0 3px var(--brass-dark), 0 20px 60px rgba(0, 0, 0, .5); }
dialog::backdrop { background: rgba(6, 18, 17, .7); }
dialog h2 { font-size: 1.6rem; outline: none; }
dialog > button, dialog > .pair, dialog > .toggles { margin-top: .7rem; width: 100%; }
.key { margin: 0; display: grid; gap: .45rem; }
.key > div { display: grid; grid-template-columns: 116px 1fr; gap: .7rem; align-items: center; }
.key dt { text-align: right; } .key dd { margin: 0; font-size: .95rem; }
.key canvas { height: 38px; border-radius: 6px; vertical-align: middle; }
.toggle { display: flex; gap: .7rem; align-items: center; min-height: 44px; }
.toggle input { width: 24px; height: 24px; accent-color: var(--glaze); }
#resultList { list-style: none; padding: 0; margin: .7rem 0; display: grid; gap: .4rem; }
#resultList li { display: flex; gap: .7rem; align-items: center; opacity: .62; }
#resultList li.on { opacity: 1; font-weight: 600; }
#resultList li > span:first-child { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 50%; border: 2px dashed #999; font-size: 1.2rem; flex: none; }
#resultList li.on > span:first-child { background: var(--brass); border: 2px solid var(--brass-dark); }
#ending { text-align: center; padding-top: 12vh; }
#ending h1 { font-size: 2.2rem; color: #ffe2a0; margin-bottom: 1rem; }
@media (prefers-reduced-motion: no-preference) { #roomBox.waiting:not(.deep) #room { animation: wait 1.8s ease-in-out infinite; } @keyframes wait { 50% { filter: brightness(.94); } } }
