/* ============================================================
   Massiwa : Archipel — Game board styles
   Plateau de jeu 8x8 avec cases en périphérie
   ============================================================ */

:root {
  --board-size: min(88vmin, 760px);
  --cell-size: calc(var(--board-size) / 8);
}

.page-game {
  background: radial-gradient(ellipse at top, #1a3a5c 0%, #0a2342 60%, #050f1f 100%);
  min-height: 100vh;
  color: var(--parchment);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(to bottom, rgba(10, 35, 66, 0.95), rgba(10, 35, 66, 0.6));
  border-bottom: 1px solid rgba(201, 162, 39, 0.3);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-light);
  letter-spacing: 2px;
  text-decoration: none;
}
.brand-mark { font-size: 24px; }
.brand-text em { font-family: var(--font-script); font-style: italic; font-size: 14px; color: var(--sea-foam); margin-left: 6px; letter-spacing: 1px; }

.topbar-info { display: flex; gap: 12px; align-items: center; }
.topbar-room, .topbar-state {
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 3px;
  background: rgba(244, 211, 94, 0.1);
  border: 1px solid rgba(201, 162, 39, 0.4);
  color: var(--gold-light);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

.hidden { display: none !important; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.game-main {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

@media (max-width: 1100px) {
  .game-main { grid-template-columns: 1fr; }
  .panel { max-height: none; }
}

/* ============================================================
   PANELS (left & right)
   ============================================================ */
.panel {
  background: linear-gradient(180deg, rgba(244, 232, 193, 0.08) 0%, rgba(10, 35, 66, 0.7) 100%);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 6px;
  padding: 16px;
  backdrop-filter: blur(6px);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-light);
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(201, 162, 39, 0.3);
  padding-bottom: 8px;
}

.panel-section { margin-top: 18px; }
.panel-subtitle {
  font-family: var(--font-title);
  font-size: 13px;
  color: var(--sea-foam);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ============================================================
   PLAYER LIST
   ============================================================ */
.player-list { list-style: none; }
.player-empty { color: var(--sea-foam); font-style: italic; font-size: 14px; padding: 12px 0; text-align: center; }

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(10, 35, 66, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.2);
  border-radius: 4px;
  transition: all 0.2s;
  position: relative;
}
.player-card.active {
  background: rgba(201, 162, 39, 0.15);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(244, 211, 94, 0.3);
}
.player-card.active::before {
  content: '▶';
  position: absolute;
  left: -10px;
  color: var(--gold-light);
  font-size: 14px;
  animation: bounceX 1s ease-in-out infinite;
}
@keyframes bounceX {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3px); }
}

.player-token {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.player-info { flex: 1; min-width: 0; }
.player-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 13px;
  color: var(--parchment);
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-money {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--gold-light);
}
.player-money.negative { color: #e07a5f; }

.player-card.eliminated {
  opacity: 0.55;
  filter: grayscale(0.5);
}

/* ============================================================
   DICE
   ============================================================ */
.dice-display { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }

.die {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.die-face {
  width: 60px;
  height: 60px;
  background: linear-gradient(160deg, #fff5d0 0%, #f4d35e 50%, #c9a227 100%);
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ink);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s;
}
.die-face.rolling { animation: roll 0.5s ease; }
@keyframes roll {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(360deg) scale(1.2); }
  100% { transform: rotate(720deg) scale(1); }
}
.die-label { font-family: var(--font-title); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--sea-foam); }

.dice-hint { font-size: 11px; font-style: italic; color: var(--sea-foam); text-align: center; margin-top: 6px; }

.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   LOG
   ============================================================ */
