/* Enhanced Modern Hangman Game Styles - Optimized for Reduced Scrolling */

/* Global Styles with improved typography */
body {
  font-family: 'Poppins', sans-serif;
  background-color: #f0f5f9;
  color: #333;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

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

/* Compact Header Styles dengan struktur hirarki baru */
.hanghead-fixed {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100%;
  margin: 0.5em auto 0.8em auto; /* Reduced margins */
  background: linear-gradient(135deg, #3c8dbc 0%, #2a6496 100%);
  padding: 0.8em 1em 1.2em 1em; /* Reduced padding */
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
  min-height: auto; /* Removed fixed height constraint */
}

/* Button container for proper positioning */
.button-container {
  position: absolute;
  top: 10px;
  right: 10px;
  height: auto;
  width: auto;
  overflow: visible;
  margin: 0;
  z-index: 100; /* Higher than user auth to ensure it's visible */
}

.btn.pull-right, .leaderboard-btn {
  float: right;
  margin-left: 10px;
}

.game-title {
  color: white;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  font-weight: 700;
  font-size: 1.8rem; /* Reduced font size */
  margin-bottom: 0.5em; /* Reduced spacing */
  text-align: center;
}

.hanghead-fixed p {
  color: rgba(255,255,255,0.9);
  font-size: 1rem; /* Reduced font size */
  margin-bottom: 0.8em; /* Reduced spacing */
  text-align: center;
}

/* Fixed position for the how-to-play button */
.btn.pull-right {
  float: right;
  background-color: rgba(255,255,255,0.9);
  color: #3c8dbc;
  border: 1px solid transparent;
  transition: all 0.3s ease;
  font-weight: 600;
  border-radius: 5px;
  padding: 0.3em 0.7em;
  font-size: 0.8em;
  z-index: 10;
}

.btn.pull-right:hover {
  background-color: transparent;
  color: white;
  border-color: white;
}

/* Timer dan Tombol Mulai di baris yang sama */
.timer-btn-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0.5em 0;
}

/* Difficulty Selector Styles with improved UI */
.difficulty-selector {
  margin: 0.5em auto; /* Reduced margin */
  text-align: center;
  background-color: rgba(255,255,255,0.15);
  padding: 0.5em; /* Reduced padding */
  border-radius: 5px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255,255,255,0.2);
}

.difficulty-selector.compact {
  display: inline-block;
  margin: 0.3em;
  padding: 0.3em 0.5em;
}

.difficulty-selector label {
  color: white;
  font-weight: 600;
  margin-right: 0.5em;
  display: inline-block;
  font-size: 0.9rem;
}

.difficulty-selector select {
  display: inline-block;
  width: auto;
  background-color: white;
  color: #3c8dbc;
  border: none;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0.3em 0.6em;
  font-size: 0.85em;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.difficulty-selector select:focus {
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
  outline: none;
}

/* Game timer moved to top with compact styling */
#game-timer-container {
  margin: 0 !important; /* Removed margin for better alignment */
  padding: 0.3em 0.8em !important; /* Reduced padding */
  background: linear-gradient(145deg, #f8f9fa, #e9ecef);
  border-radius: 8px !important;
  border: 1px solid #3c8dbc !important;
  display: inline-block;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
  transition: all 0.3s ease;
}

.compact-timer {
  font-size: 0.9em;
}

.timer-label {
  font-size: 1em !important;
  font-weight: 700 !important;
  color: #3c8dbc !important;
}

#game-timer {
  font-family: 'Courier New', monospace !important;
  font-size: 1.1em !important;
  font-weight: 700;
  color: #dc3545 !important;
}

/* Improved difficulty indicators */
.difficulty-indicator {
  display: inline-block;
  margin-left: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
}

.difficulty-easy {
  background-color: #28a745;
}

.difficulty-medium {
  background-color: #ffc107;
}

.difficulty-hard {
  background-color: #dc3545;
}

.difficulty-expert {
  background-color: #6f42c1;
}

