/* Existing styles */
body {
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #ffffff;
    font-family: 'Arial', sans-serif;
    overflow: hidden;
}

/* Title screen styles */
.title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.game-title {
    font-size: 48px;
    margin-bottom: 40px;
    color: #ffffff;
    text-align: center;
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

.title-buttons {
    display: flex;
    gap: 20px;
}

.title-button {
    padding: 15px 40px;
    font-size: 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.title-button:hover {
    transform: scale(1.05);
}

.play-button {
    background-color: #4CAF50;
    color: white;
}

.play-button:hover {
    background-color: #45a049;
}

.about-button {
    background-color: #2a2a2a;
    color: white;
    border: 2px solid #4CAF50;
}

.about-button:hover {
    background-color: #3a3a3a;
}

/* Slider styles */
.slider-container {
    margin-top: 15px;
    padding: 10px 0;
}

.slider-label {
    display: block;
    margin-bottom: 5px;
}

.difficulty-slider {
    -webkit-appearance: none;
    width: 200px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, 
        #4CAF50 0%, #4CAF50 33%, 
        #FFA500 33%, #FFA500 66%, 
        #FF4444 66%, #FF4444 100%);
    outline: none;
}

.difficulty-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: 2px solid #333;
}

.difficulty-label {
    font-size: 14px;
    margin-top: 5px;
}

/* Existing modal styles */
.win-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 50px;
    border-radius: 15px;
    z-index: 2000;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

/* Lose modal styles */
.lose-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 50px;
    border-radius: 15px;
    z-index: 2000;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

/* Welcome modal styles */
.welcome-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 15px;
    z-index: 2000;
    text-align: left;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
    max-width: 600px;
    width: 90%;
}

.welcome-modal h2 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #ffffff;
    text-align: center;
}

.welcome-modal p {
    margin: 10px 0;
    line-height: 1.6;
}

.welcome-modal ul {
    margin: 15px 0;
    padding-left: 20px;
}

.welcome-modal li {
    margin: 8px 0;
}

.close-button {
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.close-button:hover {
    color: #cccccc;
}

.get-started-btn {
    display: block;
    width: 200px;
    margin: 25px auto 0;
    padding: 12px 24px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.get-started-btn:hover {
    background-color: #45a049;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.win-modal h2, .lose-modal h2 {
    margin: 0;
    font-size: 24px;
    color: #ffffff;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

#info-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    z-index: 1000;
}

#history-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    z-index: 1000;
    max-height: 80vh;
    overflow-y: auto;
}

#history-panel h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

#history-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#history-list li {
    padding: 5px 0;
    border-bottom: 1px solid #333;
}

#history-list li:last-child {
    border-bottom: none;
}

.word-node {
    position: absolute;
    background-color: #2a2a2a;
    border-radius: 50%;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    min-height: 60px;
    user-select: none;
}

.word-node:hover {
    background-color: #3a3a3a;
    transform: scale(1.1);
}

.current-word {
    background-color: #4a4a4a;
    border: 2px solid #ffffff;
}

#connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.connection {
    stroke: #444;
    stroke-width: 2;
}

.connection.active {
    stroke: #fff;
    stroke-width: 3;
}

.info-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 10px 20px;
    background-color: #2a2a2a;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    z-index: 1000;
    transition: background-color 0.3s;
}

.info-button:hover {
    background-color: #3a3a3a;
}

.manual-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 15px;
    z-index: 2000;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.manual-modal h2 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #ffffff;
}

.manual-modal h3 {
    color: #4CAF50;
    margin: 20px 0 10px 0;
}

.manual-modal p {
    margin: 10px 0;
    line-height: 1.6;
}

.manual-modal ul {
    margin: 10px 0;
    padding-left: 20px;
}

.manual-modal li {
    margin: 5px 0;
}

.word-list {
    columns: 3;
    margin: 10px 0;
}

.word-list li {
    break-inside: avoid;
}

/* Hide the game content initially */
.game-content {
    display: none;
}

/* Mode select screen styles */
.mode-select-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    display: none;
    flex-direction: column;
    z-index: 2500;
}

.menu-nav {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 20px;
    background-color: #2a2a2a;
}

.menu-icon {
    width: 50px;
    height: 50px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    position: relative;
    background-color: #3a3a3a;
    transition: transform 0.2s, background-color 0.2s;
}

.menu-icon:hover {
    background-color: #4a4a4a;
    transform: scale(1.1);
}

.menu-icon svg {
    width: 100%;
    height: 100%;
    fill: #ffffff;
}

.menu-icon:hover .icon-label {
    display: block;
}

.icon-label {
    display: none;
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4a4a4a;
    padding: 5px 10px;
    border-radius: 5px;
    white-space: nowrap;
    font-size: 14px;
}

.menu-content {
    flex: 1;
    padding: 40px;
    display: none;
}

.menu-content.active {
    display: block;
}

.game-modes-grid {
    display: grid;
    grid-gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    max-width: calc(8 * 100px + 6 * 10px); /* Ensures a maximum of 7 columns */
    margin: 0 auto;
}

