/* ============================================================
   Kanonkula — Pirate Battleship
   Mobile-first, parchment aesthetic
   ============================================================ */

/* --- Palette ---
   Parchment   #e8d5a3
   Ink         #2b1d0e
   Ocean       #1a3a5c
   Hit/fire    #c0392b
   Miss/water  #2980b9
   Gold        #c9a84c
   Sunk        #5d3a1a
   Dark sunk   #3d2010
   Fog         rgba(26,58,92,0.55)
*/

/* --- Google Fonts: Pirata One + Crimson Text --- */
/* Loaded via <link> in index.html */

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

:root {
  --parchment: #e8d5a3;
  --parchment-dark: #d4bc84;
  --parchment-light: #f2e5c0;
  --ink: #2b1d0e;
  --ink-light: #5a3e28;
  --ocean: #1a3a5c;
  --ocean-dark: #0d2239;
  --hit: #c0392b;
  --hit-glow: #e74c3c;
  --miss: #2980b9;
  --gold: #c9a84c;
  --gold-dark: #a8893c;
  --sunk: #5d3a1a;
  --sunk-dark: #3d2010;
  --fog: rgba(26,58,92,0.55);
  --ship-wood: #8b6340;
  --ship-wood-dark: #6b4820;
  --ship-plank: #a07848;
}

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

