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

body {
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  background-color: #121213;
  color: #fff;
  min-height: 100vh;
}

.game-container {
  width: 100%;
  min-width: 300px;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
}

/* Header */
.header {
  width: 100%;
  padding: 16px 0;
  border-bottom: 1px solid #3a3a3c;
  text-align: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Game Board */
.game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 32px 0;
  width: 100%;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.row {
  display: flex;
  gap: 5px;
}

.tile {
  width: 62px;
  height: 62px;
  border: 2px solid #3a3a3c;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  font-weight: 700;
  text-transform: uppercase;
  background-color: transparent;
  color: #fff;
}

.tile.filled {
  border-color: #565758;
}

.tile.correct {
  background-color: #538d4e;
  border-color: #538d4e;
}

.tile.present {
  background-color: #b59f3b;
  border-color: #b59f3b;
}

.tile.absent {
  background-color: #3a3a3c;
  border-color: #3a3a3c;
}

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 484px;
}

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

.key {
  height: 58px;
  min-width: 43px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background-color: #818384;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  max-width: 43px;
}

.key:hover {
  background-color: #a6a6a6;
}

.key.key-wide {
  min-width: 65px;
  max-width: 65px;
  font-size: 12px;
}

.key.correct {
  background-color: #538d4e;
}

.key.present {
  background-color: #b59f3b;
}

.key.absent {
  background-color: #3a3a3c;
}

/* Stats Screen */
.stats-screen {
  display: none;
  width: 100%;
  max-width: 500px;
  padding: 20px;
}

.stats-screen.visible {
  display: block;
}

.board.hidden,
.keyboard.hidden {
  display: none;
}

.stats-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-header {
  text-align: center;
  border-bottom: 1px solid #3a3a3c;
  padding-bottom: 16px;
}

.stats-header h2 {
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Game Result */
.game-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid #3a3a3c;
}

.game-result-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
}

.game-result-word {
  font-size: 18px;
  color: #818384;
}

.game-result-word .secret-word {
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}

/* Stats Summary */
.stats-summary {
  display: flex;
  justify-content: space-around;
  gap: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
}

.stat-label {
  font-size: 12px;
  color: #818384;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Histogram */
.stats-distribution {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-distribution h3 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #818384;
}

.histogram {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.histogram-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.histogram-label {
  font-size: 14px;
  font-weight: 700;
  width: 16px;
  text-align: right;
}

.histogram-bar-container {
  flex: 1;
  height: 24px;
  position: relative;
}

.histogram-bar {
  height: 100%;
  background-color: #3a3a3c;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  transition: background-color 0.2s ease;
}

.histogram-bar.highlight {
  background-color: #538d4e;
}

.histogram-count {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

/* Buttons */
.stats-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn {
  flex: 1;
  height: 52px;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-primary {
  background-color: #538d4e;
  color: #fff;
}

.btn-primary:hover {
  background-color: #6aaa64;
}

.btn-outline {
  background-color: transparent;
  color: #fff;
  border: 2px solid #3a3a3c;
}

.btn-outline:hover {
  background-color: #3a3a3c;
}

/* Responsive adjustments */
@media (max-width: 500px) {
  .tile {
    width: 56px;
    height: 56px;
    font-size: 30px;
  }

  .key {
    height: 52px;
    min-width: 36px;
    max-width: 36px;
    font-size: 13px;
  }

  .key.key-wide {
    min-width: 58px;
    max-width: 58px;
    font-size: 11px;
  }
}

@media (max-width: 400px) {
  .tile {
    width: 50px;
    height: 50px;
    font-size: 26px;
  }

  .key {
    height: 48px;
    min-width: 28px;
    max-width: 28px;
    font-size: 11px;
  }

  .key.key-wide {
    min-width: 48px;
    max-width: 48px;
    font-size: 10px;
  }

  .keyboard-row {
    gap: 4px;
  }

  .stats-screen {
    padding: 16px;
  }

  .stat-value {
    font-size: 28px;
  }

  .btn {
    height: 44px;
    font-size: 14px;
  }
}

@media (max-width: 350px) {
  .header h1 {
    font-size: 20px;
  }

  .tile {
    width: 46px;
    height: 46px;
    font-size: 24px;
  }

  .row {
    gap: 4px;
  }

  .key {
    height: 44px;
    min-width: 24px;
    max-width: 24px;
    font-size: 10px;
  }

  .key.key-wide {
    min-width: 42px;
    max-width: 42px;
    font-size: 9px;
  }

  .keyboard-row {
    gap: 3px;
  }

  .keyboard {
    gap: 6px;
  }
}

/* Loading Overlay */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(18, 18, 19, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.visible {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #3a3a3c;
  border-top-color: #538d4e;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 18px;
  font-weight: 700;
  color: #818384;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.game.disabled {
  pointer-events: none;
  opacity: 0.6;
}
