@import url(https://fonts.googleapis.com/css?family=Roboto);

:root {
  --color-correct: #4caf50;
  --color-present: #f9a825;
  --color-missing: rgba(255, 255, 255, 0.12);
  --color-unknown: rgba(0, 0, 0, 0.38);
  /* Surface color */
  --color-background: #121212;
  --color-missing-key: #B71C1C;
  /* RGB(20, 18, 24) */
  --color-text: #FFFFFF;
  --color-key-bg: rgba(255, 255, 255, 0.12);
  /* Match mobile white12 */
}

html,
body {
  font-family: 'Roboto', sans-serif;
  width: 100%;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  background-color: var(--color-background);
  color: var(--color-text);
}

.main {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  max-width: 500px;
  width: 100%;
}

.grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  padding: 10px;
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  /* Constrain width to matches 5/6 ratio with max 420px height */
  aspect-ratio: 5/6;
  margin: 0 auto;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.tile {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  font-weight: bold;
  text-transform: uppercase;
  text-transform: uppercase;
  border: 3px solid var(--color-unknown);
  /* Default border */
  background-color: transparent;
  color: white;
  user-select: none;
  border-radius: 14px;
  aspect-ratio: 1;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.tile.correct {
  background-color: var(--color-correct);
  border-color: var(--color-correct);
}

.tile.present {
  background-color: var(--color-present);
  border-color: var(--color-present);
}

.tile.missing {
  background-color: var(--color-missing);
  border-color: var(--color-missing);
}

.tile.unknown {
  border-color: var(--color-unknown);
  background-color: var(--color-unknown);
}

.keyboard {
  width: 100%;
  max-width: 500px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.key {
  font-family: inherit;
  font-weight: bold;
  border: 1px solid rgba(0, 0, 0, 0.87);
  padding: 0;
  margin: 0;
  height: 58px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  background-color: var(--color-key-bg);
  color: white;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-transform: uppercase;
  font-size: 1.2rem;
}

.key.large {
  flex: 1.5;
  font-size: 0.8rem;
}

/* Action Keys (Enter/Backspace) */
.key.action.enabled {
  background-color: #2196F3;
  /* Colors.blue */
  color: white;
}

.key.action.disabled {
  background-color: rgba(255, 255, 255, 0.12);
  /* Colors.white12 */
  color: rgba(255, 255, 255, 0.30);
  /* Colors.white30 */
  cursor: default;
}

.key.correct {
  background-color: var(--color-correct);
}

.key.present {
  background-color: var(--color-present);
}

.key.missing {
  background-color: var(--color-missing-key);
}

/* Score Widgets */
.score-widget {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
}

.score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.2rem;
}

.score-icon {
  width: 18px;
  height: 18px;
}

/* Dialog Overlay */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.dialog-content {
  background-color: var(--color-background);
  /* border: 1px solid var(--color-missing); Removed to match mobile */
  padding: 20px;
  border-radius: 8px;
  max-width: 90%;
  width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  position: relative;
}


.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Header */
.header {
  width: 100%;
  max-width: 500px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--color-missing);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  background: none;
  border: none;
  color: var(--color-text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.primary-button {
  background-color: var(--color-correct);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 10%;
  top: auto;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-text);
  color: var(--color-background);
  padding: 10px 20px;
  border-radius: 4px;
  font-weight: bold;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-out;
  z-index: 2000;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Difficulty Widget matching mobile style */
.difficulty-widget {
  background-color: rgba(255, 255, 255, 0.12);
  /* Match mobile white12 perception on dark */
  padding: 4px 12px;
  border-radius: 24px;
  font-size: 0.9rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

/* HowTo Dialog Content */
.how-to-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.how-to-content h3 {
  margin-top: 10px;
  margin-bottom: 5px;
}

.how-to-content p {
  margin: 0;
  line-height: 1.4;
}

.example-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.dialog-footer-links {
  margin-top: 10px;
  font-size: 0.8rem;
  text-align: center;
  color: var(--color-key-bg);
}

.dialog-footer-links a {
  color: inherit;
  text-decoration: none;
}

.dialog-footer-links a:hover {
  text-decoration: underline;
}

/* Finish Dialog Styles */
.finish-dialog-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.finish-dialog-header {
  margin-bottom: 8px;
}

.finish-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.finish-icon-lost {
  font-size: 4rem;
}

.finish-title {
  margin: 0;
  font-size: 2rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.finish-word-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin: 10px 0;
}

.finish-description {
  font-size: 1rem;
  color: var(--color-text);
  max-width: 300px;
  line-height: 1.4;
}

.finish-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.primary-button.restart-button {
  background-color: var(--color-correct);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
}

.secondary-button {
  background-color: #2196F3;
  /* Blue for share */
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 10px;
  font-weight: bold;
}

.secondary-button.share-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-red {
  --color-correct: #4caf50;
  --color-present: #f9a825;
  --color-missing: rgba(255, 255, 255, 0.12);
  --color-unknown: rgba(0, 0, 0, 0.54);
  --color-background: #121212;
}

.download-buttons,
.support-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}

.download-buttons a img,
.support-buttons a img {
  height: 57px;
  background: black;
}

/* Mobile Responsiveness */
@media (max-width: 380px) {
  .keyboard {
    gap: 4px;
    padding: 5px;
  }

  .keyboard-row {
    gap: 3px;
  }

  .key {
    height: 48px;
    font-size: 1rem;
    border-radius: 4px;
  }

  .grid {
    padding: 5px;
    gap: 4px;
  }

  .row {
    gap: 4px;
  }

  .tile {
    border-radius: 8px;
    font-size: 1.5rem;
    border-width: 2px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .header {
    padding: 10px 10px;
  }
}

/* Legal Pages */
.legal-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  line-height: 1.6;
  color: var(--color-text);
}

.legal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-missing);
}

.legal-header h2 {
  color: var(--color-text);
  margin: 0;
}

.legal-page h1,
.legal-page h2,
.legal-page h3 {
  color: var(--color-correct);
  margin-top: 20px;
}

.legal-page a {
  color: #2196F3;
  text-decoration: none;
}

.legal-page a:hover {
  text-decoration: underline;
}