/* =============================================
   NIHONGOTIPS – 7 FAMILLES
   Style : Japonais lisible · Rouge & Blanc & Encre
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --ink:        #1c1410;
  --ink-soft:   #4a3f35;
  --paper:      #f7f2e8;
  --paper2:     #ede8da;
  --white:      #fffef9;
  --red:        #c0392b;
  --red-hover:  #a93226;
  --red-light:  rgba(192,57,43,0.1);
  --gold:       #9a7a1a;
  --green-ok:   #2d6a4f;
  --border:     #2c1810;
  --shadow:     rgba(28,20,16,0.14);
  --font-serif: 'Noto Serif JP', serif;
  --font-sans:  'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}

/* Subtle washi paper texture */
body {
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%231c1410' fill-opacity='0.025'%3E%3Cpath d='M0 0h4v4H0V0zm8 8h4v4H8V8zm8 0h4v4h-4V8zm8-8h4v4h-4V0zm8 8h4v4h-4V8zm8 0h4v4h-4V8zm8-8h4v4h-4V0z'/%3E%3C/g%3E%3C/svg%3E");
}

/* ==============================================
   GAME CONTAINER
   ============================================== */
.game-container {
  background: var(--white);
  border: 2px solid var(--border);
  padding: 12px 14px;
  max-width: 1100px;
  margin: 12px auto;
  box-shadow: 4px 4px 0 var(--border), 0 8px 24px var(--shadow);
  position: relative;
}

/* ==============================================
   INFO BAR
   ============================================== */
.info-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 4px solid var(--red);
  margin-bottom: 12px;
}

.top-info { display: flex; flex-direction: column; gap: 2px; }

.room-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: 1px;
}

.player-count {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.player-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  list-style: none;
}

.player-list div {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 2px;
}
.player-list div::before {
  content: "•";
  color: var(--red);
  margin-right: 5px;
}

.families-in-play {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  flex-wrap: wrap;
}
.families-in-play strong { color: var(--red); font-weight: 700; }
#families-list {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.info-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ==============================================
   BOUTONS BARRE D'INFO
   ============================================== */
#restart-game, #quit-game, #back-home {
  padding: 6px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 2px 2px 0 var(--shadow);
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
#restart-game:hover, #back-home:hover {
  background: var(--ink);
  color: var(--white);
}
#quit-game {
  border-color: var(--red);
  color: var(--red);
}
#quit-game:hover {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

/* ==============================================
   TABLE DE JEU
   ============================================== */
#game-table {
  position: relative;
  width: 100%;
  height: 380px;
  background: radial-gradient(ellipse at 50% 50%, #e6f0e6 0%, var(--paper2) 75%);
  border: 2px solid var(--border);
  box-shadow: inset 0 0 30px rgba(28,20,16,0.07), 3px 3px 0 var(--border);
  margin-bottom: 0;
  overflow: visible;
}

/* Grille légère façon goban */
#game-table::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(28,20,16,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28,20,16,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}

/* Filigrane central */
#game-table::before {
  content: "家族";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: 4rem;
  color: rgba(28,20,16,0.04);
  letter-spacing: 10px;
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
}

/* ==============================================
   SLOTS JOUEURS
   ============================================== */
.player-slot {
  position: absolute;
  width: 140px;
  height: 42px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: 2px 2px 0 var(--shadow);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.slot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.player-slot:hover { background: var(--red); color: #fff; border-color: var(--red-hover); }
.empty-slot { opacity: 0.4; cursor: default; }
.empty-slot:hover { background: var(--white); color: var(--ink-soft); border-color: var(--border); }

.top    { top: 10px;    left: 50%; transform: translateX(-50%); }
.bottom { bottom: 10px; left: 50%; transform: translateX(-50%); }
.left   { top: 50%;    left: 10px;  transform: translateY(-50%); }
.right  { top: 50%;    right: 10px; transform: translateY(-50%); }

.active-player {
  background: var(--red) !important;
  border-color: var(--red-hover) !important;
  color: #fff !important;
  animation: pulse-slot 1.8s ease-in-out infinite;
}
@keyframes pulse-slot {
  0%,100% { box-shadow: 0 0 0 2px rgba(192,57,43,0.4), 2px 2px 0 var(--border); }
  50%      { box-shadow: 0 0 0 6px rgba(192,57,43,0.15), 2px 2px 0 var(--border); }
}

/* ==============================================
   PIOCHE — ROUGE bien visible
   ============================================== */
.draw-center {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 58px;
  height: 82px;
  background: var(--red);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  z-index: 20;
  transition: all 0.15s;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border);
}
.draw-icon  { font-size: 1.6rem; line-height: 1; }
.draw-label { font-size: 0.52rem; font-weight: 700; letter-spacing: 0.5px; opacity: 0.9; }

.draw-center:hover {
  background: var(--red-hover);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--border);
}

/* ==============================================
   FAMILLES COMPLÈTES SUR TABLE
   ============================================== */
.player-families {
  position: absolute;
  display: flex;
  gap: 4px;
  pointer-events: none;
  z-index: 10;
}
.top    .player-families { top: 100%;    left: 50%; transform: translateX(-50%); flex-direction: row;    margin-top: 5px; }
.bottom .player-families { bottom: 100%; left: 50%; transform: translateX(-50%); flex-direction: row;    margin-bottom: 5px; }
.left   .player-families { top: 50%;    left: 100%; transform: translateY(-50%); flex-direction: column; margin-left: 5px; }
.right  .player-families { top: 50%;   right: 100%; transform: translateY(-50%); flex-direction: column; margin-right: 5px; }