.game-mode-item {
    aspect-ratio: 1;
    background-color: #2a2a2a;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    padding: 2vmin;
}

.game-mode-item:hover {
    transform: scale(1.05);
    background-color: #3a3a3a;
}

.game-mode-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.game-mode-icon {
    width: 50vmin;
    height: 10vmin;
    margin-bottom: 1vmin;
}

.game-mode-name {
    font-size: 16px;
    text-align: center;
}

.mode-select-footer {
    padding: 20px;
    text-align: center;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.placeholder-content h2 {
    margin-bottom: 20px;
}

.game-mode-icon svg {
    width: 100%;
    height: 100%;
    fill: #ffffff;
}

/* Timer display styling */
#timer-display {
    position: fixed !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    padding: 15px 30px !important;
    border-radius: 10px !important;
    text-align: center !important;
    z-index: 1000 !important;
}

/* Back button styling */
.back-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    background-color: #2a2a2a;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    z-index: 1000;
    transition: background-color 0.3s;
}

.back-button:hover {
    background-color: #3a3a3a;
}

/* How-to-play button and rules modal styles */
.how-to-play-button {
    display: block;
    margin: 20px auto;
    padding: 12px 24px;
    background-color: #2a2a2a;
    color: white;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s, background-color 0.2s;
}

.how-to-play-button:hover {
    transform: scale(1.05);
    background-color: #3a3a3a;
}

.rules-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 15px;
    z-index: 3500;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

.rules-modal h2 {
    color: #4CAF50;
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 24px;
}

.rules-modal .mode-rules {
    margin: 15px 0;
    padding: 15px;
    background-color: #1a1a1a;
    border-radius: 8px;
}

.rules-modal .mode-rules h4 {
    color: #ffffff;
    margin: 0 0 10px 0;
    font-size: 18px;
}

/* Stats styling */
.stats-container {
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.stat-item {
    background-color: #2a2a2a;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.stat-label {
    font-size: 14px;
    color: #888;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    color: #fff;
}

.mode-wins-grid {
    font-size: 16px;
    display: grid;
    gap: 8px;
}

#stat-username {
    color: #4CAF50;
    font-weight: bold;
}

.target-word-display {
    position: fixed;
    bottom: 70px; 
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    z-index: 1000;
}

/* Emotion modal styles */
#emotion-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 15px;
    z-index: 4000;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease-out;
    text-align: center;
}
#emotion-modal h2 {
    color: #4CAF50;
    margin: 0 0 20px 0;
    font-size: 24px;
}
#emotion-modal .emotion-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#emotion-modal .emotion-btn {
    padding: 10px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s;
}
#emotion-modal .emotion-btn:hover:not(:disabled) {
    filter: brightness(90%);
}
#emotion-modal .emotion-btn:disabled {
    background-color: #A9A9A9;
    cursor: not-allowed;
}

/* Emotion display styling */
#emotion-display {
    position: fixed;
    bottom: 120px;  
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    z-index: 1000;
    display: none;
}

/* Event modal styles */
#event-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #2a2a2a;
    padding: 30px 40px;
    border-radius: 15px;
    z-index: 4000;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease-out;
    text-align: center;
}
#event-modal h2 {
    color: #4CAF50;
    margin: 0 0 20px 0;
    font-size: 24px;
}
#event-modal .event-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}
#event-modal .event-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s;
}
#event-modal .event-btn:hover:not(:disabled) {
    filter: brightness(90%);
}
#event-modal .event-btn:disabled {
    background-color: #A9A9A9;
    cursor: not-allowed;
}

/* Event display styling */
#event-display {
    position: fixed;
    bottom: 120px;  
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    z-index: 1000;
    display: none;
}

.starting-letter-display {
    position: fixed;
    bottom: 120px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    z-index: 1000;
    display: none;
}

/* Updated Dictionary Panel Styles */
#dictionary-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px; 
    min-width: 250px;
    max-width: 600px;
    height: 100vh; 
    background: linear-gradient(180deg, #00796b, #004d40); 
    border-left: 2px solid #4CAF50; 
    padding: 20px;
    overflow-y: auto;
    z-index: 1500;
    resize: horizontal; 
}

/* New: Dictionary Toggle Button */
.dictionary-toggle-button {
    position: fixed;
    top: 20px;
    right: 320px; 
    z-index: 1000;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.dictionary-toggle-button:hover {
    background-color: #45a049;
}

/* New: Dictionary Close Button */
.dictionary-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000; 
}

/* Dictionary panel styling */
#dictionary-panel .search-container {
  position: relative;
  margin-bottom: 20px;
}

#dictionary-panel .search-input {
  width: 100%;
  padding: 10px;
  font-size: 16px;
  border: 1px solid #4a5568;
  border-radius: 8px;
  background: #2c3e50;
  color: #ffffff;
}

#dictionary-panel .search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: #60a5fa;
  border: none;
  color: white;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
}

#dictionary-panel .search-btn:hover {
  background: #4287f5;
}

#dictionary-panel .dictionary-result {
  color: #e2e8f0;
}