body {
  font-family: 'Crimson Text', Georgia, serif;
  background: var(--ocean-dark);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

h1, h2, h3, .game-title, .screen-title {
  font-family: 'Pirata One', 'Georgia', serif;
  letter-spacing: 0.03em;
}

button, a, [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* ============================================================
   Parchment Texture
   ============================================================ */
.parchment-bg {
  background-color: var(--parchment);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeBlend in='SourceGraphic' mode='multiply'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 20% 20%, #f5e8c4 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, #d4b87a 0%, transparent 60%),
    linear-gradient(135deg, #edd9a3 0%, #e0c88a 50%, #d4b87a 100%);
  background-blend-mode: multiply;
}

/* ============================================================
   Screen Base
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at 15% 15%, rgba(255,240,200,0.6) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(180,140,80,0.4) 0%, transparent 55%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 29px,
      rgba(43,29,14,0.04) 29px,
      rgba(43,29,14,0.04) 30px
    );
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-family: 'Pirata One', Georgia, serif;
  font-size: 1.15rem;
  font-weight: normal;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s, box-shadow 0.1s, background-color 0.15s;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, var(--ocean) 0%, var(--ocean-dark) 100%);
  color: var(--parchment-light);
  box-shadow: 0 3px 0 #0a1a30, 0 4px 12px rgba(0,0,0,0.3);
  border: 2px solid var(--ocean-dark);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #234b75 0%, var(--ocean) 100%);
  box-shadow: 0 4px 0 #0a1a30, 0 6px 16px rgba(0,0,0,0.35);
}

.btn-gold {
  background: linear-gradient(180deg, #ddb84e 0%, var(--gold-dark) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 #7a6020, 0 4px 12px rgba(0,0,0,0.3);
  border: 2px solid var(--gold-dark);
}

.btn-gold:hover {
  background: linear-gradient(180deg, #eac85e 0%, #b8932e 100%);
}

.btn-secondary {
  background: linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment-dark) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 #9a7a40, 0 4px 12px rgba(0,0,0,0.2);
  border: 2px solid var(--parchment-dark);
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #fff5d8 0%, var(--parchment) 100%);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-back {
  background: none;
  border: none;
  color: var(--ink-light);
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  padding: 8px 4px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-back:hover { color: var(--ink); }

/* ============================================================
   Main Menu Screen
   ============================================================ */
.screen-menu {
  background-color: var(--ocean-dark);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(26,58,92,0.8) 0%, transparent 70%),
    linear-gradient(180deg, #0d2239 0%, #1a3a5c 40%, #0d2239 100%);
  color: var(--parchment-light);
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 360px;
  padding: 24px 24px 80px;
  position: relative;
  z-index: 2;
}

.menu-title-area {
  text-align: center;
  margin-bottom: 40px;
}

.ship-silhouette {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(201,168,76,0.5));
  animation: anchor-bob 4s ease-in-out infinite;
}

@keyframes anchor-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.game-title {
  font-family: 'Pirata One', Georgia, serif;
  font-size: clamp(2.8rem, 10vw, 4rem);
  color: var(--gold);
  text-shadow:
    0 2px 0 var(--gold-dark),
    0 4px 16px rgba(201,168,76,0.4),
    0 0 40px rgba(201,168,76,0.2);
  letter-spacing: 0.08em;
  line-height: 1;
  margin-bottom: 8px;
}

.game-subtitle {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  color: rgba(232,213,163,0.7);
  font-size: 1.05rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.btn-continue {
  font-size: 1.2rem;
}

/* Waves */
.menu-waves {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  pointer-events: none;
  z-index: 1;
}

.wave {
  position: absolute;
  bottom: 0;
  width: 200%;
  height: 60px;
  background: rgba(26,58,92,0.5);
  border-radius: 50% 50% 0 0;
}

.wave1 {
  animation: wave-roll 8s linear infinite;
  background: rgba(13,34,57,0.6);
  bottom: 0;
  height: 50px;
}

.wave2 {
  animation: wave-roll 12s linear infinite reverse;
  background: rgba(26,58,92,0.35);
  bottom: 10px;
  height: 40px;
}

@keyframes wave-roll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================================
   Config Screen
   ============================================================ */
.screen-config {
  overflow-y: auto;
}

.config-content {
  padding: 20px 20px 40px;
  max-width: 480px;
  margin: 0 auto;
}

.screen-title {
  font-family: 'Pirata One', Georgia, serif;
  font-size: 1.8rem;
  color: var(--ocean);
  text-align: center;
  margin: 8px 0 24px;
  text-shadow: 1px 1px 0 rgba(43,29,14,0.2);
}

.config-section {
  margin-bottom: 24px;
}

.config-section h3 {
  font-family: 'Crimson Text', serif;
  font-size: 1.1rem;
  color: var(--ink-light);
  margin-bottom: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-style: normal;
}

.option-group {
  display: flex;
  gap: 8px;
}

.option-btn {
  flex: 1;
  min-height: 48px;
  padding: 10px 8px;
  background: var(--parchment-light);
  border: 2px solid var(--parchment-dark);
  border-radius: 6px;
  font-family: 'Pirata One', Georgia, serif;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  touch-action: manipulation;
}

.option-btn.active {
  background: linear-gradient(180deg, var(--ocean) 0%, var(--ocean-dark) 100%);
  color: var(--parchment-light);
  border-color: var(--ocean);
  box-shadow: 0 2px 8px rgba(26,58,92,0.4);
}

.option-btn:hover:not(.active) {
  background: var(--parchment-dark);
  border-color: var(--ink-light);
}

.btn-start {
  margin-top: 32px;
  font-size: 1.3rem;
  min-height: 56px;
}

/* ============================================================
   Preparation Screen
   ============================================================ */
.screen-prep {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.prep-content {
  padding: 12px 12px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.prep-content .screen-title {
  font-size: 1.4rem;
  margin-bottom: 12px;
}

.prep-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 600px) {
  .prep-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .ship-list-panel {
    width: 180px;
    flex-shrink: 0;
  }
}

/* Ship List */
.ship-list-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  order: 2;
}

@media (min-width: 600px) {
  .ship-list-panel { order: 0; }
}

.ship-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--parchment-light);
  border: 2px solid var(--parchment-dark);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}

.ship-list-item:hover:not(.ship-placed) {
  border-color: var(--ocean);
  background: #f5e8c4;
}

.ship-list-item.ship-selected {
  border-color: var(--gold);
  background: rgba(201,168,76,0.1);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.3);
}

.ship-list-item.ship-placed {
  opacity: 0.5;
  cursor: default;
}

