/* Scene depth: painted ocean, isometric raft, walking sailor. */

#game .scene {
  position: absolute;
  width: auto;
  height: auto;
  max-width: none;
  object-fit: none;
  object-position: left top;
  filter: saturate(1.1) contrast(1.02) brightness(1.01);
}

#game .world {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 56%;
  width: min(58vw, 640px);
  aspect-ratio: 770 / 322;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#game .raft {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  transform: none;
  pointer-events: auto;
}

#game .raft-shadow {
  position: absolute;
  z-index: 0;
  left: 6%;
  right: 6%;
  bottom: 8%;
  height: 32%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(2, 18, 30, .55), rgba(2, 18, 30, .12) 58%, transparent 74%);
  filter: blur(3px);
  pointer-events: none;
}

#game .raft-art {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 12px rgba(0, 16, 26, .32));
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* invisible hit area used to clamp the sailor to the deck */
#game .raft-deck {
  position: absolute;
  z-index: 0;
  inset: 8% 12% 30% 12%;
  display: grid;
  visibility: hidden;
  pointer-events: none;
}

#game .deck-plank { display: block; }

#game .raft-aura {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 54%;
  width: 82%;
  height: 48%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 52%, rgba(127, 240, 230, .24), rgba(127, 240, 230, .06) 48%, transparent 72%);
  box-shadow: 0 0 0 1px rgba(127, 240, 230, .08);
  opacity: .55;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity .25s ease;
}

#game.is-moving .raft-aura {
  opacity: 1;
  animation: aura-breathe 1.2s ease-in-out infinite alternate;
}

@keyframes aura-breathe {
  from { transform: translate(-50%, -50%) scale(.96); opacity: .5; }
  to { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}

#game .raft-label {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: -16px;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 222, 160, .38);
  border-radius: 99px;
  background: rgba(3, 28, 46, .82);
  box-shadow: 0 6px 16px rgba(0, 10, 20, .34), inset 0 1px rgba(255, 255, 255, .12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

#game .raft-label b {
  color: #fff1cc;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}

#game .raft-label > span {
  color: #a9d6dd;
  font-size: 9px;
}

/* ---------- sailor ---------- */

#game #character {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 46%;
  width: clamp(30px, 3.8vw, 46px);
  aspect-ratio: 98 / 187;
  height: auto;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

#game #character .sailor-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 4px 3px rgba(2, 20, 28, .5));
  transform-origin: center bottom;
  user-select: none;
  -webkit-user-drag: none;
}

#game #character .sailor,
#game #character > .mp-icon { display: none !important; }

#game #character[data-facing="left"] .sailor-art { transform: scaleX(-1); }
#game #character[data-facing="right"] .sailor-art { transform: scaleX(1); }

#game #character[data-state="walk"] .sailor-art {
  animation: sailor-step .3s ease-in-out infinite alternate;
}

@keyframes sailor-step {
  from { transform: translateY(0) rotate(-1.5deg); }
  to { transform: translateY(-4px) rotate(1.5deg); }
}

#game #character[data-facing="left"][data-state="walk"] .sailor-art {
  animation-name: sailor-step-left;
}

@keyframes sailor-step-left {
  from { transform: scaleX(-1) translateY(0) rotate(1.5deg); }
  to { transform: scaleX(-1) translateY(-4px) rotate(-1.5deg); }
}

/* ---------- built buildings ---------- */

#game #building-markers {
  position: absolute;
  z-index: 3;
  inset: 3% 14% 27% 14%;
  pointer-events: none;
}

#game .built-house {
  position: absolute;
  width: 30px;
  height: 34px;
  transform: translate(-50%, -70%);
  filter: drop-shadow(0 4px 3px rgba(0, 16, 26, .38));
}

#game .house-body,
#game .house-roof {
  display: block;
  position: absolute;
  left: 3px;
  right: 3px;
}

#game .house-body {
  bottom: 0;
  height: 17px;
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgba(120, 84, 50, .5) 0 2px, transparent 2px 100%),
    linear-gradient(#f7eed9, #d4c19b);
  box-shadow: 0 4px 0 #8d7350;
}

