/* ===========================================================
   Bataille navale en ligne — styles
   Mobile-first, compatible iOS Safari / Android Chrome & Firefox
   =========================================================== */

:root {
  --bg-1: #eaf6fa; --bg-2: #d3ecf5; --surface: #ffffff; --surface-alt: #f2fafc;
  --text: #0d2530; --text-dim: #587682; --primary: #0d6e8f; --primary-dark: #0a5570;
  --primary-contrast: #ffffff; --accent: #e0a63c; --success: #2c9d63; --success-bg: #e2f5ea;
  --danger: #d13a3a; --danger-bg: #fdeaea; --border: #d3ecf5; --shadow: 0 8px 24px rgba(10, 70, 90, .14);
  --radius: 18px; --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --water: #bfe4f0; --water-dark: #9dd2e5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #071b22; --bg-2: #0c2530; --surface: #112a34; --surface-alt: #163340;
    --text: #e8f6fb; --text-dim: #9fbcc7; --primary: #4db8de; --primary-dark: #6ecbef;
    --primary-contrast: #06171d; --accent: #f0bd5a; --success: #57c98a; --success-bg: #133a26;
    --danger: #ff7a7a; --danger-bg: #3a1c1c; --border: #1c3b47; --shadow: 0 8px 28px rgba(0,0,0,.5);
    --water: #12384a; --water-dark: #0d2c3a;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: radial-gradient(circle at 20% -10%, var(--bg-2), var(--bg-1) 60%);
  -webkit-font-smoothing: antialiased; touch-action: manipulation; overscroll-behavior-y: contain;
  user-select: none;
}
button, input, select { font-family: inherit; font-size: 16px; }

.app { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-top)) 12px calc(100px + var(--safe-bottom)); min-height: 100dvh; }
.view { display: none; animation: fade-in .25s ease; }
.view.active { display: flex; flex-direction: column; gap: 12px; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

.brand { text-align: center; margin-top: 8px; }
.brand-emoji { font-size: 48px; line-height: 1; }
.brand h1 { margin: 4px 0 2px; font-size: 32px; letter-spacing: -0.02em; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 15px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 13px; color: var(--text-dim); font-weight: 600; }

/* Case à cocher inline (Mode Bénéficiaire AAH, voir public/shared/AAH_MODE.md
   — motif dupliqué depuis games/petit-bac/public/style.css, chaque jeu de
   cette plateforme restant autonome pour son propre CSS). */
.field-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); margin: 12px 0; }
.field-inline input { width: 20px; height: 20px; flex-shrink: 0; }
input[type="text"], input[type="number"], select {
  padding: 12px 13px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-alt); color: var(--text); outline: none; transition: border-color .15s ease; width: 100%;
}
input:focus, select:focus { border-color: var(--primary); }
#input-code { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }

.btn {
  border: none; border-radius: 14px; padding: 12px 16px; font-weight: 700; font-size: 14.5px;
  cursor: pointer; transition: transform .08s ease, opacity .15s ease; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); box-shadow: 0 6px 16px rgba(13,110,143,.35); }
.btn-secondary { background: var(--surface-alt); color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1.5px solid var(--border); }
.btn-big { width: 100%; padding: 15px; font-size: 16px; }

.landing-actions { display: flex; flex-direction: column; }
.landing-actions .btn-primary { margin-bottom: 4px; }
.divider { text-align: center; color: var(--text-dim); font-size: 13px; margin: 14px 0; position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.divider::before { left: 0; } .divider::after { right: 0; }
.hint { color: var(--text-dim); font-size: 13px; text-align: center; line-height: 1.5; margin: 0; }
.hint.tight { text-align: left; margin-top: 4px; }
.hint.center { text-align: center; padding: 10px; }

.topbar { display: flex; align-items: center; justify-content: space-between; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 40px; height: 40px; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; font-size: 13px; }
.room-code-badge { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 7px 11px; }
.room-code-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }
.room-code-value { font-weight: 800; letter-spacing: 0.15em; font-size: 17px; color: var(--primary); }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.player-row { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 12px; background: var(--surface-alt); }
.player-row .dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; flex-shrink: 0; }
.player-row .dot.online { background: var(--success); }
.player-row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-row .host-tag { font-size: 11px; background: var(--primary); color: var(--primary-contrast); padding: 2px 7px; border-radius: 20px; }
.player-row .wins-tag { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

.section-title { margin: 4px 0 0; font-size: 20px; }
.section-title.center { text-align: center; }
.results-list { display: flex; flex-direction: column; gap: 10px; }
.result-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.result-row .rank { font-weight: 800; color: var(--text-dim); width: 22px; text-align: center; flex-shrink: 0; }
.result-row.first { border-color: var(--primary); }
.result-row .name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .wins-tag { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.confetti-emoji { text-align: center; font-size: 52px; }
.round-footer { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

.players-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.players-strip::-webkit-scrollbar { display: none; }
.player-chip {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--border); font-size: 12.5px; font-weight: 700;
}
.player-chip.current-turn { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,143,.15); }
.player-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #bbb; }
.player-chip .dot.online { background: var(--success); }

.turn-banner { text-align: center; font-weight: 800; font-size: 14.5px; padding: 9px 12px; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.turn-banner.my-turn { background: var(--primary); color: var(--primary-contrast); }

.event-log { font-size: 12px; color: var(--text-dim); line-height: 1.7; max-height: 120px; overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--border); }
.log-entry:first-child { color: var(--text); font-weight: 600; }
.log-entry-enter { animation: logIn .32s cubic-bezier(.22,1,.36,1); }
@keyframes logIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- Sélection des navires (placement) ---------- */

.ship-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ship-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface-alt); cursor: pointer; text-align: left;
}
.ship-chip .ship-icon { font-size: 16px; letter-spacing: -2px; }
.ship-chip .ship-name { flex: 1; font-weight: 700; font-size: 13px; }
.ship-chip .ship-size { font-size: 11px; color: var(--text-dim); }
.ship-chip.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,143,.15); }
.ship-chip.placed { border-color: var(--success); background: var(--success-bg); }
.placement-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.placement-actions .btn { flex: 1; min-width: 120px; }

