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

:root {
  --bg-primary: #001633;
  --bg-secondary: #0A2540;
  --bg-card: #0E2A47;
  --text-primary: #FFFFFF;
  --text-secondary: #78909C;
  --accent: #FFAB40;
  --accent-glow: rgba(255, 171, 64, 0.25);
  --accent2: #85D5E6;
  --accent2-glow: rgba(133, 213, 230, 0.2);
  --success: #0097A7;
  --border: #1A3A5C;

  /* Échiquier accordé au thème navy */
  --square-light: #B8CADA;
  --square-dark: #2E5077;
  --square-select: var(--accent);
  --square-target: var(--accent2);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: Arial, 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

/* ============ Header ============ */
header {
  text-align: center;
  padding: 50px 24px 28px;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.header-logo {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), #FFD180);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Les initiales de l'école (Télécom Nancy) mises en avant dans le wordmark. */
header h1 .tn {
  -webkit-text-fill-color: var(--accent2);
  color: var(--accent2);
}

.subtitle {
  margin: 6px auto 0;
  max-width: 640px;
  font-size: 1.05rem;
  color: var(--accent2);
  font-weight: 400;
}

.warning {
  margin: 12px auto 0;
  max-width: 640px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Texte de la même couleur que le fond : invisible à l'œil, mais bien présent
   dans la page (révélé en sélectionnant le texte ou en lisant la source). */
.whisper {
  color: var(--bg-primary);
}

.ps {
  margin: 14px auto 0;
  max-width: 640px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-secondary);
}

/* ============ Game layout ============ */
.game {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
}

/* ============ Board ============ */
.board {
  width: 480px;
  height: 480px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 24px var(--accent2-glow);
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.7rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.square.light { background: var(--square-light); }
.square.dark { background: var(--square-dark); }

.square.selected {
  background: var(--square-select) !important;
  box-shadow: inset 0 0 0 3px #FFD180;
}

/* Petit repère sur les cases d'arrivée légales. */
.square.target::after {
  content: "";
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--square-target);
  box-shadow: 0 0 10px var(--accent2-glow);
  opacity: 0.85;
}

.square.target:has(.piece)::after {
  width: 84%;
  height: 84%;
  background: transparent;
  border: 4px solid var(--square-target);
  box-shadow: inset 0 0 12px var(--accent2-glow);
}

/* Pièces pleines pour les deux camps ; seule la couleur distingue les camps. */
.piece {
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.piece.white {
  color: #FFFFFF;
  text-shadow: 0 0 2px #001633, 0 1px 2px rgba(0, 0, 0, 0.6);
}
.piece.black {
  color: #0A1F38;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.35);
}

/* ============ Panel ============ */
.panel {
  flex: 1 1 260px;
  min-width: 240px;
  max-width: 340px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

button {
  background: var(--accent);
  color: var(--bg-primary);
  border: 0;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.2s, box-shadow 0.2s;
}
button:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px var(--accent-glow);
}

.status {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.status span { color: var(--text-primary); font-weight: 600; }

.message {
  min-height: 1.4em;
  font-style: italic;
  color: var(--accent2);
  line-height: 1.5;
}

.flag {
  padding: 14px;
  border-radius: 10px;
  background: rgba(0, 151, 167, 0.12);
  border: 1px solid var(--success);
  color: #E0F7FA;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-all;
  box-shadow: 0 0 20px rgba(0, 151, 167, 0.25);
}
.hidden { display: none; }

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* ============ Overlay "gotcha" ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 8, 22, 0.85);
  backdrop-filter: blur(3px);
}
.overlay.hidden { display: none; }

.overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 90vw;
}
.overlay-inner img {
  width: 100%;
  max-width: min(520px, 88vw);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.6), 0 0 30px var(--accent-glow);
}

/* ============ Footer ============ */
footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ============ Responsive ============ */
@media (max-width: 700px) {
  header h1 { font-size: 2rem; }
  .header-logo { font-size: 2.2rem; }
  .board {
    width: 92vw;
    height: 92vw;
    max-width: 480px;
    max-height: 480px;
  }
  .square { font-size: 8.5vw; }
  .panel { max-width: none; }
}