/* Start game button with compact styling */
.start-game-btn {
  background: linear-gradient(145deg, #3c8dbc, #2a6496);
  color: white;
  border: none;
  padding: 0.5em 1.2em; /* Reduced padding */
  font-size: 1em; /* Reduced font size */
  border-radius: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(60, 141, 188, 0.4);
  font-weight: 600;
  margin: 0 !important; /* Removed margin for centered alignment */
  display: inline-block;
}

.compact-btn {
  padding: 0.4em 1em;
  font-size: 0.9em;
}

.start-game-btn:hover {
  background: linear-gradient(145deg, #2a6496, #1e496e);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(60, 141, 188, 0.5);
}

/* Game container with improved layout */
.game-container {
  background-color: white;
  border-radius: 15px;
  padding: 1em; /* Reduced padding */
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 1em; /* Reduced margin */
  margin-top: 0.5em; /* Reduced space between header and game container */
}

/* Vertically align alpha keypad, hangman, and graveyard */
#alphabet-keypad, #hangman-graphic, #letter-graveyard {
  display: inline-block;
  vertical-align: top;
  background-color: white;
  border-radius: 10px;
  padding: 15px; /* Reduced padding */
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 15px; /* Reduced margin */
  min-height: 320px; /* Reduced minimum height */
  position: relative;
}

.row {
  width: 100%;
  margin: 0 auto;
}

/* Styles untuk Keyboard Alfabet */
#alphabet-keypad {
  text-align: center;
}

#alphabet-keypad h3, #hangman-graphic h3, #letter-graveyard h3 {
  color: #3c8dbc;
  font-weight: 700;
  margin-bottom: 15px; /* Reduced margin */
  position: relative;
  display: inline-block;
  padding-bottom: 3px;
  border-bottom: 2px solid #3c8dbc;
  font-size: 1.2em; /* Reduced font size */
}

/* Container untuk menyusun alfabet */
.alphabet-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  gap: 8px; /* Reduced gap */
}

/* Baris alfabet */
.alphabet-row {
  display: flex;
  justify-content: center;
  gap: 5px; /* Reduced gap */
}

/* Tombol huruf */
.letter-button, .letter-disabled {
  width: 40px; /* Reduced size */
  height: 40px; /* Reduced size */
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Poppins', sans-serif;
  font-weight: bold;
  font-size: 1.2em; /* Reduced font size */
  cursor: pointer;
  transition: all 0.3s ease;
}

.letter-button {
  border: 2px solid #8ecae6;
  color: #3c8dbc;
  background-color: white;
}

.letter-button:hover {
  background-color: #8ecae6;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(60, 141, 188, 0.3);
}

.letter-disabled {
  border: 2px solid #ddd;
  color: #ddd;
  cursor: default;
  background-color: #f9f9f9;
}

/* Enhanced hangman graphic */
#hangman-graphic {
  text-align: center;
}

.hangman-image-container {
  position: relative;
  margin: 0 auto;
  max-width: 90%;
  padding: 0.8em; /* Reduced padding */
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px dashed rgba(60, 141, 188, 0.3);
  min-height: 150px; /* Reduced height */
  display: flex;
  justify-content: center;
  align-items: center;
}

#hangman-graphic img {
  margin: 0 auto;
  max-width: 85%;
  max-height: 150px; /* Reduced height */
  display: block;
}

.hangman-frames {
  opacity: 0;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.4s ease;
}

#hangman-frame0 {
  opacity: 1;
}

.hangman-controls {
  margin-top: 15px; /* Reduced margin */
  text-align: center;
}

.btn.reset {
  background: linear-gradient(145deg, #2ecc71, #27ae60);
  color: white;
  border: none;
  padding: 0.5em 1.2em; /* Reduced padding */
  font-size: 0.9em; /* Reduced font size */
  border-radius: 20px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(40, 167, 69, 0.4);
  font-weight: 600;
}

.btn.reset:hover {
  background: linear-gradient(145deg, #27ae60, #219653);
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(40, 167, 69, 0.5);
}

/* Enhanced letter graveyard */
#letter-graveyard {
  text-align: center;
}

.graveyard-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  min-height: 150px; /* Reduced height */
}