#game .house-body::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 7px;
  height: 10px;
  border-radius: 3px 3px 0 0;
  background: #6f5133;
  transform: translateX(-50%);
}

#game .house-roof {
  top: 1px;
  height: 14px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(#ef7258, #b23627);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

#game .built-garden .house-roof { background: linear-gradient(#93dd72, #3f8d38); }
#game .built-water .house-roof { background: linear-gradient(#8adcf3, #2f86b8); }
#game .built-tower .house-body { height: 24px; }
#game .built-engine .house-roof { background: linear-gradient(#d7b06e, #8d5a24); }
#game .built-cabin .house-roof { background: linear-gradient(#8fb3e8, #3c5e9e); }

#game .built-house b {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@container raft-stage (max-height: 360px) {
  #game .world { width: min(56vw, 560px); }
  #game .built-house { width: 24px; height: 28px; }
  #game .house-body { height: 14px; }
  #game .house-roof { height: 11px; }
}

@container raft-stage (max-width: 600px) {
  #game .world { width: min(62vw, 460px); }
  #game .raft-label { bottom: -14px; padding: 4px 9px; }
  #game .raft-label b { font-size: 11px; }
  #game .built-house { width: 22px; height: 26px; }
  #game .house-body { height: 13px; }
  #game .house-roof { height: 10px; }
}

/* Building controls share the deck's local coordinates, not HUD coordinates. */
#game .raft-assembly { position:absolute; inset:0; pointer-events:none; }
#game .raft-assembly:has(.deck-entries) #building-markers { visibility:hidden; }
#game .deck-entries {
  position:absolute; z-index:5; left:50%; bottom:57%; transform:translateX(-50%);
  display:flex; align-items:flex-end; gap:clamp(5px,1vw,14px); max-width:70%;
  padding:4px 3px; box-sizing:border-box; overflow-x:auto; overflow-y:hidden;
  scrollbar-width:thin; scrollbar-color:#b49a64 transparent; pointer-events:auto;
  overscroll-behavior-x:contain; touch-action:pan-x;
}
#game .deck-entries:not(:has([data-deck-id])) { gap:clamp(18px,8vw,92px); }
#game .deck-entries .deck-entry {
  flex:0 0 auto; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px;
  width:clamp(44px,5vw,58px); height:clamp(44px,6vw,60px); min-width:44px; min-height:44px;
  padding:2px; border:1px solid #d7b47a; border-bottom:3px solid #825d3b; border-radius:9px;
  background:linear-gradient(155deg,#285461,#103540); color:#fff1d0;
  box-shadow:0 2px 3px #271c1699,inset 0 1px #f8deab55; cursor:pointer;
  transform-origin:center bottom; transition:transform .1s,filter .1s;
}
#game .deck-entry .mp-icon { color:#ffdb98; width:22px; height:22px; }
#game .deck-entry span { color:#fff1d0; font-size:10px; white-space:nowrap; }
#game .deck-entry:active { transform:scale(.91); filter:brightness(1.35); }
#game .deck-entry:focus-visible { outline:2px solid #fff1a5; outline-offset:-3px; }
#game .deck-entries:has([data-deck-id]) { bottom:59%; }
#game .deck-entries { pointer-events:none; }
#game .deck-entries .deck-entry { pointer-events:auto; touch-action:pan-x; }
/* [STATE] 只有建筑按钮接收点击，按钮间的甲板仍可点选移动。 */

@container raft-stage (max-height: 360px) {
  #game .start-card { max-height:100%; overflow-y:auto; overscroll-behavior:contain; }
  #game #start-game { position:sticky; bottom:0; min-height:44px; }
}
#game .deck-entries { bottom:45%; scroll-snap-type:x proximity; }
#game .deck-entries:has([data-deck-id]) { bottom:45%; }
#game .deck-entries .deck-entry { scroll-snap-align:center; }
/* [STATE] 矮屏启航按钮可达，建筑入口锚定在甲板中部。 */