.board-title { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 -2px; }

/* ---------- Grilles 10x10 avec repères ---------- */

.board-wrap { display: flex; justify-content: center; }
.board-wrap.small { opacity: .95; }
.grid-with-labels { display: inline-flex; flex-direction: column; gap: 3px; }
.col-labels { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; padding-left: 20px; }
.col-labels span, .row-labels span { display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--text-dim); font-weight: 700; }
.grid-body { display: flex; gap: 3px; }
.row-labels { display: grid; grid-template-rows: repeat(10, 1fr); gap: 2px; width: 16px; }

.bn-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); gap: 2px;
  background: var(--water-dark); border-radius: 8px; padding: 3px; width: min(90vw, 340px); aspect-ratio: 1;
}
.board-wrap.small .bn-grid { width: min(70vw, 260px); }

.bn-cell {
  background: var(--water); border-radius: 3px; position: relative; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.bn-cell.not-clickable { cursor: default; }
.bn-cell.ship { background: var(--primary-dark); }
.bn-cell.ship.own { background: var(--primary); }
.bn-cell.selected-ghost { background: var(--accent); opacity: .6; }
.bn-cell.miss::after { content: '·'; color: var(--text-dim); font-size: 22px; font-weight: 900; }
.bn-cell.hit { background: var(--danger); }
.bn-cell.hit::after { content: '✕'; color: #fff; font-weight: 900; font-size: 13px; }
.bn-cell.sunk { background: #7a1f1f; }
.bn-cell.sunk::after { content: '☠'; color: #fff; font-size: 12px; }
.bn-cell.shake { animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
.bn-cell.fire-anim { animation: fireIn .3s ease; }
@keyframes fireIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.fleet-status { display: flex; justify-content: space-around; gap: 8px; background: var(--surface); border-radius: 12px; padding: 10px; border: 1px solid var(--border); font-size: 12.5px; font-weight: 700; }

/* ---------- Emoji / réactions / toast ---------- */

.react-fab {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + var(--safe-bottom));
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--primary); color: var(--primary-contrast); font-size: 20px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.3); z-index: 45;
}
.react-fab:active { transform: scale(0.92); }

.reaction-picker {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(68px + var(--safe-bottom));
  background: rgba(20, 20, 30, 0.92); border-radius: 22px; padding: 8px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  max-width: min(80vw, 230px); z-index: 46; box-shadow: var(--shadow);
}
.reaction-choice { border: none; background: none; font-size: 20px; padding: 6px; cursor: pointer; border-radius: 50%; line-height: 1; }
.reaction-choice:active { background: rgba(255,255,255,0.18); transform: scale(1.15); }

#reaction-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.floating-reaction { position: absolute; bottom: 90px; display: flex; flex-direction: column; align-items: center; animation: float-up 2.6s ease-out forwards; }
.floating-reaction .emoji { font-size: 40px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }
.floating-reaction .who { font-size: 11px; font-weight: 700; color: var(--text-dim); background: var(--surface); padding: 2px 8px; border-radius: 20px; margin-top: 2px; }
@keyframes float-up {
  0% { opacity: 0; transform: translateY(20px) scale(.6) rotate(-6deg); }
  15% { opacity: 1; transform: translateY(-10px) scale(1.05) rotate(3deg); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-260px) scale(1) rotate(-4deg); }
}

.toast { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%) translateY(-140%); background: var(--danger); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 80; transition: transform .25s ease; max-width: 90%; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); }
.connection-banner { position: fixed; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 13px; z-index: 80; box-shadow: var(--shadow); }

@media (min-width: 640px) {
  .brand h1 { font-size: 38px; }
}

/* Salon d'attente unifié visuellement sur le modèle du 8-américain */
.lobby-card { text-align: center; }
.lobby-card h2 { text-transform: none; font-size: 20px; color: var(--text); letter-spacing: normal; }
.lobby-card .room-code-label {
  text-align: center; color: var(--text-dim); margin: 10px 0 6px;
  font-size: 13px; text-transform: none;
}
.lobby-card .room-code-badge { justify-content: center; margin: 0 auto 4px; width: fit-content; }
.players-title {
  margin: 20px 0 10px; font-size: 13px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .04em; text-align: left;
}
.lobby-card .player-list,
.lobby-card #host-settings,
.lobby-card #guest-waiting,
.lobby-card #path-picker { text-align: left; }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.lobby-actions .icon-btn {
  width: auto; height: auto; padding: 13px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 700; background: transparent; color: var(--text-dim);
  border: 1.5px solid var(--border);
}
