/* Board actions stay together; supporting information can expand separately. */
body{--safe-bottom:env(safe-area-inset-bottom,0px)}
[data-theme=terrain-ruins] .app{padding-bottom:max(24px,env(safe-area-inset-bottom))}
.game-header{height:60px}
.icon-button{width:44px;height:44px;flex-shrink:0}
.mode-switch{margin:4px 0 10px;gap:12px}
.mode-switch button{min-height:44px;min-width:90px;padding:8px 12px;font-size:12px}
body[data-embed=true] .mode-switch{margin:0 0 6px}
[data-theme=terrain-ruins] .game-layout{grid-template-areas:'heading heading' 'board stats' 'board inventory';grid-template-rows:auto auto 1fr;gap:12px 24px}
.puzzle-heading{min-width:0;gap:10px;align-items:center}
.puzzle-heading>div:first-child{min-width:0}
.level-navigation{flex-shrink:0}
#campaign-level{min-height:44px;min-width:54px;font-size:12px}
.play-area{justify-self:center;align-self:start;width:100%}
.board-frame{width:100%;margin-left:auto;margin-right:auto}
.score-panel{grid-area:stats;min-width:0;align-self:start}
[data-theme=terrain-ruins] .score-panel .result{margin:0;padding:14px;text-align:left;line-height:1.4}
.result-heading{display:flex;align-items:center;gap:10px}
.result-heading .completion-seal{width:30px;height:34px;flex-shrink:0;margin:0}
.result-heading .eyebrow{font-size:8px;letter-spacing:1px}
[data-theme=terrain-ruins] .result-heading strong{font-size:23px;margin:3px 0 0;line-height:1.1}
.result-metrics{display:flex;flex-wrap:wrap;gap:10px 20px;margin:14px 0 0;font-variant-numeric:tabular-nums}
.result-metrics>div{min-width:0}
.result-metrics dt{font-size:10px;color:#627357}
.result-metrics dd{margin:4px 0 0;font:500 27px/1 Arial,sans-serif;color:#304f3c}
[data-theme=terrain-ruins] .result-metrics dd small{display:inline;font-size:12px;margin:0}
.score-panel .result .result-status{margin:12px 0 0;font-size:10px;line-height:1.5;overflow-wrap:anywhere}
.score-panel .result-action{margin:10px 0 0;min-height:44px;width:100%;white-space:normal}
[data-theme=terrain-ruins] .stats{padding:14px;gap:12px}
[data-theme=terrain-ruins] .remaining-stat strong{font-size:35px}
.stat-note{display:none}
[data-theme=terrain-ruins] .game-controls{display:flex;gap:8px;margin-top:8px;align-items:stretch}
.game-controls>button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:0;padding:8px;flex:1;margin:0;border:1px solid #b9c6a9;border-radius:5px;font-size:12px;background:#f5f7ef}
.game-controls>.next-button{flex:1.4;background:#eaf0df}
.game-controls>#next-level.ready{background:#355b42;border-color:#294b34;color:#f7f1dd}
[data-theme=terrain-ruins] .status{font-size:11px;line-height:1.5;min-height:34px;margin:7px 0 0}
.level-intro{font-size:11px;line-height:1.6;margin:12px 0 0}
[data-theme=terrain-ruins] .inventory{border:1px solid #d6ddc9;border-radius:5px;padding:0;min-width:0;align-self:start}
.inventory>summary{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:44px;padding:10px 12px;cursor:pointer;list-style:none;font-size:11px;color:#53694b}
.inventory>summary::-webkit-details-marker{display:none}
.guide-toggle{font-size:20px;line-height:1;transition:transform .15s}
.inventory[open] .guide-toggle{transform:rotate(45deg)}
.guide-content{padding:4px 12px 12px}
.progress-line{margin-top:14px;gap:12px}
.play-hint{margin:14px 0}
.site-credit{margin-top:14px;padding-top:14px}
dialog{max-width:calc(100vw - 24px);max-height:calc(var(--host-viewport-height,100dvh) - 32px);overflow:auto;overscroll-behavior:contain}
.close-help{min-width:44px;min-height:44px;position:sticky;top:-12px;z-index:2;background:var(--paper)}
.name-field{flex-wrap:wrap;gap:8px}
#scores-dialog .name-field input{flex:1 1 140px;max-width:240px;min-width:0}
#scores-dialog .name-field input{font-size:16px;min-height:44px}
#scores-dialog .next-button{min-height:44px}
@media(max-width:600px){
  [data-theme=terrain-ruins] .app{padding-left:12px;padding-right:12px}
  .game-header{height:48px}
  [data-theme=terrain-ruins] .identity h1{font-size:25px}
  .mode-switch{margin:0 0 3px}
  [data-theme=terrain-ruins] .game-layout{display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:'heading' 'stats' 'board' 'inventory';grid-template-rows:auto;gap:8px;max-width:384px}
  [data-theme=terrain-ruins] .puzzle-heading h2{font-size:19px;margin:2px 0 0;line-height:1.2}
  [data-theme=terrain-ruins] .stats{display:flex;gap:10px;padding:8px 12px;min-height:53px}
  [data-theme=terrain-ruins] .score-panel .result{padding:9px 12px;display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px}
  .result-heading{gap:7px}
  .result-heading .completion-seal{width:23px;height:28px}
  .result-heading .eyebrow{font-size:7px;letter-spacing:.7px}
  [data-theme=terrain-ruins] .result-heading strong{font-size:20px}
  .result-metrics{margin:0;gap:10px 16px}
  .result-metrics dt{font-size:9px}
  .result-metrics dd{font-size:22px;margin-top:3px}
  .score-panel .result .result-status{flex-basis:100%;margin:0}
  [data-theme=terrain-ruins] .stat>span:first-child{font-size:10px;margin-bottom:3px}
  [data-theme=terrain-ruins] .stat strong{font:500 24px/1 Arial,sans-serif;letter-spacing:-.5px}
  [data-theme=terrain-ruins] .remaining-stat::after{display:none}
  .stat small{font-size:11px}
  #time-stat{flex:1.25}
  .game-controls>button{font-size:11px;padding:8px 5px;gap:4px}
  .game-controls>#show-scores{font-size:10px}
  .quick-legend{grid-template-columns:repeat(4,minmax(0,1fr))}
  [data-theme=terrain-ruins] .quick-item{font-size:10px}
  body[data-embed=true] .game-layout{gap:8px}
  body[data-embed=true] .game-header{height:48px}
  .start-overlay{padding:12px;overflow:auto}
  [data-theme=terrain-ruins] #start-token{width:30px;height:34px;margin-bottom:5px}
  .start-overlay h3{font-size:23px;margin:6px 0}
  .start-overlay p{font-size:11px;line-height:1.4;margin:6px 0 12px}
  .start-overlay small{font-size:10px;line-height:1.4;margin-top:8px}
  [data-theme=terrain-ruins] .primary{min-height:44px;font-size:11px}
}

  body[data-short-screen=true] .app{position:relative}
  body[data-short-screen=true] .game-header{height:48px}
  body[data-short-screen=true] .mode-switch{position:absolute;top:0;right:88px;margin:0}
  body[data-short-screen=true] .mode-switch button{min-width:70px;min-height:44px;padding:4px 10px}
  body[data-short-screen=true][data-theme=terrain-ruins] .game-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(150px,200px);grid-template-areas:'board heading' 'board stats' 'board inventory';grid-template-rows:auto auto 1fr;gap:8px 18px;max-width:700px;padding-top:8px}
  body[data-short-screen=true][data-theme=terrain-ruins] .puzzle-heading h2{font-size:17px}
  body[data-short-screen=true][data-theme=terrain-ruins] .stats{display:grid;grid-template-columns:1fr 1fr;padding:10px;gap:8px}
  body[data-short-screen=true][data-theme=terrain-ruins] .score-panel .result{padding:10px}
  body[data-short-screen=true] .result-heading .completion-seal{display:none}
  body[data-short-screen=true] .result-heading .eyebrow{font-size:7px;letter-spacing:.5px}
  body[data-short-screen=true][data-theme=terrain-ruins] .result-heading strong{font-size:20px}
  body[data-short-screen=true] .result-metrics{gap:10px 16px;margin-top:10px}
  body[data-short-screen=true] .result-metrics dd{font-size:22px}
  body[data-short-screen=true] .remaining-stat{grid-column:1/-1}
  body[data-short-screen=true] .stat strong{font-size:24px}
  body[data-short-screen=true] .start-overlay{padding:10px;overflow:auto}
  body[data-short-screen=true][data-theme=terrain-ruins] #start-token{display:none}
  body[data-short-screen=true] .start-overlay h3{font-size:20px;margin:4px 0}
  body[data-short-screen=true] .start-overlay p{font-size:10px;margin:4px 0 8px;line-height:1.4}
  body[data-short-screen=true] .start-overlay small{font-size:9px;margin-top:6px}
@media(max-width:600px){
  body[data-short-screen=true] .mode-switch{right:68px;gap:4px}
  body[data-short-screen=true][data-theme=terrain-ruins] .identity h1{font-size:21px}
  body[data-short-screen=true][data-theme=terrain-ruins] .game-layout{grid-template-columns:minmax(0,1fr) 155px;gap:8px 12px}
}
@media(pointer:coarse){.play-hint{display:none}}
