/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #E4EBF8;
  color: #142864;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.screen.hidden {
  display: none !important;
}

/* ── Home Screen ──────────────────────────────────────────────────────────── */
.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 24px;
}

.title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.title-icon {
  font-size: 48px;
  line-height: 1;
}

.title {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 6px;
  color: #142864;
  text-align: center;
}

.subtitle {
  font-size: 14px;
  color: #3764A5;
  text-align: center;
  max-width: 260px;
  line-height: 1.4;
}

.hint {
  font-size: 12px;
  color: #5B7BB5;
  text-align: center;
  max-width: 260px;
  line-height: 1.4;
}

/* ── Waiting Screen ───────────────────────────────────────────────────────── */
.waiting-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 20px;
}

.waiting-label {
  font-size: 16px;
  font-weight: 600;
  color: #1E326E;
}

.share-box {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  background: #fff;
  border: 1.5px solid #B4C8E4;
  border-radius: 10px;
  padding: 10px 10px 10px 14px;
  gap: 8px;
  min-height: 48px;
}

.share-link-text {
  flex: 1;
  font-size: 13px;
  color: #1E326E;
  word-break: break-all;
  line-height: 1.4;
  font-family: monospace;
}

.btn-copy {
  flex-shrink: 0;
  background: #3764A5;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-copy:active {
  background: #1E326E;
}

.waiting-status {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: #3764A5;
  font-size: 14px;
  font-weight: 500;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #B4C8E4;
  border-top-color: #3764A5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 20px;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: #3764A5;
  color: #fff;
  width: 100%;
  max-width: 280px;
  padding: 16px 24px;
  font-size: 17px;
  letter-spacing: 1px;
  border-radius: 12px;
}

.btn-large {
  padding: 16px 32px;
}

.btn-secondary {
  background: #3764A5;
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
}

.btn-secondary.active {
  background: #1E326E;
}

.btn-icon {
  background: #3764A5;
  color: #fff;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  border-radius: 10px;
  min-width: 64px;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-icon-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.btn-icon.active {
  background: #1E326E;
}

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  width: 100%;
  max-width: 280px;
  font-size: 16px;
  padding: 14px 24px;
  border-radius: 12px;
}

.wa-icon {
  width: 22px;
  height: 22px;
  fill: #fff;
  flex-shrink: 0;
}

/* ── Game Screen ──────────────────────────────────────────────────────────── */
#screen-game {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100vh;
  padding-bottom: 12px;
}

#status-bar {
  background: #CDDAEF;
  color: #143278;
  text-align: center;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
}

#boards-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  flex: 0 0 auto;
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 285px;
}

.board-label {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #1E326E;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.canvas-with-icons {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 5px;
}

canvas {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  display: block;
  border-radius: 4px;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Fleet Icons ──────────────────────────────────────────────────────────── */
.fleet-icons {
  width: 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ship-icon-wrap {
  display: flex;
  align-items: stretch;
}

.ship-icon-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
  transition: fill 0.3s;
}

/* ── Placement Controls ───────────────────────────────────────────────────── */
#placement-controls {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  flex: 0 0 auto;
}

#placement-controls.hidden {
  display: none !important;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }

/* ── Larger screens ───────────────────────────────────────────────────────── */
@media (min-width: 481px) {
  body {
    justify-content: flex-start;
    padding-top: 24px;
  }

  .screen {
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(20, 40, 100, 0.12);
    min-height: auto;
    overflow: hidden;
  }

  .home-inner,
  .waiting-inner {
    min-height: 600px;
  }

  #screen-game {
    min-height: 640px;
  }
}
