:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #f4f9ff;
  background: #0a172b;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .22em; }
button {
  min-height: 44px;
  padding: .65rem 1rem;
  color: inherit;
  background: #10263b;
  border: 1px solid #92bdccaa;
  border-radius: .5rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
button:focus-visible, a:focus-visible { outline: 3px solid #fff09a; outline-offset: 3px; }
.welcome {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4rem;
  padding: clamp(1.25rem, 6vw, 6rem);
  background: linear-gradient(90deg, #071224e8, #07122436 72%), url('waterfront.webp') center / cover;
}
.brand, .eyebrow {
  margin: 0;
  color: #a4fff4;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.welcome-copy { max-width: 42rem; }
.welcome h1 {
  margin: .25rem 0 1rem;
  font: 600 clamp(3rem, 8vw, 7.5rem)/.94 Georgia, serif;
  letter-spacing: -.05em;
  text-wrap: balance;
}
.welcome-copy > p:not(.eyebrow) { max-width: 36rem; line-height: 1.6; }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .9rem 1.4rem; margin: 1.5rem 0; }
#start, #use { color: #071b2b; background: #a4fff4; border-color: #a4fff4; }
.controls { color: #daebfa; font-size: .9rem; }
#game { position: fixed; inset: 0; }
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#world-view, #view { position: absolute; inset: 0; }
#world-view { pointer-events: none; }
#view.over-webgl { opacity: 0; }
#game:has(#view.over-webgl:focus-visible) { outline: 2px solid #fff09a; outline-offset: -3px; }
canvas:focus-visible { outline: 2px solid #fff09a; outline-offset: -3px; }
.hud {
  position: absolute;
  inset: max(.75rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) auto max(.75rem, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  pointer-events: none;
}
.location, .hud-actions, #goal { background: #0a1a2cf5; padding: .6rem .8rem; border: 1px solid #8cc2db66; border-radius: .65rem; }
.location h1 { font-size: clamp(1.05rem, 3vw, 1.65rem); margin: .12rem 0 0; }
#city-render-status { margin: .3rem 0 0; color: #daebfa; font-size: .8rem; }
#city-render-status:empty { margin: 0; }
.hud-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .55rem 1rem; font-size: .875rem; pointer-events: auto; }
#city-graphics { white-space: nowrap; }
#city-quality { background: #13283b; color: inherit; font: inherit; border: 1px solid #8cc2db88; border-radius: .35rem; padding: .35em; }
#goal { position: absolute; left: 50%; bottom: max(.75rem, env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: min(90%, 35rem); text-align: center; font-size: .95rem; }
#use { display: block; margin: .45rem auto 0; }
#stick {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  touch-action: none;
  border: 1px solid #c8f7f7aa;
  background: #13283bd9;
  border-radius: 50%;
}
#knob { border-radius: 50%; width: 36px; height: 36px; background: #b4eeea; pointer-events: none; }
dialog { width: min(94vw, 42rem); max-height: 85dvh; overflow: auto; padding: clamp(.8rem, 3vw, 1.5rem); background: #101e30; color: inherit; border: 1px solid #688da2; border-radius: .8rem; }
dialog::backdrop { background: #071222bd; }
dialog h2 { margin: .3em 0; }
dialog p, #log { line-height: 1.5; }
#grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .25rem; }
#grid button { font-size: .8rem; padding: .4rem .25rem; background: #1b3042; border-radius: .25rem; overflow-wrap: anywhere; }
#grid .here { outline: 2px solid #ffdd8c; }
#grid .seen { color: #8df2db; }
#close { float: right; }
@media (max-width: 700px) {
  .welcome { background-image: linear-gradient(0deg, #071224f7 12%, #07122422 95%), url('waterfront.webp'); }
  #goal { left: max(7.1rem, calc(env(safe-area-inset-left) + 6rem)); right: max(.6rem, env(safe-area-inset-right)); transform: none; width: auto; max-width: none; font-size: .875rem; }
  .hud-actions { flex-direction: column-reverse; align-items: flex-end; }
}
@media (max-height: 500px) {
  .welcome { gap: 1.5rem; }
  .welcome h1 { font-size: clamp(2rem, 7vw, 4rem); }
}
#sound[aria-pressed="true"] { border-color: #a4fff4; color: #a4fff4; }
@media (max-width: 700px) {
  .hud-actions { gap: .35rem; flex-direction: row; max-width: 12rem; padding: .4rem; }
  .hud-actions a { order: 1; width: 100%; text-align: right; padding: .25rem; }
  .hud-actions button { padding: .4rem .53rem; }
}

#city-menu { pointer-events: auto; max-width: 65%; }
#city-menu summary { width: max-content; margin-left: auto; padding: .7rem; min-height: 44px; cursor: pointer; background: #10263b; border: 1px solid #8cc2db88; border-radius: .5rem; font-size: .9rem; }
#city-menu[open] .hud-actions { margin-top: .25rem; }
#grid button[aria-pressed="true"] { border-color: #a4fff4; }
#follow { margin-top: .7rem; }

.welcome { position:relative; isolation:isolate; overflow:hidden; }
#waterfront-scene { position:absolute; inset:0; pointer-events:none; z-index:-2; }
.welcome::after { content:""; position:absolute; inset:0; pointer-events:none; z-index:-1;
 background:linear-gradient(90deg,#071224c9,transparent 73%); }
@media(max-width:700px){.welcome::after{background:linear-gradient(0deg,#071224e8 4%,transparent 87%);}}
#city-vitals { margin: .2rem 0 0; color: #c7f5ee; font-size: .82rem; }
#movement-actions, #combat-actions { position: absolute; display: flex; gap: .35rem; touch-action: none; }
#movement-actions { left: max(.65rem, env(safe-area-inset-left)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 96px); }
#combat-actions { right: max(.65rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); }
#movement-actions button, #combat-actions button { min-height: 44px; background: #12263aee; }
#combat-actions [data-hold="KeyF"] { background: #781e42; border-color: #f7a3c2; }
#reticle { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 12px; height: 12px; border: 1px solid #e1ffff; border-radius: 50%; pointer-events: none; }
#patrol { display: block; margin-top: .18rem; color: #b2d6df; }
@media (max-width: 790px) {
  #goal { bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 150px); left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 1.25rem); }
}
@media (max-height: 500px) {
  #goal { bottom: max(.65rem, env(safe-area-inset-bottom)); max-width: min(47vw, calc(100vw - 330px)); }
}
@media (orientation: landscape) and (max-width: 790px) and (max-height: 500px) {
  #goal { bottom: calc(max(.65rem, env(safe-area-inset-bottom)) + 143px); max-width: calc(100vw - 1.3rem); }
}

#game {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#combat-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(49px, auto)) clamp(72px, 16vw, 88px);
  grid-template-rows: repeat(3, minmax(44px, auto));
}
#combat-actions button { min-height: 44px; padding: .35rem .5rem; }
#aim-stick {
  grid-area: 1 / 3 / 4 / 4;
  align-self: end;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #f7a3c2aa;
  border-radius: 50%;
  background: #32172bd9;
  touch-action: none;
  cursor: grab;
}
#aim-knob {
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f2a8c5;
  pointer-events: none;
}
@media (max-width: 360px) {
  #combat-actions { gap: .25rem; }
  #combat-actions button { font-size: .85rem; padding-inline: .35rem; }
  #stick { width: 76px; height: 76px; }
}

#city-lock {
  position: absolute;
  top: calc(50% + 15px);
  left: 50%;
  transform: translateX(-50%);
  color: #c5ffe2;
  text-shadow: 0 1px 5px #001914;
  font-size: .75rem;
  pointer-events: none;
}
#game[data-target-lock] #reticle { border: 2px solid #a1ffc1; box-shadow: 0 0 10px #7afcae; }
#combat-actions button:active, #movement-actions button:active { outline: 2px solid #c9fef4; }

#talk-sammy { display: block; margin: .35rem auto 0; min-height: 44px; }
#talk-sammy[hidden] { display: none; }
#sammy-dialog button { min-height: 44px; }
.sammy-profile { display: flex; gap: .85rem; align-items: center; margin-top: .9rem; }
.sammy-profile img { width: 112px; height: 112px; object-fit: cover; border-radius: .55rem; }

#game:not([data-extra-combat]) [data-extra] { display:none }
#quick-magic { background:#563878; border-color:#dfb9ff; font-weight:700 }
#combat-actions #quick-magic,#combat-actions [data-hold="Space"],#combat-actions [data-hold="KeyF"] { min-width:3.2rem }
#festival-status { position:absolute; z-index:4; top:clamp(6.2rem,17vh,11rem); left:50%; transform:translateX(-50%); width:max-content; max-width:calc(100% - 1.5rem); padding:.55rem .9rem; text-align:center; color:#fff3da; background:#182139ec; border:1px solid #eac579; border-radius:.45rem; pointer-events:none }
#city-menu .hud-actions { max-height:min(72dvh,32rem); overflow:auto }
#city-menu select { max-width:100% }

#game:not([data-extra-combat]) #combat-actions { grid-template-rows:repeat(2,minmax(44px,auto)) }
#game:not([data-extra-combat]) #aim-stick { grid-row:1 / 3 }