/* Enhanced styles for the graveyard letters */
.grave-letter {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px; /* Reduced size */
  height: 30px; /* Reduced size */
  font-size: 1.1em; /* Reduced font size */
  font-weight: bold;
  color: #dc3545;
  border: 2px solid #dc3545;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(220, 53, 69, 0.2);
  transition: all 0.3s ease;
}

.grave-letter:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 3px 6px rgba(220, 53, 69, 0.3);
}

/* Enhanced word to guess section */
#word-to-guess {
  margin: 0.8em auto; /* Reduced margin */
  text-align: center;
  padding: 0.5em; /* Reduced padding */
  display: flex;
  justify-content: center;
  gap: 5px; /* Reduced gap */
}

/* Enhanced styles for the letter blocks */
.character-block {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 35px; /* Reduced size */
  height: 35px; /* Reduced size */
  background-color: #f8f9fa;
  position: relative;
}

.character-block span {
  font-size: 1.8em; /* Reduced font size */
  font-weight: bold;
  color: #28a745;
  text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.is-letter {
  border-bottom: 2px solid #3c8dbc;
}

/* Word hints section - Enhanced & Centered */
#word-hint {
  margin: 0.7em auto; /* Reduced margin */
  text-align: center;
  padding: 0.6em; /* Reduced padding */
  background-color: #f8f9fa;
  border: 1px dashed #3c8dbc;
  border-radius: 8px;
  width: 70%; /* Smaller width */
  max-width: 400px; /* Limit maximum width */
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  position: relative;
}

.compact-hint {
  padding: 0.4em;
  margin: 0.4em auto;
}

#word-hint:hover {
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.hint-text-container {
  margin-top: 6px; /* Reduced margin */
  clear: both;
  font-size: 0.9em; /* Reduced font size */
}

#hint-button {
  background: linear-gradient(145deg, #ffc107, #e0a800);
  color: #333;
  border: none;
  padding: 0.3em 0.7em; /* Reduced padding */
  border-radius: 15px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 5px rgba(255, 193, 7, 0.3);
  font-size: 0.85em; /* Reduced font size */
  display: inline-block;
}

#hint-button:hover {
  background: linear-gradient(145deg, #e0a800, #d39e00);
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(255, 193, 7, 0.4);
}

#hint-text {
  margin-top: 0.8em; /* Reduced margin */
  color: #495057;
  font-style: italic;
  display: none;
  padding: 0.8em; /* Reduced padding */
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
  font-size: 0.9em; /* Reduced font size */
}

/* Game statistics section with improved text alignment */
.game-stats {
  margin: 1em auto; /* Reduced margin */
  padding: 1em; /* Reduced padding */
  background-color: white;
  border-radius: 15px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  text-align: center;
  transition: all 0.3s ease;
}

.game-stats:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}

.game-stats p {
  color: #495057;
  font-size: 0.9em; /* Reduced font size */
  margin-bottom: 0.8em; /* Reduced margin */
  line-height: 1.6;
  text-align: center;
  max-width: 95%;
  margin-left: auto;
  margin-right: auto;
}

/* Footer with improved styling */
footer {
  margin-top: 1.5em; /* Reduced margin */
  padding: 0.8em; /* Reduced padding */
  color: #6c757d;
  font-size: 0.8em; /* Reduced font size */
  text-align: center;
  border-top: 1px solid #e9ecef;
}