.ship-list-name {
  flex: 1;
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.ship-list-count {
  font-size: 0.85rem;
  color: var(--ink-light);
  font-family: 'Crimson Text', serif;
}

/* Ship visual in list */
.ship-visual {
  display: flex;
  gap: 1px;
  flex-shrink: 0;
}

.ship-seg {
  width: 12px;
  height: 12px;
  background: var(--ship-wood);
  border-radius: 1px;
}

.ship-seg.seg-bow {
  background: var(--ship-wood-dark);
  border-radius: 3px 1px 1px 3px;
}

.ship-seg.seg-stern {
  background: var(--ship-wood);
  border-radius: 1px 3px 3px 1px;
}

/* Prep controls */
.prep-board-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prep-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
}

.prep-controls .btn-secondary:first-child {
  grid-column: 1;
}

.prep-controls .btn-secondary:nth-child(2) {
  grid-column: 2;
}

.prep-controls .btn-gold,
.prep-controls .btn-primary {
  grid-column: 1 / -1;
}

/* ============================================================
   Board Grid
   ============================================================ */
.board-container {
  display: block;
  width: 100%;
}

.board-with-labels {
  width: 100%;
  gap: 1px;
}

.board-col-label,
.board-row-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Crimson Text', serif;
  font-size: 0.65rem;
  color: var(--ink-light);
  font-weight: 600;
}

.board-cell {
  aspect-ratio: 1;
  background: rgba(232,213,163,0.6);
  border: 1px solid rgba(43,29,14,0.2);
  position: relative;
  overflow: visible;
  transition: background-color 0.1s;
  cursor: default;
  min-width: 0;
  min-height: 0;
}

.board-cell:hover {
  background: rgba(201,168,76,0.15);
}

/* Cell states */
.cell-fog {
  background: rgba(26,58,92,0.12);
}

.cell-fog:hover {
  background: rgba(201,168,76,0.2);
  cursor: crosshair;
}

.cell-ship {
  background: linear-gradient(135deg, var(--ship-plank) 0%, var(--ship-wood) 50%, var(--ship-wood-dark) 100%);
  border-color: var(--sunk-dark);
}

.cell-hit {
  background: radial-gradient(circle, #8b1a1a 0%, #c0392b 60%, #5a0a0a 100%);
  border-color: #8b1a1a;
}

.cell-miss {
  background: radial-gradient(circle, rgba(41,128,185,0.65) 0%, rgba(26,58,92,0.45) 100%);
}

.cell-sunk {
  background: radial-gradient(circle, var(--sunk-dark) 0%, var(--sunk) 60%, #2a1005 100%);
  border-color: var(--sunk-dark);
}

.cell-preview-valid {
  background: rgba(201,168,76,0.4) !important;
  border-color: var(--gold) !important;
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.cell-preview-invalid {
  background: rgba(192,57,43,0.35) !important;
  border-color: var(--hit) !important;
  outline: 2px solid var(--hit);
  outline-offset: -2px;
}

.cell-highlighted {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  z-index: 2;
}

/* Hit / Miss markers */
.hit-marker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  z-index: 2;
  text-shadow: 0 0 6px #ff6600;
  animation: fire-flicker 1.5s ease-in-out infinite alternate;
}

.miss-marker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
  color: var(--miss);
  font-weight: bold;
  z-index: 2;
  opacity: 0.7;
}

/* Ship segments */
.ship-segment {
  position: absolute;
  inset: 2px;
  z-index: 1;
  border-radius: 2px;
}

.ship-bow-h {
  background: linear-gradient(90deg, var(--ship-wood-dark) 0%, var(--ship-plank) 100%);
  border-radius: 40% 4px 4px 40% / 40% 4px 4px 40%;
}

.ship-stern-h {
  background: linear-gradient(90deg, var(--ship-plank) 0%, var(--ship-wood-dark) 100%);
  border-radius: 4px 40% 40% 4px / 4px 40% 40% 4px;
}

.ship-bow-v {
  background: linear-gradient(180deg, var(--ship-wood-dark) 0%, var(--ship-plank) 100%);
  border-radius: 40% 40% 4px 4px / 40% 40% 4px 4px;
}

.ship-stern-v {
  background: linear-gradient(180deg, var(--ship-plank) 0%, var(--ship-wood-dark) 100%);
  border-radius: 4px 4px 40% 40% / 4px 4px 40% 40%;
}

.ship-segment-middle {
  background: var(--ship-wood);
  /* Plank lines */
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 6px,
    rgba(43,29,14,0.12) 6px,
    rgba(43,29,14,0.12) 7px
  );
}