.log-list {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.log-list::-webkit-scrollbar { width: 6px; }
.log-list::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
.log-list::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

.log-empty { color: var(--sea-foam); font-style: italic; font-size: 13px; padding: 10px 0; text-align: center; }
.log-item {
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 13px;
  background: rgba(10, 35, 66, 0.4);
  border-left: 2px solid var(--gold);
  border-radius: 0 3px 3px 0;
  line-height: 1.4;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(-10px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   CONTROLS
   ============================================================ */
.lobby-controls { display: flex; flex-direction: column; gap: 8px; }
.input {
  background: rgba(10, 35, 66, 0.6);
  border: 1px solid rgba(201, 162, 39, 0.3);
  border-radius: 3px;
  padding: 8px 10px;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--gold); }
.input::placeholder { color: rgba(179, 224, 230, 0.5); font-style: italic; }

.connection-status {
  font-size: 12px;
  text-align: center;
  color: var(--sea-foam);
  margin-top: 8px;
  font-style: italic;
}
.connection-status.connected { color: #5f8d4e; }

.my-properties { max-height: 200px; overflow-y: auto; }
.my-properties .hint { color: var(--sea-foam); font-style: italic; font-size: 13px; }

.action-panel {
  border-top: 1px solid rgba(201, 162, 39, 0.25);
  padding-top: 12px;
}

.action-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(10, 35, 66, 0.55);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 4px;
  font-size: 13px;
}

.action-card span {
  color: var(--sea-foam);
}
.my-prop {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  margin-bottom: 3px;
  background: rgba(10, 35, 66, 0.4);
  border-left: 3px solid var(--gold);
  font-size: 12px;
  border-radius: 0 3px 3px 0;
}

/* ============================================================
   BOARD WRAPPER
   ============================================================ */
.board-wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
}

.board-frame {
  position: relative;
  width: var(--board-size);
  padding: 30px 20px 20px;
  background:
    radial-gradient(ellipse at center, #f4e8c1 0%, #d4b878 70%, #8b6914 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9'/%3E%3CfeColorMatrix values='0 0 0 0 0.85 0 0 0 0 0.7 0 0 0 0 0.4 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  background-blend-mode: multiply;
  border: 8px solid var(--wood-dark);
  border-radius: 8px;
  box-shadow:
    inset 0 0 30px rgba(60, 30, 10, 0.3),
    0 16px 48px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--gold);
  outline: 3px solid var(--wood-dark);
  outline-offset: -2px;
}

/* ============================================================
   BOARD TITLE (MASSIWA pirate)
   ============================================================ */
.board-title {
  position: relative;
  text-align: center;
  margin-bottom: 8px;
}

.title-ropes {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 30px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.6;
}

.board-title-text {
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 76px);
  letter-spacing: 8px;
  margin: 0;
  padding: 0 10px;
  display: inline-block;
  background: linear-gradient(180deg, #fff5d0 0%, #f4d35e 25%, #c9a227 60%, #7a5c10 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter:
    drop-shadow(0 1px 0 #3d2817)
    drop-shadow(0 2px 0 #2a1a0a)
    drop-shadow(0 3px 0 #1a0f06)
    drop-shadow(0 5px 8px rgba(0, 0, 0, 0.5));
  text-shadow: none;
  position: relative;
  z-index: 1;
}

.board-subtitle {
  font-family: var(--font-script);
  font-style: italic;
  font-size: 14px;
  color: var(--wood-dark);
  letter-spacing: 3px;
  margin-top: 2px;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.5);
}

/* ============================================================
   BOARD GRID
   ============================================================ */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--wood-dark);
  padding: 2px;
  border-radius: 4px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
}

/* Les cellules vides au centre */
.board .cell-empty {
  background:
    radial-gradient(ellipse at center, #c9a227 0%, #8b6914 40%, #5b3a29 100%);
  position: relative;
  overflow: hidden;
}

/* Centre : carte des Comores */
.board .cell-center {
  grid-column: 2 / span 6;
  grid-row: 2 / span 6;
  background:
    radial-gradient(ellipse at center, #b3e0e6 0%, #5d9bcf 50%, #2c5784 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Cases propriétés (rectangles en périphérie) */
.cell {
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dk) 100%);
  border: 1px solid var(--wood);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cell:hover {
  transform: scale(1.05);
  z-index: 5;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.cell .cell-color {
  width: 100%;
  height: 22%;
  flex-shrink: 0;
}

.cell .cell-name {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-title);
  font-size: 9px;
  font-weight: 700;
  color: var(--ink);
  padding: 2px;
  line-height: 1.1;
  word-break: break-word;
  overflow: hidden;
}

.cell .cell-price {
  font-family: var(--font-body);
  font-size: 9px;
  color: var(--wood-dark);
  text-align: center;
  padding: 1px 0;
  background: rgba(244, 232, 193, 0.5);
}

/* Cell orientation (rotation based on side) */
.cell-bottom { transform: rotate(0deg); }
.cell-right  { transform: rotate(90deg); }
.cell-top    { transform: rotate(180deg); }
.cell-left   { transform: rotate(270deg); }

/* Pions sur les cases */
.cell-tokens {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  z-index: 3;
}
.token-mini {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--parchment);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   SPECIAL CORNER CELLS (BAHATI, SANDUK, MTSANGO, MADJILISSE)
   ============================================================ */
.cell-special {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--font-display);
  color: var(--parchment);
  position: relative;
  overflow: hidden;
  padding: 4px;
}

.cell-special .special-icon {
  font-size: clamp(20px, 4vmin, 36px);
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
.cell-special .special-name {
  font-size: clamp(9px, 1.6vmin, 14px);
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.cell-special .special-sub {
  font-family: var(--font-script);
  font-size: clamp(7px, 1.2vmin, 10px);
  font-style: italic;
  margin-top: 2px;
  opacity: 0.9;
}

/* BAHATI — case départ (au sud) */
.cell-bahati {
  background: linear-gradient(135deg, #2c5784 0%, #5d9bcf 50%, #b3e0e6 100%);
  border: 2px solid #c9a227;
  box-shadow: inset 0 0 20px rgba(244, 211, 94, 0.3), 0 0 12px rgba(244, 211, 94, 0.4);
}
.cell-bahati::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
  pointer-events: none;
}
.cell-bahati::after {
  content: '★';
  position: absolute;
  top: 4px;
  right: 4px;
  color: #f4d35e;
  font-size: 14px;
  text-shadow: 0 0 8px rgba(244, 211, 94, 0.8);
  animation: twinkle 2s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.85); }
}

/* SANDUK — coffre au trésor (au nord) */
.cell-sanduk {
  background: linear-gradient(135deg, #3d2817 0%, #5b3a29 50%, #8b5a2b 100%);
  border: 2px solid #c9a227;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 0 16px rgba(244, 211, 94, 0.5);
}
.cell-sanduk::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0, transparent 8px, rgba(244, 211, 94, 0.1) 8px, rgba(244, 211, 94, 0.1) 10px),
    radial-gradient(circle at 50% 50%, rgba(244, 211, 94, 0.3) 0%, transparent 70%);
  pointer-events: none;
}
.cell-sanduk::after {
  content: '💎';
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  filter: drop-shadow(0 0 4px rgba(244, 211, 94, 0.8));
  animation: glow 1.5s ease-in-out infinite alternate;
}
@keyframes glow {
  from { filter: drop-shadow(0 0 4px rgba(244, 211, 94, 0.5)); transform: scale(1); }
  to   { filter: drop-shadow(0 0 12px rgba(244, 211, 94, 1)); transform: scale(1.1); }
}

/* MTSANGO — chance (à l'ouest) */
.cell-mtsango {
  background: linear-gradient(135deg, #5F8D4E 0%, #C1D8B0 100%);
  border: 2px solid #285430;
}
.cell-mtsango::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  pointer-events: none;
}

/* MADJILISSE — caisse de communauté (à l'est) */
.cell-madjilisse {
  background: linear-gradient(135deg, #7B5EA7 0%, #D5C5E8 100%);
  border: 2px solid #3D2C8D;
}
.cell-madjilisse::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  pointer-events: none;
}

/* ============================================================
   ISLAND BANNER INSIDE CELL
   ============================================================ */
.cell-island-label {
  position: absolute;
  bottom: 1px;
  right: 1px;
  font-family: var(--font-title);
  font-size: 7px;
  letter-spacing: 0.5px;
  color: rgba(26, 15, 6, 0.5);
  text-transform: uppercase;
  pointer-events: none;
}

/* ============================================================
   COMPASS ROSE (superposé sur le plateau)
   ============================================================ */
.compass-rose {
  position: absolute;
  bottom: 30px;
  right: 30px;
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  z-index: 10;
  pointer-events: none;
  animation: compassFloat 8s ease-in-out infinite;
}
@keyframes compassFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}

