body {
  font-family: sans-serif;
  text-align: center;
  background: #f9f9f9;
  margin: 0;
  /* padding: 20px; */
}

/* Remove horizontal scroll */
html,
body {
  overflow-x: hidden;
}

#page-container {
  margin-top: 60px;
  position: relative;
  padding-bottom: 60px;
  min-height: 100vh;
}

#install-button {
  visibility: hidden;
  position: fixed;
  color: #FF8340;
  cursor: pointer;
  top: 14px;
  right: 80px;
  z-index: 99999999;
  width: 120px;
}

/* button sizes */

button i {
  display: block;
  font-size: 1.2rem;
}

button small {
  display: block;
  font-size: 0.75rem;
  line-height: 1;
}


/* Base styles for the chessboard container */
/* These styles apply to all screen sizes by default (often optimized for larger screens) */
#board {
  /* Set a max-width for desktop/tablet to prevent it from getting too large */
  width: 450px;
  height: 450px;
  max-width: 600px;
  /* Adjust this to your preferred maximum board size on desktops */
  margin: 20px auto;
  /* Center the board horizontally on larger screens */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  /* Optional: add some shadow for visual appeal */
  border-radius: 8px;
  /* Optional: subtle rounded corners */
  overflow: hidden;
  /* Ensures board content stays within bounds */
  /* Add any other default styling for your board wrapper */
}

/* Optional: If you want some padding around the board on larger screens */
/* body {
    padding: 0 20px;
} */

.toast-container {
  z-index: 99999999;
  top: 40px;
}

#controls {
  /* border-top: 1px solid #ddd; */
  /* padding-top: 10px; */
  margin-top: 15px;
}

/* Ensure buttons don't shrink */
#controls .btn {
  flex-shrink: 0;
}

/* Ensure consistent button heights */
#controls .btn {
  /* min-height: 38px; */
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ****************** gameInfoModal ****************** */

/* Enhance modal layout */
#gameInfoModal .modal-content {
  font-family: 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* Section Headings */
.section-heading {
  text-transform: uppercase;
  font-size: 0.875rem;
  color: #6c757d;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* Styled info boxes */
.info-box {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Move list formatting */
.move-box {
  gap: 0.5rem;
  min-height: 60px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  max-height: 30vh;
  overflow-y: auto;
}

/* Button spacing */
#copy-fen-btn i {
  vertical-align: middle;
}

/* Modal backdrop fix */
#gameInfoModal {
  /* margin-top: 80px; */
  /* text-align: start; */
  z-index: 99999999;
}

/* ****************** gameInfoModal ****************** */
#puzzleModal {
  /* margin-top: 80px; */
  /* text-align: start;*/
  z-index: 99999999;
}

.hintBox,
.feedbackBox {
  margin-top: 10px;
  font-weight: bold;
}


#gameHistoryModal {
  text-align: start;
  z-index: 99999999;
}

#puzzleStatsModal {
  text-align: start;
  z-index: 99999999;
}

#puzzleStatsModal {
  text-align: start;
  z-index: 99999999;
}

#puzzleList {
  text-align: start;
  overflow-y: auto;
  max-height: 30vw;
}


/* Game history item styling */
#savedGamesList .list-group-item {
  transition: all 0.2s ease;
}

#savedGamesList .list-group-item:hover {
  background-color: #f8f9fa;
}

.game-name {
  font-weight: 500;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#editGameModal {
  text-align: start;
  z-index: 999999999;
}

/* Edit modal styling */
#editGameModal .form-control {
  padding: 0.5rem 0.75rem;
}

/* Small screen adjustments */
@media (max-width: 576px) {
  #savedGamesList .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }

  .game-name {
    max-width: 120px;
  }
}

/* Game history item styling: End */


#appInfoModal {
  text-align: start;
  z-index: 99999999;
}

/* Add to your stylesheet */
#appInfoModal .modal-header {
  background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
}

#appInfoModal .accordion-button:not(.collapsed) {
  background-color: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
}

#appInfoModal .list-group-item {
  transition: all 0.3s ease;
}

#appInfoModal .list-group-item:hover {
  background-color: #f8f9fa;
}

.promotion-dialog {
  position: absolute;
  z-index: 9999999;
  background: white;
  border: 2px solid #444;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%);
  max-width: 80px;
}

.promotion-choices {
  padding: 10px;
}

