/* Board must fill the column. Short screens sacrifice atmosphere and title spacing,
   never board width or tap targets. */
* { box-sizing: border-box; }
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-right: env(safe-area-inset-right, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --safe-left: env(safe-area-inset-left, 0px); }
body { margin: 0; background: #163b38 url('./assets/conservatory.webp') center / cover fixed; color: #fff2d4; font: 16px system-ui, sans-serif; }
#app { width: min(100%, 500px); min-height: 100dvh; margin: auto; padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left)); background: #102f2b; }
header, footer, .hud, nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
button { min-width: 44px; min-height: 44px; border: 1px solid #c6ab74; border-radius: 12px; background: #31524c; color: inherit; font: inherit; padding: 8px 12px; flex: 0 0 auto; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid white; }
#title { text-align: center; height: calc(100dvh - 80px - var(--safe-top) - var(--safe-bottom)); background: url('./assets/conservatory.webp') center / cover; border: 1px solid #c6ab74; border-radius: 120px 120px 20px 20px; display: flex; align-items: end; }
.title-copy { width: 100%; padding: 22px 8px; background: linear-gradient(transparent, #102f2bee 30%); border-radius: 0 0 20px 20px; }
h1 { font: 64px Georgia, serif; letter-spacing: .22em; margin: 8px 0; text-shadow: 0 3px 10px #051f1c; }
button img, .hud img { width: 30px; height: 30px; vertical-align: middle; object-fit: contain; }
#sound { padding: 5px; order: -1; } header { position: relative; justify-content: start; padding-right: 56px; margin-bottom: 12px; font-size: 12px; letter-spacing: .12em; }
.hud span { display: flex; align-items: center; gap: 8px; min-width: 120px; }
#moves { position: relative; padding-bottom: 12px; } #moves meter { position: absolute; bottom: 1px; left: 8px; width: calc(100% - 16px); height: 8px; }
#moves.urgent { border-color: #ffbb65; background: #6c411d; box-shadow: 0 0 12px #ffc36a55; }
h2 { margin: 16px 0 8px; } p { line-height: 1.5; } #note { min-height: 48px; }
.hud { margin: 12px 0; } .hud span { border: 1px solid #c6ab74; border-radius: 10px; padding: 8px; }
#board { display: grid; grid-template-columns: repeat(5, 1fr); aspect-ratio: 1; width: 100%; gap: 3px; touch-action: none; }
.cell { padding: 0; border-radius: 8px; border: 0; min-width: 0; background: url('./assets/tile.png') center / 115% 115%; position: relative; }
.cell.selected { outline: 2px solid #ffec9d; outline-offset: -3px; z-index: 1; }
.cell.selected::after { content: ''; position: absolute; inset: 0; background: url('./assets/selection.png') center / contain; mask-image: radial-gradient(transparent 45%, black 49%); pointer-events: none; }
.forecast { position: absolute; right: 2px; top: 2px; border-radius: 8px; background: #123c36; color: #fff3c3; font-size: 18px; width: 24px; height: 24px; line-height: 24px; border: 1px solid #d3be7b; pointer-events: none; }
button:disabled { opacity: .4; cursor: default; }
.cell .entity { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 3px 2px #17342b88); }
#result { text-align: center; } #result-art { width: 140px; height: 140px; object-fit: contain; } #result button { margin: 4px; }
#levels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0; } #levels button { min-height: 76px; }
#levels button { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 4px; text-align: left; padding: 10px; }
#levels small { grid-column: 2; color: #ddc789; }
nav { margin: 16px 0; } nav button { width: calc((100% - 24px) / 4); }
footer button { flex: 1; } #result { position: fixed; z-index: 3; top: calc(50% + (var(--safe-top) - var(--safe-bottom)) / 2); left: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100% - 32px - var(--safe-left) - var(--safe-right))); max-height: calc(100dvh - 24px - var(--safe-top) - var(--safe-bottom)); overflow-y: auto; padding: 24px; border: 1px solid #c6ab74; background: #31524c; border-radius: 16px; box-shadow: 0 0 0 100vmax #102c28bb; }
[hidden] { display: none !important; }
@media (max-height: 700px) {
  header { margin-bottom: 0; }
  /* On a short mobile viewport, share the sound/level row and combine the two
     control rows. Sacrifice header decoration, never board width or 44px targets. */
  #app:has(#game:not([hidden])) header { height: 0; padding: 0; }
  #app:has(#game:not([hidden])) header span { display: none; }
  #app:has(#game:not([hidden])) #sound { position: absolute; top: 0; left: 0; z-index: 2; }
  #level { min-height: 44px; padding: 8px 56px; margin: 0; }
  #note { min-height: 40px; font-size: 14px; line-height: 20px; margin: 4px 0; }
  h2 { font-size: 20px; margin: 4px 0; }
  .hud { margin: 4px 0; } .hud span { padding: 3px 8px; }
  nav { margin: 6px 0 0; width: 56%; float: left; gap: 3px; }
  nav button { width: calc((100% - 9px) / 4); height: 48px; padding: 0; }
  nav button img { width: 20px; height: 20px; }
  footer { width: 42%; float: right; gap: 3px; margin-top: 6px; }
  footer button { height: 48px; min-width: 44px; padding: 0; font-size: 12px; }
  footer img { display: none; }
  #game::after { content: ''; display: block; clear: both; }
}