/* ============================================================
   Battle Screen
   ============================================================ */
.screen-battle {
  overflow: hidden;
}

.battle-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.battle-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.turn-indicator {
  background: var(--ocean);
  color: var(--parchment-light);
  padding: 4px 14px;
  border-radius: 20px;
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  font-weight: 600;
}

.grid-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.grid-label {
  flex-shrink: 0;
  font-family: 'Crimson Text', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  font-style: italic;
}

/* Fire zone: status text + fire button side by side */
.fire-zone {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.battle-status {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
  background: rgba(43,29,14,0.08);
  border: 1px solid rgba(43,29,14,0.15);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Crimson Text', serif;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink);
  text-align: center;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-fire {
  flex: 0 0 auto;
  width: auto;
  min-width: 90px;
  min-height: 48px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #ddb84e 0%, var(--gold-dark) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 #7a6020, 0 4px 12px rgba(0,0,0,0.3);
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  font-family: 'Pirata One', Georgia, serif;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-fire:hover:not(:disabled) {
  background: linear-gradient(180deg, #eac85e 0%, #b8932e 100%);
}

.btn-fire:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-fire:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-pass-inline {
  flex-shrink: 0;
  width: auto;
  min-width: 100px;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 0.95rem;
}

/* Battle screen: boards are sized by available height, not width.
   This prevents any scrollbar/overflow recalculation from changing
   board dimensions during animations. */
.screen-battle #attack-board,
.screen-battle #defense-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen-battle .board-container {
  width: min(100%, calc(50dvh - 80px));
  aspect-ratio: 1;
  overflow: hidden;
  margin: 0 auto;
}

.screen-battle .board-with-labels {
  height: 100%;
}

/* Selected cell on attack grid */
.cell-selected {
  outline: 3px solid var(--gold) !important;
  outline-offset: -2px;
  background: rgba(201,168,76,0.25) !important;
  z-index: 3;
}

.cell-fog.cell-selected,
.cell-fog:hover {
  cursor: crosshair;
}

/* ============================================================
   Pause / Pass Screen
   ============================================================ */
.screen-pause {
  background: linear-gradient(180deg, #0d2239 0%, #1a3a5c 100%);
  color: var(--parchment-light);
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.pause-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 32px;
  max-width: 360px;
  text-align: center;
}

.pause-icon {
  font-size: 5rem;
  opacity: 0.85;
  animation: skull-pulse 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(201,168,76,0.3));
}

@keyframes skull-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}

.pause-title {
  font-family: 'Pirata One', Georgia, serif;
  font-size: 2rem;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(201,168,76,0.4);
}

.pause-text {
  font-family: 'Crimson Text', serif;
  font-size: 1.2rem;
  color: rgba(232,213,163,0.9);
  line-height: 1.6;
}

.pause-text strong {
  color: var(--gold);
  font-size: 1.4rem;
}

.btn-continue-large {
  font-size: 1.3rem;
  min-height: 60px;
  padding: 16px 32px;
  width: 100%;
  max-width: 280px;
  letter-spacing: 0.06em;
}

/* ============================================================
   Game Over Screen
   ============================================================ */
.screen-gameover {
  overflow-y: auto;
  justify-content: flex-start;
  align-items: center;
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(201,168,76,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 15% 15%, rgba(255,240,200,0.6) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(180,140,80,0.4) 0%, transparent 55%);
}

.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 20px 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.victory-flag {
  font-size: 3rem;
  animation: flag-wave 2s ease-in-out infinite;
  display: block;
}

@keyframes flag-wave {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50% { transform: rotate(3deg) scale(1.05); }
}

.gameover-title {
  font-family: 'Pirata One', Georgia, serif;
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  color: var(--ocean);
  text-shadow: 1px 2px 0 rgba(43,29,14,0.2);
}

.gameover-subtitle {
  font-family: 'Crimson Text', serif;
  font-style: italic;
  color: var(--ink-light);
  font-size: 1.1rem;
}

.gameover-board-label {
  font-family: 'Crimson Text', serif;
  font-weight: 600;
  color: var(--ink);
  font-size: 1rem;
  align-self: flex-start;
}

#gameover-board {
  width: 100%;
}

.gameover-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

/* ============================================================
   Animations
   ============================================================ */

/* Cannonball (JS-driven, styles for the element created in animations.js) */
.cannonball {
  pointer-events: none;
}

/* Explosion burst */
.explosion-burst {
  position: absolute;
  inset: -20%;
  z-index: 10;
  border-radius: 50%;
  background: radial-gradient(circle, #fff5c0 0%, #ff8c00 40%, #c0392b 70%, transparent 100%);
  animation: explosion-pop 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes explosion-pop {
  0% { transform: scale(0); opacity: 1; }
  60% { transform: scale(1.4); opacity: 0.9; }
  100% { transform: scale(0.9); opacity: 0; }
}

/* Fire flicker */
.fire-flicker {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 80%;
  z-index: 5;
  background: radial-gradient(ellipse at bottom, #ff6600 0%, #ff3300 40%, transparent 100%);
  animation: fire-flicker 1.2s ease-in-out infinite alternate;
  pointer-events: none;
  border-radius: 50% 50% 0 0;
}

@keyframes fire-flicker {
  0%   { transform: translateX(-50%) scaleX(1) scaleY(1); opacity: 0.9; }
  25%  { transform: translateX(-45%) scaleX(0.9) scaleY(1.1); opacity: 1; }
  50%  { transform: translateX(-55%) scaleX(1.1) scaleY(0.9); opacity: 0.85; }
  75%  { transform: translateX(-48%) scaleX(0.95) scaleY(1.05); opacity: 0.95; }
  100% { transform: translateX(-50%) scaleX(1) scaleY(1); opacity: 0.9; }
}

/* Splash ripple */
.splash-ripple {
  position: absolute;
  inset: 10%;
  z-index: 10;
  border-radius: 50%;
  border: 3px solid rgba(41,128,185,0.7);
  animation: splash-expand 0.8s ease-out forwards;
  pointer-events: none;
}

.splash-ripple::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  border: 2px solid rgba(41,128,185,0.5);
  animation: splash-expand 0.8s ease-out 0.15s forwards;
}

@keyframes splash-expand {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(2.5); opacity: 0; }
}

/* Ship shake */
.ship-shake {
  animation: shake 0.5s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-3px); }
  30%, 70% { transform: translateX(3px); }
}