.promotion-title {
  font-weight: bold;
  margin-bottom: 8px;
  font-size: small;
}

.promotion-options button {
  aspect-ratio: 1/1;
  /* Square buttons */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  width: 50px;
  height: 50px;
  background-repeat: no-repeat;
}


.promotion-options button:hover {
  /* background: #e9ecef; */
}

.white-queen {
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NSIgaGVpZ2h0PSI0NSI+PGcgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik04IDEyYTIgMiAwIDEgMS00IDAgMiAyIDAgMSAxIDQgMHptMTYuNS00LjVhMiAyIDAgMSAxLTQgMCAyIDIgMCAxIDEgNCAwek00MSAxMmEyIDIgMCAxIDEtNCAwIDIgMiAwIDEgMSA0IDB6TTE2IDguNWEyIDIgMCAxIDEtNCAwIDIgMiAwIDEgMSA0IDB6TTMzIDlhMiAyIDAgMSAxLTQgMCAyIDIgMCAxIDEgNCAweiIvPjxwYXRoIGQ9Ik05IDI2YzguNS0xLjUgMjEtMS41IDI3IDBsMi0xMi03IDExVjExbC01LjUgMTMuNS0zLTE1LTMgMTUtNS41LTE0VjI1TDcgMTRsMiAxMnoiIHN0cm9rZS1saW5lY2FwPSJidXR0Ii8+PHBhdGggZD0iTTkgMjZjMCAyIDEuNSAyIDIuNSA0IDEgMS41IDEgMSAuNSAzLjUtMS41IDEtMS41IDIuNS0xLjUgMi41LTEuNSAxLjUuNSAyLjUuNSAyLjUgNi41IDEgMTYuNSAxIDIzIDAgMCAwIDEuNS0xIDAtMi41IDAgMCAuNS0xLjUtMS0yLjUtLjUtMi41LS41LTIgLjUtMy41IDEtMiAyLjUtMiAyLjUtNC04LjUtMS41LTE4LjUtMS41LTI3IDB6IiBzdHJva2UtbGluZWNhcD0iYnV0dCIvPjxwYXRoIGQ9Ik0xMS41IDMwYzMuNS0xIDE4LjUtMSAyMiAwTTEyIDMzLjVjNi0xIDE1LTEgMjEgMCIgZmlsbD0ibm9uZSIvPjwvZz48L3N2Zz4=');
}

.white-rook {
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0NSIgaGVpZ2h0PSI0NSI+PGcgZmlsbD0iI2ZmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik05IDM5aDI3di0zSDl2M3ptMy0zdi00aDIxdjRIMTJ6bS0xLTIyVjloNHYyaDVWOWg1djJoNVY5aDR2NSIgc3Ryb2tlLWxpbmVjYXA9ImJ1dHQiLz48cGF0aCBkPSJNMzQgMTRsLTMgM0gxNGwtMy0zIi8+PHBhdGggZD0iTTMxIDE3djEyLjVIMTRWMTciIHN0cm9rZS1saW5lY2FwPSJidXR0IiBzdHJva2UtbGluZWpvaW49Im1pdGVyIi8+PHBhdGggZD0iTTMxIDI5LjVsMS41IDIuNWgtMjBsMS41LTIuNSIvPjxwYXRoIGQ9Ik0xMSAxNGgyMyIgZmlsbD0ibm9uZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIvPjwvZz48L3N2Zz4=');
}

.white-bishop {
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cD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PSJldmVub2RkIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjxwYXRoIGQ9Ik0yMiAxMGMxMC41IDEgMTYuNSA4IDE2IDI5SDE1YzAtOSAxMC02LjUgOC0yMSIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0yNCAxOGMuMzggMi45MS01LjU1IDcuMzctOCA5LTMgMi0yLjgyIDQuMzQtNSA0LTEuMDQyLS45NCAxLjQxLTMuMDQgMC0zLTEgMCAuMTkgMS4yMy0xIDItMSAwLTQuMDAzIDEtNC00IDAtMiA2LTEyIDYtMTJzMS44OS0xLjkgMi0zLjVjLS43My0uOTk0LS41LTItLjUtMyAxLTEgMyAyLjUgMyAyLjVoMnMuNzgtMS45OTIgMi41LTNjMSAwIDEgMyAxIDMiIGZpbGw9IiNmZmYiLz48cGF0aCBkPSJNOS41IDI1LjVhLjUuNSAwIDEgMS0xIDAgLjUuNSAwIDEgMSAxIDB6bTUuNDMzLTkuNzVhLjUgMS41IDMwIDEgMS0uODY2LS41LjUgMS41IDMwIDEgMSAuODY2LjV6IiBmaWxsPSIjMDAwIi8+PC9nPjwvc3ZnPg==');
}


