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

body {
  background: #121213;
  color: #fff;
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
  width: 100%;
  border-bottom: 1px solid #3a3a3c;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.1;
}
.logo-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
.logo-link:hover h1,
.logo-link:focus-visible h1 {
  opacity: 0.85;
}
.tld {
  font-size: 0.75em;
  vertical-align: baseline;
  opacity: 0.5;
}
.subtitle {
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #818384;
  margin-top: 2px;
}
#info-btn {
  position: absolute;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #818384;
  background: transparent;
  color: #818384;
  font-size: 0.9rem;
  font-weight: 700;
  font-style: italic;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#info-btn:hover { border-color: #fff; color: #fff; }

/* Modal */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open { display: flex; }
#modal {
  background: #1a1a1b;
  border: 1px solid #3a3a3c;
  border-radius: 12px;
  padding: 28px 28px 24px;
  max-width: 400px;
  width: calc(100% - 48px);
  position: relative;
}
#modal h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
#modal p {
  color: #d7dadc;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 10px;
}
#modal p:last-child { margin-bottom: 0; }
.color-key {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 0.88rem;
  color: #d7dadc;
}
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  flex-shrink: 0;
}
#modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #818384;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
#modal-close:hover { color: #fff; }

/* ======= CREATOR ======= */
#creator {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 32px;
  width: 100%;
  max-width: 460px;
  gap: 14px;
}
#creator > p {
  color: #818384;
  font-size: 1rem;
  text-align: center;
}
#creator input {
  width: 100%;
  padding: 13px 16px;
  background: #1a1a1b;
  border: 2px solid #565758;
  border-radius: 8px;
  color: #fff;
  outline: none;
}
#creator input:focus { border-color: #818384; }
#creator input::placeholder { color: #565758; }
#phrase-input {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
#phrase-input::placeholder { text-transform: none; letter-spacing: normal; }
#hint-input { font-size: 0.95rem; }

.btn-primary {
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  background: #538d4e;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-primary:hover { background: #6aaa64; }

#link-box {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding-top: 6px;
  border-top: 1px solid #3a3a3c;
}
#link-box label { color: #818384; font-size: 0.85rem; }
#link-display {
  background: #1a1a1b;
  border: 1px solid #3a3a3c;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: #aaa;
  word-break: break-all;
}
#copy-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  background: transparent;
  color: #fff;
  border: 2px solid #565758;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#copy-btn:hover { border-color: #818384; }

/* ======= GAME ======= */
#game {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  padding: 20px 12px 16px;
  gap: 16px;
}

#hint-display {
  display: none;
  background: #1a1a1b;
  border: 1px solid #3a3a3c;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: #818384;
  max-width: 500px;
  width: 100%;
  text-align: center;
}
#hint-display span { color: #d7dadc; }

#grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid #3a3a3c;
  border-radius: 3px;
  color: #fff;
  user-select: none;
  width: var(--tile-size, 52px);
  height: var(--tile-size, 52px);
}
.tile.filled { border-color: #565758; }
.tile.green  { background: #538d4e; border-color: #538d4e; }
.tile.yellow { background: #b59f3b; border-color: #b59f3b; }
.tile.grey   { background: #3a3a3c; border-color: #3a3a3c; }

.space-gap { width: 12px; flex-shrink: 0; }

#win-msg {
  display: none;
  background: #538d4e;
  color: #fff;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}
.shake { animation: shake 0.28s ease; }

#keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: 100%;
  max-width: 500px;
  padding: 0 6px;
}
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  height: 56px;
  min-width: 40px;
  padding: 0 5px;
  background: #818384;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.key.wide   { min-width: 60px; font-size: 0.75rem; }
.key.green  { background: #538d4e; }
.key.yellow { background: #b59f3b; }
.key.grey   { background: #3a3a3c; }