@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
  background: #121213;
  color: #ffffff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

#root {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Header styling */
.header {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-bottom: 1px solid #2d2d30;
  position: relative;
  background: rgba(18, 18, 19, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
}

.header-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 30%, #a1a1a6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-icons {
  position: absolute;
  right: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #a1a1a6;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Game container */
.game-container {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 8px;
  flex: 1;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #ffffff;
  color: #121213;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Board Row and Tiles */
.board-row {
  display: flex;
  gap: 6px;
}

.tile {
  width: 62px;
  height: 62px;
  border: 2px solid #3a3a3c;
  background: #121213;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #ffffff;
  user-select: none;
  transition: border-color 0.1s ease, background 0.15s ease;
  position: relative;
}

/* Tile with a letter typed (not yet submitted) */
.tile.filled {
  border-color: #7a7a7a;
  transform: scale(1.05);
  animation: pop 0.1s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Revealed tile states */
.tile.correct {
  background: #538d4e;
  border-color: #538d4e;
}

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

.tile.absent {
  background: #2b2b2d;
  border-color: #2b2b2d;
  color: #8a8a8c;
}

/* Flip animation */
.tile.flip {
  animation: flip 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Row shake animation (invalid word) */
.row-shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* Bounce animation on win */
.tile.bounce {
  animation: bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes bounce {
  0%   { transform: translateY(0); }
  40%  { transform: translateY(-16px); }
  70%  { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

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

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

.key {
  height: 58px;
  min-width: 40px;
  background: #818384;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  user-select: none;
  transition: background 0.12s ease, transform 0.05s ease, filter 0.12s ease;
  padding: 0 8px;
  flex: 1;
  max-width: 43px;
}

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

.key:hover {
  filter: brightness(1.1);
}

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

.key:focus {
  outline: none;
}

.key.correct { background: #538d4e; }
.key.present { background: #b59f3b; }
.key.absent  { background: #2b2b2d; color: #8a8a8c; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: #1a1a1c;
  border: 1px solid #2d2d30;
  border-radius: 16px;
  padding: 28px;
  width: 90%;
  max-width: 420px;
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: scaleUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  color: #a1a1a6;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.modal h2 {
  text-align: center;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

/* Stats modal */
.stats-grid {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 28px;
}

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

.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: #ffffff;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: #a1a1a6;
  text-align: center;
  max-width: 70px;
}

.distribution-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 12px;
  color: #ffffff;
}

.distribution {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 28px;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.dist-label {
  width: 12px;
  text-align: right;
  flex-shrink: 0;
  color: #a1a1a6;
  font-weight: 600;
}

.dist-bar-wrap {
  flex: 1;
}

.dist-bar {
  background: #2b2b2d;
  min-width: 28px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: right;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  color: #ffffff;
}

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

.stats-footer {
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #2d2d30;
  padding-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

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

.countdown-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #a1a1a6;
}

.countdown-time {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
}

.share-btn {
  background: #538d4e;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
  box-shadow: 0 4px 12px rgba(83, 141, 78, 0.2);
}

.share-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(83, 141, 78, 0.3);
}

.share-btn:active {
  transform: translateY(1px);
}

/* Help modal instructions */
.help-section {
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.6;
  border-bottom: 1px solid #2d2d30;
  padding-bottom: 20px;
  color: #e1e1e6;
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-example {
  display: flex;
  gap: 5px;
  margin: 12px 0 8px;
}

.help-tile {
  width: 40px;
  height: 40px;
  border: 2px solid #3a3a3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
}

.help-tile.correct { background: #538d4e; border-color: #538d4e; }
.help-tile.present { background: #b59f3b; border-color: #b59f3b; }
.help-tile.absent  { background: #2b2b2d; border-color: #2b2b2d; color: #8a8a8c; }

/* Mode toggle pill */
.mode-toggle {
  display: flex;
  background: #111112;
  border: 1px solid #2d2d30;
  border-radius: 24px;
  padding: 3px;
  gap: 2px;
  position: absolute;
  left: 16px;
}

.mode-btn {
  background: none;
  border: none;
  color: #a1a1a6;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.mode-btn:hover:not(.active-normal):not(.active-beginner) {
  color: #ffffff;
}

.mode-btn.active-normal {
  background: #538d4e;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(83, 141, 78, 0.3);
}

.mode-btn.active-beginner {
  background: #b59f3b;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(181, 159, 59, 0.3);
}

/* Signature */
.signature {
  position: fixed;
  bottom: 12px;
  right: 16px;
  font-size: 11px;
  color: #565656;
  pointer-events: none;
  user-select: none;
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* Responsive: shrink tiles on short/narrow viewports */
@media (max-height: 720px) {
  .game-container {
    padding: 12px 8px;
  }
  .board-v2 {
    margin-bottom: 16px !important;
  }
  .tile {
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
  }
  .key {
    height: 48px;
    font-size: 0.8rem;
  }
  .header {
    padding: 12px 16px;
  }
  .header-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 380px) {
  .tile {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
  }
  .key {
    min-width: 32px;
    max-width: 36px;
    font-size: 0.75rem;
    padding: 0 4px;
  }
  .key.wide {
    min-width: 50px;
    max-width: 56px;
  }
  .mode-toggle {
    left: 8px;
  }
}
