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

:root {
  --bg-primary: #121213;
  --bg-secondary: #1a1a1b;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --border: #3a3a3c;
  --border-active: #565758;
}

body {
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  flex: 1;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--border);
}

.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 4px;
  margin: 12px auto;
  width: fit-content;
}

.mode-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--border-active);
  color: var(--text-primary);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.game-container {
  width: 100%;
  margin-bottom: 20px;
}

.guess-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 20px;
}

.guess-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

.tile {
  width: 45px;
  height: 58px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: all 0.3s ease;
}

.tile.filled {
  border-color: var(--border-active);
  animation: pop 0.1s ease;
}

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

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

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

.tile.flip {
  animation: flip 0.5s ease;
}

.slash {
  font-size: 32px;
  color: var(--text-secondary);
  width: 20px;
  text-align: center;
}

@keyframes pop {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes flip {
  0% {
    transform: rotateX(0);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

.keyboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

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

.key {
  min-width: 43px;
  height: 58px;
  border: none;
  border-radius: 4px;
  background: var(--border-active);
  color: var(--text-primary);
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key:hover {
  opacity: 0.8;
}

.key:active {
  transform: scale(0.95);
}

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

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

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

.key.absent {
  background: var(--absent);
}

.hints-section {
  margin: 20px 0;
  width: 100%;
}

.hint-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.hint-btn {
  padding: 10px 16px;
  background: var(--border-active);
  color: var(--text-primary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.hint-btn:hover:not(:disabled) {
  background: var(--border);
}

.hint-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.hint-content strong {
  color: var(--text-primary);
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal h2 {
  font-size: 24px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.guess-distribution {
  margin-top: 20px;
}

.guess-distribution h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.distribution-bar {
  display: flex;
  align-items: center;
  margin: 4px 0;
  gap: 8px;
}

.bar-label {
  width: 12px;
  font-size: 14px;
}

.bar {
  background: var(--absent);
  height: 24px;
  min-width: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  font-size: 14px;
  font-weight: bold;
  transition: width 0.5s ease;
}

.bar.current {
  background: var(--correct);
}

.result-message {
  text-align: center;
  padding: 20px;
  margin: 20px 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.result-message h2 {
  margin-bottom: 12px;
  color: var(--correct);
}

.result-message.fail h2 {
  color: var(--text-secondary);
}

.result-message p {
  margin: 8px 0;
  line-height: 1.6;
}

.result-message a {
  color: #6aafff;
  text-decoration: none;
}

.result-message a:hover {
  text-decoration: underline;
}

.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

.share-btn,
.play-again-btn {
  padding: 12px 24px;
  background: var(--correct);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.play-again-btn {
  background: var(--border-active);
}

.share-btn:hover,
.play-again-btn:hover {
  opacity: 0.9;
}

.instructions {
  line-height: 1.8;
}

.instructions h3 {
  margin: 16px 0 8px 0;
}

.example-row {
  display: flex;
  gap: 5px;
  margin: 12px 0;
  justify-content: center;
}

.example-tile {
  width: 40px;
  height: 50px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
}

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

  .key {
    min-width: 36px;
    height: 50px;
    font-size: 18px;
  }

  h1 {
    font-size: 24px;
  }
}

.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px 24px;
  border-radius: 4px;
  font-weight: bold;
  z-index: 2000;
  animation: toast 2s ease;
}

@keyframes toast {
  0%,
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  10%,
  90% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
footer {
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

footer a:hover {
  text-decoration: underline;
}
