@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@500&display=swap');

:root {
  --color-background: #DADACA;
  --color-text: #000000;
  --color-logo: #FBB530;
  --color-banner: #148051;
  --color-incorrect: #B92129;
  --color-semicorrect: #FBB530;
  --color-correct: #148051;
  --color-key-bg: #f6f6f6;
  --color-key-text: #333;
  --color-key-border: #555;
  --font-primary: 'Open Sans', sans-serif;
  --font-logo: 'Dancing Script', cursive;
  --border-radius: 5px;
}

/* Dark mode variables */
body.dark-mode {
  --color-background: #181A1B;
  --color-text: white;
  --color-key-bg: #333;
  --color-key-text: #f6f6f6;
  --color-key-border: #555;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-primary);
  height: 100%;
  overflow-y: hidden;
}

body {
  background-color: var(--color-background);
  color: var(--color-text);
  transition: background-color 0.3s, color 0.3s;
}

/* Layout */
.content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  max-width: 600px;
  margin: 0 auto;
}

/* Header */
.banner {
  display: flex;
  align-items: center;
  background-color: var(--color-banner);
  justify-content: space-between;
  padding: 0.5rem 1rem;
}

/* Logo styling */
.logo {
  font-family: var(--font-logo);
  font-size: 2.5rem;
  color: var(--color-logo);
  text-align: center;
  flex-grow: 1;
  transition: transform 0.2s, text-shadow 0.2s;
}

.logo:hover {
  transform: scale(1.05);
  text-shadow: 0 0 10px rgba(251, 181, 48, 0.5);
}

.icon-button {
  border: solid 2px;
  border-radius: var(--border-radius);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--color-logo);
  cursor: pointer;
}

.icon-button:hover {
  opacity: 0.8;
}

/* Game area */
.game-area {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
}

.guess-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 320px;
}

.guess-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.guess-cell {
  width: 50px;
  height: 50px;
  border: 1px solid var(--color-key-border);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  text-transform: uppercase;
}

/* Keyboard */
.keyboard-container {
  padding: 0.5rem 0 1rem 0;
}

.keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.keyboard-row {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
}

.key {
  height: 50px;
  min-width: 30px;
  flex: 1;
  border: 1px solid var(--color-key-border);
  border-radius: var(--border-radius);
  background-color: var(--color-key-bg);
  color: var(--color-key-text);
  font-family: var(--font-primary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

.key:active {
  background-color: #555555;
}

.key-wide {
  flex: 1.5;
  font-size: 0.9rem;
}

/* Game states */
.correct {
  background-color: var(--color-correct);
  color: white;
  border-color: var(--color-correct);
}

.semicorrect {
  background-color: var(--color-semicorrect);
  color: white;
  border-color: var(--color-semicorrect);
}

.incorrect {
  background-color: var(--color-incorrect);
  color: white;
  border-color: var(--color-incorrect);
}

.disabledBtn {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Overlay and messages */
.overlay {
  opacity: 0;
  background-color: #000000;
  position: fixed;
  margin: 0;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
}

.overlayOn {
  pointer-events: all;
  opacity: 0.7;
}

#messages {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 300px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}

.message {
  width: 100%;
  padding: 1rem;
  border: solid 1px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #FBF5A0;
  color: #000000;
  border-radius: var(--border-radius);
  opacity: 1;
  transition: opacity 1s ease;
  z-index: 3;
}

.hideMsg {
  opacity: 0;
}

/* Result screen styles */
.resultScreen {
  position: relative;
  width: 320px;
  max-width: 90vw;
  background-color: var(--color-background);
  color: var(--color-text);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 100;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-title {
  font-size: 2rem;
  font-weight: bold;
  color: var(--color-correct);
  margin-bottom: 0.5rem;
}

.result-title.lost {
  color: var(--color-incorrect);
}

.result-details {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.correct-word {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 1rem 0;
}

.result-letter {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  font-weight: bold;
  background-color: var(--color-correct);
  color: white;
  border-radius: 4px;
  animation: bounce-in 0.5s ease forwards;
  animation-delay: var(--delay, 0s);
  transform: scale(0);
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.play-again-btn {
  background-color: var(--color-correct);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background-color 0.2s, transform 0.2s;
}

.play-again-btn:hover {
  background-color: #0d6d3e;
  transform: translateY(-2px);
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.close-btn:hover {
  opacity: 1;
}

/* Test field */
.test-field {
  position: fixed;
  width: 50px;
  height: 20px;
  left: 10px;
  top: 20%;
}

/* Media queries */
@media (max-width: 480px) {
  .guess-cell {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }
  
  .key {
    height: 45px;
    font-size: 0.9rem;
    padding: 0 3px;
  }
  
  .logo {
    font-size: 2rem;
  }
  
  .keyboard-container {
    padding: 0.5rem 0.5rem 1rem 0.5rem;
    width: 100%;
  }
  
  .keyboard {
    gap: 0.3rem;
    width: 100%;
    max-width: 100%;
  }
  
  .keyboard-row {
    gap: 0.2rem;
    width: 100%;
  }
  
  /* Fix for "BANDYTI" text */
  #enter {
    font-size: 0.75rem;
  }
}

@media (max-width: 360px) {
  .guess-cell {
    width: 40px;
    height: 40px;
  }
  
  .key {
    height: 40px;
    min-width: 26px;
    font-size: 0.8rem;
    padding: 0 2px;
  }
  
  /* Even smaller font for "BANDYTI" on very small screens */
  #enter {
    font-size: 0.7rem;
  }
}

/* Invalid word modal */
.invalid-word-modal {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background-color: var(--color-background);
  color: var(--color-text);
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 280px;
  border: 2px solid var(--color-incorrect);
}

.invalid-word-modal.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.modal-icon {
  font-size: 2rem;
  color: var(--color-incorrect);
  margin-bottom: 0.5rem;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: bold;
  margin-bottom: 0.2rem;
}

.modal-text {
  font-size: 1rem;
  opacity: 0.8;
}

/* Hint modal */
.hint-modal {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background-color: var(--color-background);
  color: var(--color-text);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 280px;
  border: 2px solid var(--color-logo);
}

.hint-modal.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hint-modal .modal-icon {
  font-size: 2rem;
  color: var(--color-logo);
  margin-bottom: 0.3rem;
}

.hint-modal .modal-title {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.hint-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hint-letters {
  display: flex;
  gap: 5px;
  margin: 0.5rem 0;
}

.hint-letter {
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-key-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.hint-revealed {
  background-color: var(--color-logo);
  color: white;
  border-color: var(--color-logo);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(251, 181, 48, 0.4);
  }
  100% {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(251, 181, 48, 0.7);
  }
}

.hint-position {
  font-size: 1.1rem;
}

/* Hide reset button for now */
/*#resetBtn {
  display: none;
}*/