.family-complete-on-table {
  width: 48px;
  height: 66px;
  border: 2px solid var(--green-ok);
  background: #e8f4ec;
  overflow: hidden;
  box-shadow: 2px 2px 0 var(--green-ok);
}
.family-complete-on-table img { width: 100%; height: 100%; object-fit: contain; }

/* ==============================================
   MAIN DU JOUEUR
   ============================================== */
#player-hand-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 14px 16px;
  background: var(--paper);
  border-top: 2px solid var(--border);
  border-left: 2px solid var(--border);
  border-right: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 4px 0 var(--border);
}

.hand-label {
  font-family: var(--font-serif);
  font-size: 0.72rem;
  color: var(--red);
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 8px;
  opacity: 0.8;
}

.hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px;
}

/* Cartes — plus grandes */
.card {
  width: 110px;
  aspect-ratio: 3/4;
  border: 1.5px solid var(--border);
  border-bottom: 3px solid var(--border);
  background: var(--white);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.15s;
  overflow: hidden;
  box-shadow: 2px 3px 0 var(--shadow);
  position: relative;
}

.card img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Zoom au survol */
.card:hover {
  transform: translateY(-10px) scale(1.08);
  box-shadow: 2px 14px 18px var(--shadow);
  border-color: var(--red);
  z-index: 50;
}

/* Carte sélectionnée */
.card-selected {
  outline: 3px solid var(--red) !important;
  outline-offset: 3px;
  transform: translateY(-12px) scale(1.06) !important;
  box-shadow: 0 12px 20px rgba(192,57,43,0.25) !important;
  z-index: 50;
}

/* ==============================================
   MESSAGES
   ============================================== */
#center-message {
  position: absolute; /* pas fixed */
  font-family: var(--font-sans);
  font-size: 1.3rem; /* plus gros */
  font-weight: 700;
  background: var(--ink);
  border-left: 4px solid var(--red);
  color: var(--paper);
  padding: 12px 22px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 3px 3px 0 var(--red);
  white-space: nowrap;
  text-align: center;
  transition: opacity 0.3s ease;
  z-index: 100;
}

#winner-message {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  padding: 30px 50px;
  background: var(--white);
  border: 3px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(1rem, 4vw, 1.8rem);
  font-weight: 700;
  text-align: center;
  letter-spacing: 3px;
  box-shadow: 6px 6px 0 var(--red), 0 20px 40px rgba(0,0,0,0.25);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#winner-message::before {
  content: "優勝 🏆";
  display: block;
  font-size: 2.2rem;
  color: var(--red);
  margin-bottom: 10px;
}

/* ==============================================
   AIDE
   ============================================== */
#game-help {
  position: fixed;
  top: 10px; right: 10px;
  z-index: 1000;
  max-width: 280px;
}
#help-toggle {
  background: var(--ink);
  border: 1px solid var(--border);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s;
  box-shadow: 2px 2px 0 var(--red);
}
#help-toggle:hover { background: var(--red); box-shadow: 2px 2px 0 var(--ink); }

#help-content {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--red);
  padding: 14px;
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 3px 3px 0 var(--shadow);
}
#help-content h3 {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--red);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--paper2);
}
#help-content ul { list-style: none; }
#help-content li {
  font-size: 0.8rem;
  color: var(--ink);
  padding: 6px 0;
  border-bottom: 1px solid var(--paper2);
  line-height: 1.6;
}
#help-content li:last-child { border-bottom: none; }
#help-content li strong {
  display: block;
  color: var(--red);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  margin-bottom: 1px;
}
#help-content::-webkit-scrollbar { width: 4px; }
#help-content::-webkit-scrollbar-track { background: var(--paper); }
#help-content::-webkit-scrollbar-thumb { background: var(--red); }

/* ==============================================
   APERÇU CARTE
   ============================================== */
#card-preview-img {
  max-width: 88vw;
  max-height: 82vh;
  border: 2px solid var(--paper);
  box-shadow: 6px 6px 0 var(--red), 0 20px 50px rgba(0,0,0,0.5);
}

/* ==============================================
   MOBILE ≤ 600px
   ============================================== */
@media (max-width: 600px) {
  body { font-size: 13px; }

  .game-container {
    margin: 0;
    border-left: none; border-right: none;
    padding: 8px;
    box-shadow: 0 4px 0 var(--border);
  }

  #game-table { height: 240px; }

  .player-slot {
    width: 80px; height: 34px;
    font-size: 0.65rem;
  }
  .top    { top: 6px; }
  .bottom { bottom: 6px; }
  .left   { left: 6px; }
  .right  { right: 6px; }

  .draw-center { width: 44px; height: 64px; top: 8px; left: 8px; }
  .draw-icon  { font-size: 1.3rem; }
  .draw-label { font-size: 0.42rem; }

  .info-bar { gap: 6px; padding: 8px 10px; }
  .room-name { font-size: 0.9rem; }
  .info-actions { margin-left: 0; width: 100%; }
  #restart-game, #quit-game, #back-home { font-size: 0.7rem; padding: 5px 10px; }

  #player-hand-container { padding: 8px 8px 12px; }

  #cards {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
  }
  #cards .card {
    width: 100%;
    aspect-ratio: 3/4;
    height: auto;
  }
  /* Zoom touch-friendly sur mobile (tap) */
  #cards .card:active {
    transform: scale(1.05);
  }

  .family-complete-on-table { width: 38px; height: 53px; }

  #game-help { top: 8px; right: 8px; }
  #help-content { max-height: 220px; }
  #help-toggle { font-size: 0.68rem; }
  #center-message { font-size: 0.72rem; padding: 10px 14px; }
}