@media (max-width: 800px) {
  .compass-rose { width: 70px; height: 70px; bottom: 18px; right: 18px; }
}

/* ============================================================
   CENTER MAP (4 islands)
   ============================================================ */
.center-map {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.center-map svg { width: 92%; height: 92%; }

.island-shape {
  transition: all 0.3s;
  cursor: pointer;
}
.island-shape:hover {
  filter: drop-shadow(0 0 12px rgba(244, 211, 94, 0.8));
  transform: scale(1.05);
  transform-origin: center;
}

.center-compass {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 50px;
  height: 50px;
  opacity: 0.6;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
}
.modal-content {
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dk) 100%);
  color: var(--ink);
  max-width: 540px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 40px;
  border-radius: 8px;
  border: 4px solid var(--wood-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  position: relative;
}
.modal-content h2 {
  font-family: var(--font-display);
  color: var(--wood-dark);
  margin-bottom: 20px;
  letter-spacing: 2px;
}
.modal-content ol { padding-left: 24px; }
.modal-content li {
  margin-bottom: 12px;
  line-height: 1.6;
  font-size: 16px;
}
.modal-content strong { color: var(--wood-dark); }
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  background: var(--wood-dark);
  color: var(--parchment);
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}
.modal-close:hover { background: var(--wood); }

/* ============================================================
   CANVAS BOARD (V3.0.6 style, glow-up) -- replaces the DOM grid
   ============================================================ */
.board-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 2px #1a1a1a;
  background: #2AA0D8;
}
#boardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}
.board-islands-nav {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  z-index: 2;
}
.board-island-btn {
  border: 1.5px solid #1a1a1a;
  background: #ffffff;
  color: #1a1a1a;
  font-family: 'Georgia', serif;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.board-island-btn:hover { background: #f0f0f0; }
.board-island-btn.active { background: #1a1a1a; color: #fff; }

/* ============================================================
   DICE -- glow-up: flag reveal for the Comorian die, pip-style
   standard die, smoother roll animation, gold glow on result
   ============================================================ */
.dice-display { perspective: 600px; }
.die-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.4s ease;
  transform-style: preserve-3d;
}
.die-standard .die-face,
.die-comorian .die-face {
  background: #ffffff;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
}
.die-face.rolling {
  animation: diceSpin 0.5s ease-out;
}
@keyframes diceSpin {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(720deg); }
}
.die-pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 68%;
  height: 68%;
}
.die-pips span { border-radius: 50%; background: transparent; align-self: center; justify-self: center; width: 22%; height: 22%; }
.die-pips span.on { background: #1a1a1a; }
.dice-flag-wrap {
  width: 70%;
  height: 70%;
}
.dice-flag-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.die-comorian-icon { font-size: 22px; }