/* Enhanced modal styling */
.modal-content {
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  border: none;
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(135deg, #3c8dbc 0%, #2a6496 100%);
  color: white;
  border-radius: 15px 15px 0 0;
  padding: 1em; /* Reduced padding */
  border-bottom: none;
}

.modal-body {
  padding: 1.5em; /* Reduced padding */
}

.modal-title {
  font-weight: 700;
  font-size: 1.4em; /* Reduced font size */
}

.modal-footer {
  border-top: 1px solid #eee;
  padding: 1em; /* Reduced padding */
}

/* Enhanced how to play modal */
.difficulty-guide-modal {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 1em; /* Reduced padding */
  margin-top: 1em; /* Reduced margin */
  border: 1px solid #e9ecef;
}

.difficulty-guide-modal h5 {
  font-weight: 700;
  color: #3c8dbc;
  margin-bottom: 0.8em; /* Reduced margin */
  font-size: 1.1em; /* Reduced font size */
}

.difficulty-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8em; /* Reduced margin */
  font-size: 0.9em; /* Reduced font size */
}

.difficulty-table th, 
.difficulty-table td {
  padding: 0.6em; /* Reduced padding */
  border: 1px solid #dee2e6;
  text-align: center;
}

.difficulty-table th {
  background-color: #e9ecef;
  font-weight: 600;
}

/* Game inactive state */
.game-inactive .letter-button {
  opacity: 0.6;
  pointer-events: none;
}

.game-inactive #word-to-guess {
  opacity: 0.6;
}

/* Game active state */
.game-active .letter-button {
  opacity: 1;
  pointer-events: auto;
}

.game-active #word-to-guess {
  opacity: 1;
}

/* Score display in modals */
.score-display {
  margin: 1em 0; /* Reduced margin */
  padding: 1em; /* Reduced padding */
  background: linear-gradient(145deg, #f8f9fa, #e9ecef);
  border-radius: 10px;
  text-align: center;
  border: 1px dashed #3c8dbc;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: all 0.3s ease;
}

.score-display:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.score-value {
  font-size: 2.2em; /* Reduced font size */
  font-weight: 700;
  color: #28a745;
  margin-bottom: 0.2em; /* Reduced margin */
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Animations */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.highlight-effect {
  animation: pulse 0.3s ease;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

.shake-effect {
  animation: shake 0.5s ease;
}

@keyframes celebrate {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.winner-effect {
  animation: celebrate 1s ease infinite;
}

/* Responsive design improvements */
@media (max-width: 992px) {
  .hanghead-fixed {
    padding: 1em 1em 1.2em 1em; /* Further reduced padding for medium screens */
    min-height: auto;
  }
  
  .game-title {
    font-size: 1.6rem;
  }
  
  #alphabet-keypad, #hangman-graphic, #letter-graveyard {
    width: 100%;
    max-width: 100%;
    margin: 0 0 15px 0;
    min-height: auto;
    padding: 10px;
  }
  
  .game-container {
    padding: 0.8em;
  }
  
  #word-hint {
    width: 80%;
  }
  
  .start-game-btn {
    font-size: 1em;
    padding: 0.5em 1.5em;
  }
  
  .character-block {
    width: 30px;
    height: 30px;
  }
  
  .character-block span {
    font-size: 1.6em;
  }
}

@media (max-width: 768px) {
  .hanghead-fixed {
    padding: 0.8em 0.8em 1em 0.8em; /* Further reduced padding for small screens */
  }
  
  .game-title {
    font-size: 1.4rem;
    margin-bottom: 0.3em;
  }
  
  .timer-btn-container {
    flex-direction: column;
    gap: 10px;
  }
  
  .btn.pull-right {
    padding: 0.3em 0.5em;
    font-size: 0.8em;
  }
  
  .difficulty-selector {
    max-width: 100%;
  }
  
  .letter-button, .letter-disabled {
    width: 35px;
    height: 35px;
    font-size: 1em;
  }
  
  .alphabet-row {
    gap: 4px;
  }
  
  .character-block {
    width: 25px;
    height: 25px;
  }
  
  .character-block span {
    font-size: 1.4em;
  }
  
  .score-value {
    font-size: 1.8em;
  }
  
  .start-game-btn {
    font-size: 0.9em;
    padding: 0.4em 1.2em;
  }
  
  #hangman-graphic img {
    max-height: 130px;
  }
  
  .hangman-image-container {
    min-height: 130px;
  }
}

@media (max-width: 576px) {
  .hanghead-fixed {
    padding: 0.6em 0.6em 0.8em 0.6em; /* Further reduced padding for very small screens */
  }
  
  .game-title {
    font-size: 1.2rem;
  }
  
  .letter-button, .letter-disabled {
    width: 30px;
    height: 30px;
    font-size: 0.9em;
  }
  
  .alphabet-row {
    gap: 3px;
  }
  
  .character-block {
    width: 22px;
    height: 22px;
  }
  
  .character-block span {
    font-size: 1.2em;
  }
  
  #word-hint {
    width: 90%;
    padding: 0.6em;
  }
  
  .hangman-image-container {
    min-height: 120px;
  }
  
  #hangman-graphic img {
    max-height: 120px;
  }
  
  .start-game-btn {
    font-size: 0.8em;
    padding: 0.4em 1em;
  }
  
  #alphabet-keypad h3, #hangman-graphic h3, #letter-graveyard h3 {
    font-size: 1em;
    margin-bottom: 10px;
  }
  
  .btn.reset {
    padding: 0.3em 0.8em;
    font-size: 0.8em;
  }
}

