* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: Arial, sans-serif;
  background: #121213;
  color: white;
  min-height: 100svh;
}

.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  padding: 10px 15px 12px;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.streak {
  margin-top: 0;
  font-size: 16px;
  font-weight: bold;
  color: #ffd54a;
}

h1 {
  margin: 0 0 9px;
  font-size: 4rem;
  line-height: 1.05;
}

.controls {
  margin: 10px 0 10px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 10px 16px;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  font-size: 16px;
  background: #2f2f31;
  color: white;
  transition: 0.15s ease;
}

.mode-btn:hover {
  background: #3a3a3c;
}

.mode-btn.active-mode {
  background: #538d4e;
}

.status {
  min-height: 22px;
  margin: 6px 0 0;
  font-size: 14px;
  color: #d7dadc;
  text-align: center;
  word-break: break-word;
  padding: 0 6px;
}

.hidden {
  display: none !important;
}

.game-area {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 10px;
}

.board-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.tile {
  width: 56px;
  height: 56px;
  border: 2px solid #3a3a3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  text-transform: uppercase;
  background: #121213;
  transition: border-color 0.15s ease, transform 0.1s ease;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  flex: 0 0 auto;
}

.tile.filled {
  border-color: #6b6b6d;
}

.tile.active {
  border-color: #9b9b9d;
}

.tile.flip {
  animation: tileFlip 0.55s ease;
}

@keyframes tileFlip {
  0% { transform: rotateX(0deg); }
  45% { transform: rotateX(90deg); }
  55% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.correct {
  background: #538d4e;
  border-color: #538d4e;
}

.present {
  background: #b59f3b;
  border-color: #b59f3b;
}

.absent {
  background: #3a3a3c;
  border-color: #3a3a3c;
}

.keyboard {
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.keyboard-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
}

.key {
  min-width: 45px;
  height: 45px;
  padding: 0 8px;
  border: none;
  border-radius: 6px;
  background: #818384;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 1 auto;
}

.key-wide {
  min-width: 68px;
  font-size: 16px;
  padding: 0 10px;
}

.key-correct { background: #538d4e; }
.key-present { background: #b59f3b; }
.key-absent { background: #3a3a3c; }

.action-buttons {
  margin: 8px 0 10px;
  display: flex;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
}

.action-buttons > * {
  flex: 1;
  max-width: 180px;
}

.share-wrap {
  position: relative;
  display: flex;
}

.action-btn {
  width: 100%;
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  background: #538d4e;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:hover {
  filter: brightness(1.05);
}

.copy-toast {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  background: #2f2f31;
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  white-space: nowrap;
  border: 1px solid #4a4a4d;
  z-index: 999;
}

.copy-toast::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #2f2f31;
}

@media (max-width: 600px) {
  .container {
    padding: 8px 8px 6px;
  }

  h1 {
    font-size: 2.8rem;
    margin-bottom: 8px;
  }

  .controls {
    margin: 6px 0 6px;
    gap: 8px;
  }

  .mode-btn {
    padding: 10px 14px;
    font-size: 15px;
  }

  .streak {
    font-size: 15px;
    margin-top: 2px;
  }

  .status {
    min-height: 18px;
    font-size: 13px;
    margin-top: 2px;
  }

  .board {
    gap: 5px;
    margin: 8px 0 6px;
  }

  .board-row {
    gap: 5px;
  }

  .tile {
    width: 47px;
    height: 47px;
    font-size: 20px;
  }

  .action-buttons {
    margin: 6px 0 6px;
    gap: 8px;
    min-height: 40px;
  }

  .action-buttons > * {
    max-width: 155px;
  }

  .action-btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  .keyboard {
    gap: 5px;
    margin-top: 4px;
  }

  .keyboard-row {
    gap: 3px;
  }

  .key {
    min-width: 31px;
    height: 35px;
    padding: 0 3px;
    font-size: 16px;
    border-radius: 5px;
  }

  .key-wide {
    min-width: 54px;
    font-size: 16px;
    padding: 0 5px;
  }
}

@media (max-width: 430px) {
  .container {
    padding: 6px 6px 4px;
  }

  h1 {
    font-size: 2.35rem;
    margin-bottom: 6px;
  }

  .controls {
    margin: 5px 0 5px;
    gap: 6px;
  }

  .mode-btn {
    padding: 9px 12px;
    font-size: 14px;
    border-radius: 8px;
  }

  .streak {
    font-size: 14px;
  }

  .status {
    min-height: 16px;
    font-size: 12px;
  }

  .board {
    gap: 4px;
    margin: 6px 0 5px;
  }

  .board-row {
    gap: 4px;
  }

  .tile {
    width: 42px;
    height: 42px;
    font-size: 18px;
    border-width: 2px;
  }

  .action-buttons {
    margin: 5px 0 5px;
    gap: 6px;
    min-height: 38px;
  }

  .action-buttons > * {
    max-width: 145px;
  }

  .action-btn {
    padding: 9px 10px;
    font-size: 13px;
  }

  .keyboard {
    gap: 4px;
    margin-top: 2px;
  }

  .keyboard-row {
    gap: 2px;
  }

  .key {
    min-width: 36px;
    height: 41px;
    font-size: 16px;
    padding: 0 2px;
    border-radius: 5px;
  }

  .key-wide {
    min-width: 48px;
    font-size: 16px;
    padding: 0 3px;
  }

  .copy-toast {
    font-size: 12px;
    padding: 6px 10px;
  }
}