#fen-display {
  overflow-wrap: break-word;
}

.piece.dragging {
  z-index: 10;
  filter: drop-shadow(0 0 8px rgba(255, 255, 0, 0.7));
}

button {
  margin: 5px;
  padding: 6px 12px;
  font-size: 14px;
}

#eval-container {
  /* margin: 10px auto; */
  /* width: 100%; */
  text-align: center;
}

#eval-bar {
  height: 20px;
  background: #ccc;
  position: relative;
  width: 100%;
  margin-bottom: 4px;
}

#eval-fill {
  height: 100%;
  background: linear-gradient(to right, #000 0%, #fff 100%);
  width: 50%;
}

.cg-board square.pink {
  background-color: rgba(255, 192, 203, 0.5);
}

.cg-board square.blue {
  background-color: rgba(0, 0, 255, 0.3);
}

#status,
#warning {
  /* padding: 10px;
  margin: 10px 0; */
  border-radius: 5px;
  /* font-weight: bold; */
}

#status.blunder,
#warning.blunder {
  background-color: #ffcccc;
  /* color: #cc0000; */
  color: #000000;
}

#status.mistake,
#warning.mistake {
  background-color: #ffe6cc;
  /* color: #e67300; */
  color: #000000;
}

#status.inaccuracy,
#warning.inaccuracy {
  background-color: #ffffcc;
  /* color: #999900; */
  color: #000000;
}

/* In your style.css */
#eval-score {
  font-weight: bold;
  padding: 2px;
  border-radius: 3px;
  flex-direction: row;
  flex-wrap: wrap;
  display: inline-flex
}

#eval-score.positive {
  background-color: rgba(255, 255, 200, 0.7);
  color: #333;
}

#eval-score.negative {
  background-color: rgba(200, 200, 255, 0.7);
  color: #333;
}

#eval-score.mate {
  background-color: rgba(255, 150, 150, 0.7);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }

  100% {
    opacity: 1;
  }
}

#color-selection {
  margin: 10px 0;
}

#color-selection button {
  padding: 5px 10px;
  margin: 0 5px;
  cursor: pointer;
}

#color-selection button.active {
  background-color: #4CAF50;
  color: white;
  font-weight: bold;
}

/* Styling for the overall LLM coach container */
#llm-coach-container {
  display: flex;
  align-items: flex-start;
  margin: 20px auto;
  max-width: 700px;
  width: 90%;
  position: relative;
  /* Now the container needs to be relative for its own ::before */
  overflow: visible;
  /* Crucial to ensure the tail is not clipped */
  text-align: left;
}

/* ... coach-avatar and llm-response-area styles as before ... */

/* Chat bubble tail/callout on #llm-coach-container (Desktop/Tablet) */
#llm-coach-container::before {
  content: '';
  position: absolute;
  /* Positioned relative to #llm-coach-container */

  /* Calculate position to align with the chat bubble's top-left corner */
  /* Avatar width (50px) + margin-right (15px) = 65px. */
  /* So the chat bubble starts at 65px from the left of the container. */
  /* We want the triangle to protrude from there, pointing left. */
  left: 55px;
  /* Adjust this to fine-tune its horizontal position. (e.g., 65px - 10px triangle base) */
  top: 15px;
  /* Adjust this to align vertically with the bubble's top-left corner.
                  (20px margin-top + some offset for bubble's padding/border) */

  width: 0;
  height: 0;
  border-style: solid;
  /* Create a triangle pointing LEFT.
       border-width: [top] [right] [bottom] [left]
       The LEFT border color makes it visible. */
  border-width: 20px 25px 20px 0;
  /* Base 20px (10+10), Height 15px */
  border-color: transparent #e0f2f7 transparent transparent;
  /* Tail color matches bubble background */
  z-index: 1;
  /* Ensure it's above the background, but potentially below the bubble if bubble has higher z-index */
  text-align: start;
}

