body {
    background: #222;
    color: white;
    font-family: sans-serif;
}

#game-table {
    width: 100%;
    margin: auto;
    display: flex;              /* make parent a flex container */
    flex-direction: column;
    justify-content: center;    /* horizontal centering */
    align-items: center;        /* vertical centering */
    min-height: 100vh;          /* make parent take full viewport height */
}

/* ---------------- OPPONENTS ---------------- */

#opponents {
    display: flex;
    justify-content: center;
    width: fit-content;      /* 🔑 THIS */
    margin: 0 auto;          /* centers the shrink-wrapped row */
}


/* 1 opponent */
#opponents:has(.opponent-board:nth-child(1):last-child) {
    gap: 32px;
    padding-inline: 32px;
}

/* 2 opponents */
#opponents:has(.opponent-board:nth-child(2):last-child) {
    gap: 24px;
    padding-inline: 24px;
}

/* 3 opponents */
#opponents:has(.opponent-board:nth-child(3):last-child) {
    gap: 16px;
    padding-inline: 16px;
}

/* 4 opponents */
#opponents:has(.opponent-board:nth-child(4):last-child) {
    gap: 0px;
    padding-inline: 0px;
}

.opponent-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* 🔑 allows absolute tokens inside */
    width: 320px;       /* match the image width exactly */
}

.opponent-board-container {
    position: relative;
    width: 320px;
    border-radius: 12px;
    background: transparent;
}

.opponent-board-container img {
    width: 100%;
    display: block;
}

/* Active (your turn) effect */
.opponent-board-container.active {
  animation: turnPulse 3s ease-in-out infinite;
}

@keyframes turnPulse {
  0% {
    box-shadow: 0 0 8px 3px rgba(255, 215, 0, 0.5);
  }
  50% {
    box-shadow: 0 0 18px 6px rgba(255, 215, 0, 0.95);
  }
  100% {
    box-shadow: 0 0 8px 3px rgba(255, 215, 0, 0.5);
  }
}

.player-name {
    margin-top: 4px;
    font-size: 24px;
    white-space: nowrap;
    pointer-events: none;
}


/* ---------------- PLAYER ---------------- */

#player-area {
    display: flex;
    width: 100%;
    flex-direction: row;   /* 🔑 stack board then button */
    align-items: center;      /* center horizontally */
    justify-content: center;
    gap: 14px;                /* space between board and button */
}


#board-container {
    position: relative;
    flex: 0 0 auto;     /* do NOT grow or shrink */
    width: 500px;
}

/* Active (your turn) effect */
#board-container.active {
  animation: turnPulse 3s ease-in-out infinite;
}


#board {
    margin-top: 20px;
    width: 100%;
    display: block;
}


/* RIGHT SCORE */
.score-zone {
    flex: 1 1 0;        /* fill remaining space */
    min-width: 0;
    margin-top: 10px;
    display: block;
    max-width: 25%;    /* prevents image overflow */
}

/* tile holding areas */
.hand-zone {
    flex: 1 1 0;         /* 🔑 fill remaining space */
    min-width: 0;        /* important for flex overflow */
    min-height: 300px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
    justify-content: center;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    max-width: 25%;
}

/* subtle visual hint */
.hand-zone {
    background: rgba(255,255,255,0.04);
}

.hand-tile {
    width: 60px;
    height: 110px;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.hand-tile:active {
    cursor: grabbing;
}

.hand-tile.dragging {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    cursor: grabbing;
}


.button-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
#submit-btn {
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    width: 150px;
    height: 50px;
    background: linear-gradient(180deg, #4caf50, #388e3c);
    font-size: 24px;
    box-shadow: 0 5px 0 #2e7d32;
}

#submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 #2e7d32;
}

#submit-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2e7d32;
}

#cancel-btn {
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    width: 150px;
    height: 50px;
    background: linear-gradient(180deg, #b14937, #fa674d);
    font-size: 24px;
    box-shadow: 0 5px 0 #ff593b;
}