/* Direct styling for the navigation elements - moved to the left */
a[href="login.html"],
a[href="register.html"],
.btn-login,
.btn-register {
  display: inline-block !important;
  padding: 5px 12px !important;
  margin: 5px !important;
  border-radius: 5px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  transition: all 0.3s !important;
  position: relative !important;
  z-index: 1000 !important;
}

/* Leaderboard and Cara Bermain stay at right */
a[href="leaderboard.html"],
.leaderboard-link,
button[data-target="#info"],
button[data-toggle="modal"] {
  position: relative !important;
  z-index: 1000 !important;
  margin-left: 10px !important;
  display: inline-block !important;
  padding: 5px 12px !important;
  border-radius: 5px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  transition: all 0.3s !important;
}

/* Login button */
a[href="login.html"],
.btn-login {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #3c8dbc !important;
  border: 1px solid transparent !important;
}

a[href="login.html"]:hover,
.btn-login:hover {
  background: rgba(255, 255, 255, 0.7) !important;
}

/* Register button */
a[href="register.html"],
.btn-register {
  background: rgba(40, 167, 69, 0.9) !important;
  color: white !important;
  border: 1px solid transparent !important;
}

a[href="register.html"]:hover,
.btn-register:hover {
  background: rgba(40, 167, 69, 0.7) !important;
}

/* Leaderboard button */
a[href="leaderboard.html"],
.leaderboard-link {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #3c8dbc !important;
  border: 1px solid transparent !important;
}

a[href="leaderboard.html"]:hover,
.leaderboard-link:hover {
  background: rgba(255, 255, 255, 0.7) !important;
}

/* Position auth container at the top LEFT */
.user-auth-container {
  position: absolute !important;
  top: 10px !important;
  left: 10px !important; /* Changed from right to left */
  display: flex !important;
  align-items: center !important;
  z-index: 1000 !important;
}

/* Keep the right-side buttons on the right */
.button-container {
  position: absolute !important;
  top: 10px !important;
  right: 10px !important;
  display: flex !important;
  align-items: center !important;
  z-index: 1000 !important;
}

/* Fix layout on mobile */
@media (max-width: 768px) {
  .hanghead-fixed {
    padding-top: 60px !important;
  }
  
  .button-container,
  .user-auth-container {
    flex-wrap: wrap !important;
    justify-content: center !important;
    width: auto !important;
  }
  
  .user-auth-container {
    left: 10px !important;
  }
  
  .button-container {
    right: 10px !important;
  }
}

@media (max-width: 480px) {
  .user-greeting {
    font-size: 12px;
  }
  
  .btn-logout, .btn-auth {
    font-size: 12px;
    padding: 4px 8px;
  }
  
  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
}