#coach-avatar {
  width: 50px;
  height: 50px;
  min-width: 50px;
  min-height: 50px;
  margin-right: 15px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Styling for the LLM response chat bubble */
#llm-response-area {
  background-color: #e0f2f7;
  /* A light, calming blue, similar to some chat apps */
  padding: 15px 20px;
  border-radius: 18px;
  position: relative;
  /* Essential for positioning the ::before pseudo-element */
  flex-grow: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;

  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;

  color: #333;
  /* line-height: 1.6; */
  z-index: 1;
  /* Ensure the bubble is above other normal flow content */

}

/* Styling for the text content within the scrollable area */
#llm-response-text {
  margin: 0;
  /* font-size: 0.90em; */
  /* white-space: pre-wrap; */
  white-space: normal;
  word-wrap: break-word;
  text-align: start;
}

/* ----------------------------------------------------------- */
/* Media Queries for Smaller Screens */
/* ----------------------------------------------------------- */

/* For Tablets (Portrait) and larger phones (e.g., iPads, larger Android phones) */
@media (max-width: 768px) {
  #board {
    width: 440px;
    height: 440px;
    /* Slightly reduce max-width or make it more fluid */
    max-width: 90%;
    /* Take up 90% of the viewport width */
    margin: 15px auto;
  }
}

/* For Phones (Landscape and Portrait) */
/* This is where we want the full screen width for the board */
@media (max-width: 576px) {
  #notifications {
    /* font-size: 11px; */
    font-size: small;
  }

  /* Adjust this breakpoint if your target phones are smaller/larger */
  #board {
    width: 100vw;
    height: 100vw;
    /* Take full width of the screen */
    max-width: 100%;
    /* Ensure it doesn't exceed 100% */
    margin: 0;
    /* Remove horizontal margin to use full width */
    /* You might want to adjust vertical margin/padding for spacing on phones */
    padding: 0;
    /* Remove any padding that might push the board inward */
    border-radius: 0;
    /* Remove rounded corners for full edge-to-edge look */
  }

  /* Optional: Adjust body padding for phones */
  body {
    padding: 0;
  }

  #llm-coach-container {
    flex-direction: row;
    /* Stack avatar and bubble vertically */
    align-items: center;
    /* Center horizontally when stacked */
    margin: 10px auto;
    width: 97%;
    font-size: small;
  }

  #coach-avatar {
    margin-right: 0;
    margin-bottom: 10px;
    /* Add vertical margin below avatar */
  }

  #llm-response-area {
    width: calc(100% - 10px);
    /* Full width minus padding to avoid overflow */
    max-width: 100%;
    border-radius: 12px;
    padding: 12px 15px;
    height: 90px;
    font-size: small;
  }

  /* Adjust the tail position for a stacked layout (pointing upwards from the bubble) */
  #llm-coach-container::before {
    /* Position above the bubble, which is centered below the avatar */
    top: 50px;
    /* Adjust this based on avatar height (50px + 10px margin-bottom) + its own offset */
    left: 50%;
    /* Center horizontally with the bubble */
    transform: translateX(-50%);
    /* Adjust for true centering */

    /* Create a triangle pointing UP.
           The BOTTOM border color makes it visible. */
    border-width: 0 10px 15px 10px;
    /* Base 20px (10+10), Height 15px */
    border-color: transparent transparent #e0f2f7 transparent;
    /* Tail color matches bubble background */
  }
}

/* Mobile button styling */
@media (max-width: 767.98px) {
  #controls .btn {
    padding: 0.25rem;
    /* min-height: 40px; */
    /* max-height: 32px;
    max-width: 32px; */
  }

  #controls small {
    font-size: 0.75rem;
    /* font-size: 0.65rem; */
    line-height: 1.2;
  }

  #controls .btn-group {
    margin-bottom: 0.5rem;
  }
}

/* Responsive tweaks */
@media (max-width: 768px) {
  #appInfoModal .modal-dialog {
    margin: 0.5rem auto;
  }
}

/* Mobile-specific tweaks */
/* @media (max-width: 767.98px) {
  #controls .btn-group {
    border-radius: 0.25rem !important;
  }
  
  #controls .btn-group .btn {
    flex: 1;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }
} */

/* You might even target very small phones if needed */
/* @media (max-width: 420px) {
    #board {
        // Specific adjustments for very small screens if necessary
    }
} */