/* TweakMill Battleship — full-width panels, sea grid, clear hit/miss/sunk */

.tm-bs {
  --tm-bs-sea: #1565c0;
  --tm-bs-sea-deep: #0d47a1;
  --tm-bs-foam: #e3f2fd;
  --tm-bs-ship: #546e7a;
  --tm-bs-miss: #b0bec5;
  --tm-bs-hit: #c62828;
  --tm-bs-sunk: #37474f;
  --tm-bs-cell: min(2.2rem, 4.5vw);
  --tm-bs-gap: 3px;
}

.tm-bs-arena {
  max-width: 68rem;
  margin-left: auto;
  margin-right: auto;
}

.tm-bs-hud {
  position: relative;
  border-radius: var(--tm-radius, 12px);
  background: linear-gradient(135deg, var(--tm-bs-sea-deep) 0%, #1565c0 50%, #0277bd 100%);
  color: #fff;
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: 0 0.4rem 1.2rem rgba(13, 71, 161, 0.25);
  min-height: 3.5rem;
}

.tm-bs-hud h2,
.tm-bs-hud p {
  color: #fff;
}

.tm-bs-hud .tm-bs-hud-line {
  font-size: clamp(1.05rem, 2.6vw, 1.2rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tm-bs-hud .tm-bs-hud-sub {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  opacity: 0.92;
}

.tm-bs-modebar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
}

.tm-bs-modebar .btn {
  min-height: 2.75rem;
}

.tm-bs-lobby {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.tm-bs-room-code {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  user-select: all;
  background: rgba(0, 0, 0, 0.15);
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.35rem;
  margin: 0 0.2rem;
}

.tm-bs-panels {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 992px) {
  .tm-bs-panels {
    flex-direction: row;
    align-items: flex-start;
  }
  .tm-bs-panels .tm-bs-side {
    flex: 1 1 50%;
    min-width: 0;
  }
}

.tm-bs-panel {
  min-height: 12rem;
}

.tm-bs-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.tm-bs-side-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--tm-primary);
}

.tm-bs-grid-wrap {
  padding: 0.5rem;
  background: var(--tm-bs-sea-deep);
  border-radius: 0.5rem;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.tm-bs-grid {
  display: grid;
  grid-template-columns: repeat(10, var(--tm-bs-cell));
  grid-template-rows: repeat(10, var(--tm-bs-cell));
  gap: var(--tm-bs-gap);
  width: max-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  user-select: none;
}

.tm-bs-cell {
  width: var(--tm-bs-cell);
  height: var(--tm-bs-cell);
  min-width: 0;
  min-height: 0;
  border: none;
  border-radius: 4px;
  padding: 0;
  cursor: default;
  transition:
    background 0.12s ease,
    transform 0.1s ease,
    box-shadow 0.12s ease;
  background: color-mix(in srgb, var(--tm-bs-sea) 90%, #000);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.tm-bs-cell:focus-visible {
  outline: 2px solid #ffab40;
  outline-offset: 1px;
  z-index: 1;
}

.tm-bs-cell--sea {
  background: var(--tm-bs-sea);
}

.tm-bs-cell--ship {
  background: var(--tm-bs-ship);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.tm-bs-cell--place-preview {
  background: #81c784 !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.tm-bs-cell--place-invalid {
  background: #e57373 !important;
  cursor: not-allowed;
}

.tm-bs-cell--interact {
  cursor: crosshair;
}

.tm-bs-cell--interact:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tm-bs-foam) 35%, var(--tm-bs-sea));
  transform: scale(1.04);
  box-shadow: 0 0.15rem 0.35rem rgba(0, 0, 0, 0.12);
}

.tm-bs-cell--miss {
  background: #eceff1;
  color: #78909c;
  font-size: 0.65em;
  font-weight: 700;
}

.tm-bs-cell--miss::after {
  content: "◯";
  opacity: 0.85;
}

.tm-bs-cell--hit {
  background: #ffcdd2;
  box-shadow: inset 0 0 0 2px var(--tm-bs-hit);
  position: relative;
}

.tm-bs-cell--hit::after {
  content: "✱";
  color: var(--tm-bs-hit);
  font-size: 0.75em;
  font-weight: 900;
}

.tm-bs-cell--sunk {
  background: #cfd8dc;
  box-shadow: inset 0 0 0 2px var(--tm-bs-sunk);
}

.tm-bs-cell--sunk::after {
  content: "☠";
  font-size: 0.7em;
  opacity: 0.8;
}

.tm-bs-cell--incoming {
  /* shots opponent landed on you */
  animation: tmBsPulse 0.5s ease;
}

.tm-bs-dock {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0.5rem 0.25rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.tm-bs-dock-ships {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
}

.tm-bs-dock-legend {
  font-size: 0.8rem;
  color: #546e7a;
  width: 100%;
}

.tm-bs-ship-pick {
  min-height: 2.5rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}

.tm-bs-ship-pick[aria-pressed="true"] {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tm-primary);
}

.tm-bs-rotate {
  min-width: 2.5rem;
}

.tm-bs-fade-in {
  animation: tmBsFade 0.35s ease;
}

@keyframes tmBsFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes tmBsPulse {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: brightness(1.2);
  }
}

.tm-bs-enemy {
  min-height: 3rem;
}

/* Enemy grid: unknown cells stay sea until fired */
.tm-bs-grid--fog .tm-bs-cell--sea.tm-bs-cell--fired-miss,
.tm-bs-grid--fog .tm-bs-cell--sea:not(.tm-bs-cell--fired) {
  background: var(--tm-bs-sea);
}

@media (prefers-reduced-motion: reduce) {
  .tm-bs-cell,
  .tm-bs-fade-in,
  .tm-bs-cell--incoming {
    animation: none;
    transition: none;
  }
}