/* Sunk banner */
.sunk-banner {
  background: linear-gradient(90deg, var(--hit), #8b1a1a);
  color: #fff;
  font-family: 'Pirata One', Georgia, serif;
  font-size: 1.1rem;
  padding: 6px 14px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: banner-drop 0.4s ease-out forwards, banner-fade 0.5s ease-in 1.5s forwards;
  pointer-events: none;
}

@keyframes banner-drop {
  0% { transform: translateX(-50%) translateY(-200%); opacity: 0; }
  100% { transform: translateX(-50%) translateY(-110%); opacity: 1; }
}

@keyframes banner-fade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Fog reveal */
.fog-reveal {
  position: absolute;
  inset: 0;
  background: var(--fog);
  z-index: 20;
  transition: opacity 0.8s ease-out;
  opacity: 1;
  pointer-events: none;
}

.fog-reveal.fog-reveal-active {
  opacity: 0;
}

/* Screen shake */
.screen-shake {
  animation: screen-shake 0.5s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ============================================================
   Utilities
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   Scrollbar styling (where supported)
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(43,29,14,0.1);
}

::-webkit-scrollbar-thumb {
  background: var(--parchment-dark);
  border-radius: 3px;
}

/* ============================================================
   Decorative dividers
   ============================================================ */
.divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--parchment-dark), transparent);
  margin: 16px 0;
}

/* ============================================================
   Toast / notification
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--parchment-light);
  padding: 10px 20px;
  border-radius: 24px;
  font-family: 'Crimson Text', serif;
  font-size: 1rem;
  z-index: 10000;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2s forwards;
  pointer-events: none;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
