:root {
  --bg: #121212;
  --surface: #1a1a1a;
  --surface-2: #222;
  --text: #f8f8f8;
  --muted: #b3b3b3;
  --green: #1db954;
  --green-dark: #14833c;
  --danger: #d9534f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #1f1f1f 0%, var(--bg) 55%);
  color: var(--text);
}

.topbar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2b2b2b;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

h1, h2, h3, h4 { margin: 0 0 .6rem 0; }
p { margin: .25rem 0; }

.auth-menu {
  position: relative;
  display: grid;
  justify-items: end;
  gap: .5rem;
}

.auth-panel {
  width: min(360px, calc(100vw - 2rem));
}

.app-layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
}

.main-column {
  display: grid;
  gap: 1rem;
}

.right-sidebar {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.panel {
  background: var(--surface);
  border: 1px solid #2c2c2c;
  border-radius: 14px;
  padding: 1rem;
}

.hidden { display: none !important; }

.row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  color: var(--muted);
  font-size: .95rem;
}

input, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid #383838;
  background: var(--surface-2);
  color: var(--text);
  padding: .55rem .7rem;
}

input { min-height: 40px; }

button {
  border: none;
  background: var(--green);
  color: #07110a;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}

button:hover { background: #29cf63; }
button.secondary { background: #333; color: #ddd; }
button.secondary:hover { background: #444; }
button.danger { background: var(--danger); color: #fff; }
button.full-width { width: 100%; }

.mode-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
}

.mode-card {
  display: grid;
  gap: .1rem;
  justify-items: start;
  text-align: left;
  background: #1f1f1f;
  border: 1px solid #303030;
  color: var(--text);
}

.mode-card span {
  color: var(--muted);
  font-size: .85rem;
}

.mode-card.active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

#board {
  margin: .75rem 0;
  display: grid;
  gap: .4rem;
}

.guess-row {
  display: grid;
  gap: .35rem;
  grid-template-columns: repeat(8, minmax(22px, 1fr));
}

.tile {
  border: 1px solid #404040;
  min-height: 38px;
  display: grid;
  place-items: center;
  font-weight: 700;
  border-radius: 8px;
  text-transform: uppercase;
}

.tile.correct { background: #1d6f3a; border-color: #1d6f3a; }
.tile.present { background: #4d4d22; border-color: #4d4d22; }
.tile.absent { background: #303030; border-color: #303030; color: #aaa; }

.keyboard {
  margin-top: .85rem;
  display: grid;
  gap: .4rem;
}

.keyboard-row {
  display: flex;
  gap: .35rem;
  justify-content: center;
}

.key {
  min-height: 42px;
  min-width: 34px;
  padding: .5rem;
  border-radius: 8px;
  border: 1px solid #3b3b3b;
  background: #777;
  color: #0b0b0b;
  font-weight: 700;
}

.key.wide {
  min-width: 64px;
}

.key.absent {
  background: #2a2a2a;
  border-color: #2a2a2a;
  color: #b0b0b0;
}

.key.present {
  background: #8a7e2f;
  border-color: #8a7e2f;
  color: #111;
}

.key.correct {
  background: var(--green-dark);
  border-color: var(--green-dark);
  color: #041008;
}

.mode-section {
  margin-top: .85rem;
  border-top: 1px solid #2d2d2d;
  padding-top: .75rem;
}

.challenge-item {
  border: 1px solid #2f2f2f;
  border-radius: 10px;
  padding: .65rem;
  margin-bottom: .5rem;
}

.challenge-item input {
  width: 100%;
  margin-top: .45rem;
}

#hint-box {
  color: #9ee5b6;
  font-size: .95rem;
}

.muted {
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .right-sidebar {
    order: -1;
  }

  .mode-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-menu {
    justify-items: stretch;
  }

  .mode-cards {
    grid-template-columns: 1fr;
  }

  .row { flex-direction: column; }
  .row > * { width: 100%; }
}
