.ship-deck {
  container: ship-deck / inline-size;
  min-inline-size: 0;
  width: 100%;
}

.ship-deck--dense .ship-deck__viewport {
  overflow-x: auto;
  border-radius: 10px;
  scrollbar-color: #6c8c99 #dce6e8;
}

.ship-deck--dense .ship-deck__board {
  min-width: 500px;
}

.ship-deck__viewport:focus-visible {
  outline: 2px solid #05977f;
  outline-offset: 3px;
}

.ship-deck__board {
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 190px;
  aspect-ratio: 2.64;
  overflow: hidden;
  border: 1px solid #274659;
  border-radius: 10px;
  background-color: #0e2539;
  background-image:
    linear-gradient(to right, #6b9bb91b 1px, transparent 1px),
    linear-gradient(to bottom, #6b9bb91b 1px, transparent 1px),
    linear-gradient(to right, #6b9bb911 1px, transparent 1px),
    linear-gradient(to bottom, #6b9bb911 1px, transparent 1px);
  background-position: center;
  background-size: 80px 80px, 80px 80px, 20px 20px, 20px 20px;
}

.ship-deck__board:focus-visible {
  outline: 2px solid #05977f;
  outline-offset: 3px;
}

.ship-deck__canvas,
.ship-deck__zones {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ship-deck__zones {
  pointer-events: none;
}

.ship-deck__compartment {
  box-sizing: border-box;
  container: ship-cell / inline-size;
  display: flex;
  position: absolute;
  z-index: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.34rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.16rem 2px;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid #4b7387;
  border-radius: 4px;
  background: #183a50;
  color: #e1edf2;
  font: 650 0.71rem/1.1 system-ui, sans-serif;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
}

.ship-deck__compartment[data-status="warning"],
.ship-deck__compartment[data-status="qa"],
.ship-deck__compartment[data-status="review"] {
  border-color: #997747;
  background: #3e382f;
}

.ship-deck__compartment[data-status="blocked"] {
  border-color: #b77577;
  background: #4b3038;
}

.ship-deck__compartment[data-status="complete"],
.ship-deck__compartment[data-status="done"],
.ship-deck__compartment[data-status="closed"] {
  border-color: #498683;
  background: #18434b;
}

.ship-deck__compartment:hover,
.ship-deck__compartment:focus-visible {
  z-index: 3;
  outline: 1px solid #a8eddf;
  outline-offset: 2px;
}

.ship-deck__compartment[aria-pressed="true"] {
  z-index: 2;
  border-color: #65dfbd;
  background: #15524f;
  color: #ecfff9;
  box-shadow: inset 0 0 0 1px #65dfbd50;
}

.ship-deck__compartment[aria-pressed="true"] .ship-deck__code {
  color: #a0efd9;
}

.ship-deck__compartment--dimmed {
  opacity: .5;
}

.ship-deck__compartment--dimmed:hover,
.ship-deck__compartment--dimmed:focus-visible {
  opacity: .82;
}

.ship-deck__code,
.ship-deck__name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-deck__code {
  flex-shrink: 0;
  color: #d5e4ed;
  font: 620 0.59rem/1.12 ui-monospace, Consolas, monospace;
  overflow-wrap: anywhere;
  text-overflow: clip;
}

.ship-deck__name {
  white-space: nowrap;
}

.ship-deck__name--short {
  display: none;
}

.ship-deck__board--drawing {
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.ship-deck__board--drawing .ship-deck__zones {
  opacity: 0.45;
}

.ship-deck__board--drawing .ship-deck__compartment {
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.ship-deck__board--editing {
  background-position: left top;
  background-size: 10% 20%, 10% 20%, 2% 4%, 2% 4%;
}

.ship-deck__board--editing .ship-deck__compartment[inert]:not(.ship-deck__compartment--dimmed) {
  opacity: .65;
}

.ship-deck__compartment[data-deck-edit-handle="move"] {
  border-color: #f5c28b;
  box-shadow: inset 0 0 0 1px #f5c28b5c;
  cursor: move;
  touch-action: none;
  user-select: none;
}

.ship-deck__resize {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 7px;
  background: radial-gradient(circle, #ffd3a4 0 10px, #102b41 11px, transparent 12px);
  color: #15293b;
  font: 750 16px/1 system-ui, sans-serif;
  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.ship-deck__resize:focus-visible,
.ship-deck__compartment[data-deck-edit-handle="move"]:focus-visible {
  outline: 2px solid #ffd3a4;
  outline-offset: 2px;
}

.ship-deck__board--dragging [data-deck-edit-handle="move"] {
  cursor: grabbing;
}

.ship-deck__instructions,
.ship-deck__scroll-hint {
  margin: 0.65rem 0 0;
  color: #495e6e;
  font-size: 0.8125rem;
}

.ship-deck__scroll-hint {
  display: none;
}

.ship-deck--overflow .ship-deck__scroll-hint {
  display: block;
}

@container ship-deck (max-width: 490px) {
  .ship-deck__board {
    min-height: 166px;
  }

  .ship-deck__compartment {
    gap: .22rem;
    font-size: 0.62rem;
  }

  .ship-deck__name--full {
    display: none;
  }

  .ship-deck__name--short {
    display: block;
  }
}

@container ship-cell (max-width: 56px) {
  .ship-deck__code {
    font-size: clamp(7.5px,17cqi,9.5px);
    letter-spacing: -.018em;
  }

  .ship-deck__name {
    font-size: .89em;
  }
}

@container ship-cell (max-width: 47px) {
  .ship-deck__code ~ .ship-deck__name {
    display: none;
  }
}
