/* =========================
   GLOBAL / BASE
========================= */
:root{
  --bg: #0b1017;
  --panel: #1a1f2e;
  --panel2: #2a2f3e;
  --text: #f5f7fb;
  --muted: #c9ced8;
  --border: #2a2f3e;

  --green: #4CAF50;
  --green2:#45a049;
  --blue:  #2196F3;
  --red:   #f44336;
  --orange:#FF9800;
}

*{ box-sizing: border-box; }

body{
  background: var(--bg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* On phones: reduce side padding so the board gets bigger */
@media (max-width: 600px){
  .container{ padding: 10px; }
}

/* =========================
   NAVIGATION
========================= */
.navbar{
  background: var(--panel);
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.nav-container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.nav-brand{
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
}

.nav-links{
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-links a{
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.nav-links a:hover{
  background: var(--border);
}

/* =========================
   FLASH MESSAGES
========================= */
.flash{
  padding: 12px 16px;
  margin: 14px 0;
  border-radius: 10px;
  font-weight: 600;
}

.flash-success{ background: var(--green); color: #fff; }
.flash-error{ background: var(--red); color: #fff; }
.flash-info{ background: var(--blue); color: #fff; }

/* =========================
   BUTTONS
========================= */
.btn{
  display: inline-block;
  padding: 12px 20px;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  transition: background 0.2s ease, transform 0.08s ease;
  text-align: center;
}

.btn:hover{ background: var(--green2); }
.btn:active{ transform: translateY(1px); }

.btn-secondary{ background: #666; }
.btn-secondary:hover{ background: #555; }

.btn-small{ padding: 8px 14px; font-size: 14px; }
.btn-full{ width: 100%; }
.btn-primary{ background: var(--green); }
.btn-primary:hover{ background: var(--green2); }

/* =========================
   HOME / HERO
========================= */
.hero{
  text-align: center;
  padding: 50px 20px;
  background: linear-gradient(135deg, var(--panel) 0%, var(--bg) 100%);
  border-radius: 14px;
  margin: 30px 0;
  border: 1px solid var(--border);
}

.hero h1{
  font-size: 2.8rem;
  margin-bottom: 1rem;
  background: linear-gradient(45deg, var(--green), var(--blue));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.subtitle{
  font-size: 1.1rem;
  color: #cfd5df;
  margin-bottom: 1.5rem;
}

.action-buttons{
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* =========================
   GAME SESSIONS / RULES / AUTH
========================= */
.game-sessions{ margin: 30px 0; }

.sessions-list{
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.session-card{
  background: var(--panel);
  padding: 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.session-info{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 12px;
}

.status{
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
}

.status.active{ background: var(--green); color: #fff; }
.status.waiting{ background: var(--orange); color: #fff; }

.players{
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.session-actions{ text-align: center; }

.rules{ margin: 50px 0; }

.rules-list{
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.rule{
  background: var(--panel);
  padding: 1.6rem;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.rule h3{ color: var(--green); margin-bottom: 0.8rem; }

.auth-container{
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.auth-card{
  background: var(--panel);
  padding: 2.2rem;
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
}

.auth-card h1{
  text-align: center;
  margin-bottom: 1.6rem;
  color: var(--text);
}

.auth-form{
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-group{ display: flex; flex-direction: column; }

.form-group label{
  margin-bottom: 0.45rem;
  color: #cfd5df;
  font-weight: 600;
}

.form-group input{
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

.form-group input:focus{
  outline: none;
  border-color: var(--green);
}

.auth-links{
  text-align: center;
  margin-top: 1.2rem;
}

.auth-links a{
  color: var(--green);
  text-decoration: none;
}
.auth-links a:hover{ text-decoration: underline; }

/* =========================
   GAME PAGE LAYOUT
========================= */
.title{
  margin: 10px 0 14px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.game-container{
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* On phones: reduce padding so board becomes larger */
@media (max-width: 600px){
  .game-container{ padding: 10px; }
}

/* Top info area: compress on mobile so board is not tiny */
.game-info{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 14px;
}

.player-info{
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.player{
  padding: 10px 12px;
  border-radius: 10px;
  min-width: 150px;
  border-left: 4px solid;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.white-player{
  background: rgba(255,255,255,0.08);
  border-left-color: #fff;
}

.black-player{
  background: rgba(0,0,0,0.25);
  border-left-color: #000;
}

.player.active-turn{
  box-shadow: 0 0 15px 3px rgba(255,255,0,0.45);
  transform: scale(1.03);
}

.game-controls{
  text-align: center;
  min-width: 280px;
}

.turn-indicator{
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 900;
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid #444;
}

/* Dice styles */
.dice-controls{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.turn-order-section,
.main-dice-section{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.player-rolls{
  display: flex;
  gap: 20px;
  margin-bottom: 6px;
}

.player-roll{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.player-label{ font-size: 13px; color: #cfd5df; }

.dice-turn,
.dice{
  width: 56px;
  height: 56px;
  border: 2px solid #444;
  border-radius: 12px;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dice-turn img,
.dice img{
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dice-main{
  display: flex;
  gap: 12px;
}

.turn-order-btn,
.roll-btn{
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 900;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: var(--green);
  color: #fff;
  transition: background 0.2s ease, transform 0.08s ease;
  min-width: 120px;
}

.turn-order-btn:hover,
.roll-btn:hover{ background: var(--green2); }
.turn-order-btn:active,
.roll-btn:active{ transform: translateY(1px); }

.turn-order-btn:disabled,
.roll-btn:disabled{
  background: #666;
  cursor: not-allowed;
}

.spectator-notice{
  padding: 10px 12px;
  background: var(--orange);
  color: #fff;
  border-radius: 10px;
  font-weight: 900;
}

/* Mobile: compress the top info so the board can be larger */
@media (max-width: 520px){
  .game-info{
    padding: 10px;
    gap: 10px;
  }
  .player{
    min-width: auto;
    width: 100%;
  }
  .game-controls{
    min-width: auto;
    width: 100%;
  }
  .player-rolls{ gap: 12px; }
  .dice-turn, .dice{ width: 48px; height: 48px; }
}

/* =========================
   BOARD
========================= */
.board-wrapper{
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

/* Responsive board */
#board{
  position: relative;
  width: min(98vw, 820px);     /* a bit larger on mobile */
  margin: 0 auto;
  aspect-ratio: 820 / 900;
  border: 2px solid #444;
  border-radius: 12px;

  background-image: url("/static/elements/board.png");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;

  /* enables cqw units */
  container-type: inline-size;
}

/* Groups laid out as 6-column grid */
.point-group{
  position: absolute;

  width: 38.6cqw;    /* 317/820*100 */
  height: 12.2cqw;   /* 100/820*100 */

  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.1cqw;

  box-sizing: border-box;
}

/* Group positions */
#group-0 { top: 82.222%; left: 55.439%; }  /* bottom right */
#group-1 { top: 82.222%; left: 4.927%;  }  /* bottom left */
#group-2 { top: 6.556%;  left: 4.927%;  }  /* top left */
#group-3 { top: 6.556%;  left: 55.439%; }  /* top right */

/* Point rectangles */
.point-rect{
  position: relative;
  width: 100%;
  height: 100%;

  border: 1px solid rgba(255,255,255,0.45);
  background-color: rgba(255,255,255,0.06);
  border-radius: 10px;
  transition: transform 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
  overflow: visible;
}

/* Full-cell click area */
.point-rect form,
.point-rect .point-button{
  width: 100%;
  height: 100%;
}

.point-button{
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

/* Hover + highlights */
.point-button:hover{
  background-color: rgba(255,255,0,0.12);
  border-radius: 10px;
}

.point-rect.selected-source{
  background-color: rgba(255,255,0,0.30);
  box-shadow: 0 0 12px 3px rgba(255,255,0,0.85);
  border: 2px solid rgba(255,255,0,0.85);
  z-index: 10;
}

.point-rect.possible-source{
  background-color: rgba(255,255,0,0.16);
  border: 2px dashed rgba(255,255,0,0.75);
}

.point-rect.possible-destination{
  background-color: rgba(0,255,0,0.22);
  box-shadow: 0 0 10px 3px rgba(0,255,0,0.7);
  border: 2px solid rgba(0,255,0,0.75);
  z-index: 6;
}

.point-rect.first-checker{
  border: 3px solid gold;
  box-shadow: 0 0 14px 4px rgba(255,215,0,0.7);
}

.point-rect.possible-destination:hover{
  background-color: rgba(0,255,0,0.35);
  transform: scale(1.03);
}

/* Point label above each point: make it scale & optionally hide on small screens */
.point-info-label{
  position: absolute;
  top: calc(-1 * clamp(26px, 5cqw, 46px));
  left: 50%;
  transform: translateX(-50%);

  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: clamp(9px, 1.6cqw, 12px);
  font-weight: 900;
  z-index: 25;
  pointer-events: none;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.18);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide point labels on very small screens (makes board cleaner & bigger) */
@media (max-width: 520px){
  .point-info-label{ display: none; }
}

/* =========================
   CHECKERS (scale with board)
========================= */
.checker-label-white,
.checker-label-black{
  text-align: center;
  font-weight: 900;
  z-index: 20;
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;

  font-size: clamp(12px, 2.2cqw, 16px);
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 7px;
}

.checker-label-white{
  color: #000;
  background: rgba(255,255,255,0.95);
  border: 1px solid #000;
}

.checker-label-black{
  color: #fff;
  background: rgba(0,0,0,0.92);
  border: 1px solid rgba(255,255,255,0.7);
}

.checker-img-white,
.checker-img-black{
  width: clamp(22px, 4.6cqw, 34px) !important;
  height: clamp(22px, 4.6cqw, 34px) !important;
  display: block;
  object-fit: contain;
  z-index: 15;
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* =========================
   MOVE INSTRUCTIONS / STATUS
   (optimized to not waste space on mobile)
========================= */
.move-instructions{
  background: var(--panel2);
  padding: 12px 14px;
  border-radius: 12px;
  margin: 10px 0;
  border-left: 4px solid var(--green);
}

.instructions-title{
  color: var(--green);
  font-weight: 900;
  margin-bottom: 6px;
  font-size: 15px;
}

.instructions-text{
  color: var(--text);
  line-height: 1.35;
  font-size: 14px;
  word-break: break-word;
}

.destination-selection{
  margin: 14px 0;
  padding: 14px;
  background: var(--panel2);
  border-radius: 12px;
  text-align: center;
  border: 2px solid var(--green);
}

.destination-selection h3{
  margin-bottom: 10px;
  color: var(--green);
}

.destination-options{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.destination-btn{
  padding: 10px 14px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
  transition: background 0.2s ease, transform 0.08s ease;
}

.destination-btn:hover{ background: var(--green2); }
.destination-btn:active{ transform: translateY(1px); }

.cancel-btn{
  padding: 10px 14px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
  transition: background 0.2s ease, transform 0.08s ease;
}

.cancel-btn:hover{ background: #da190b; }
.cancel-btn:active{ transform: translateY(1px); }

.game-status{
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--panel2);
  border-radius: 12px;
  font-size: 15px;
  text-align: center;
  border-left: 4px solid var(--green);
}

/* =========================
   LEGEND
========================= */
.color-legend{
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.legend-item{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #d7dbe3;
}

.legend-color{
  width: 18px;
  height: 18px;
  border-radius: 6px;
}

.legend-yellow{
  background: rgba(255,255,0,0.25);
  border: 1px solid rgba(255,255,0,0.7);
}

.legend-green{
  background: rgba(0,255,0,0.22);
  border: 1px solid rgba(0,255,0,0.7);
}

.legend-gold{
  background: rgba(255,215,0,0.25);
  border: 1px solid rgba(255,215,0,0.75);
}

/* =========================
   RESPONSIVE: GENERAL
========================= */
@media (max-width: 900px){
  .game-info{
    flex-direction: column;
    text-align: center;
  }
  .player-info{
    justify-content: center;
    width: 100%;
  }
}

/* Phone tuning: reduce extra blocks so the board looks larger */
@media (max-width: 520px){
  .hero h1{ font-size: 2rem; }
  .action-buttons{ flex-direction: column; align-items: center; }
  .btn{ width: 220px; }

  .sessions-list{ grid-template-columns: 1fr; }
  .rules-list{ grid-template-columns: 1fr; }

  .move-instructions,
  .destination-selection,
  .game-status{
    padding: 10px 12px;
    border-radius: 12px;
  }

  .instructions-text{ font-size: 13px; }
}