#cancel-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 #ff593b;
}

#cancel-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #ff593b;
}

.continue-btn {
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    width: 150px;
    height: 50px;
    background: linear-gradient(180deg, #4caf50, #388e3c);
    font-size: 24px;
    box-shadow: 0 5px 0 #2e7d32;
}

.continue-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 0 #2e7d32;
}

.continue-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2e7d32;
}

/* ---------------- TOKENS ---------------- */

.token {
    position: absolute;
    width: 60px;
    height: 110px;
    pointer-events: none;
}

.opponent-token {
    position: absolute;
    display: block;
    width: 35px !important;   /* force it */
    height: 60px !important;
    pointer-events: none;
}
/* LOG IN */
#join-game-container {
    background: #333;
    align-items: center;
    justify-content: center;
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    text-align: center;
    width: 320px;
}

#join-game-container h2 {
    margin-bottom: 25px;
    font-size: 24px;
    color: #ffd700; /* gold accent */
}

#join-game-container label {
    display: block;
    text-align: left;
    margin-bottom: 5px;
    font-weight: bold;
}

#join-game-container input {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 6px;
    border: none;
    font-size: 16px;
    box-sizing: border-box;
}

#join-game-container button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background-color: #ffd700;
    color: #222;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}

#join-game-container button:hover {
    background-color: #e6c200;
}
/* WINNER OVERLAY */

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Hidden state */
.hidden {
  display: none;
}

/* Modal */
.winner-modal {
  background: #1e1e1e;
  color: #fff;
  padding: 32px 40px;
  border-radius: 16px;
  min-width: 320px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
  animation: popIn 0.35s ease-out;
}

/* Title */
#winner-title {
  margin-bottom: 20px;
  color: gold;
}

/* Score list */
.score-list {
  margin: 20px 0;
  text-align: left;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.score-row:last-child {
  border-bottom: none;
}

/* Button */
.winner-modal button {
  margin-top: 20px;
  padding: 10px 18px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: gold;
  color: #000;
}

/* Animation */
@keyframes popIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Popup overlay */
#popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

/* Popup content */
.popup-content {
    background: rgb(32, 32, 32);
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    position: relative;
    width: 400px;
}

/* Image */
#popup-image {
    max-width: 100%;
    max-height: 300px;
    display: block;
    margin: 0 auto 10px;
}

/* Navigation buttons */
.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 36px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: white;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 5px;
}

#prev-btn {
    left: -40px;
}

#next-btn {
    right: -40px;
}

/* Select button */
#select-btn {
    margin-top: 10px;
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
}

/* Styled Rules Button - Matches Submit Button Style */
#rules-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    cursor: pointer;
    
    /* Inherited Styles (Scaled Down) */
    width: 100px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: linear-gradient(180deg, #4caf50, #388e3c);
    color: white;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 4px 0 #2e7d32; /* Slightly smaller shadow */
    transition: transform 0.1s;
}

#rules-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 0 #2e7d32;
}

#rules-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #2e7d32;
}

/* Modal Overlay - Full screen centering */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center; /* Horizontal center */
    align-items: center;     /* Vertical center */
    z-index: 2000;
}

/* Modal Container - Tight to the image */
.modal-content {
    position: relative;
    display: inline-block; /* Wraps tightly around the image */
    max-width: 90%;
    max-height: 90%;
}

#rules-img {
    display: block;
    max-width: 80vw;  /* Adjust this to make image larger/smaller on screen */
    max-height: 80vh;
    /* border: 4px solid white; */
    /* border-radius: 12px; */
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* The 'X' Close Button */
.close-x {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #ff4444;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    text-align: center;
    line-height: 32px; /* Centers the X vertically */
    cursor: pointer;
    font-weight: bold;
    font-size: 24px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 2001;
}