:root {
  --bg: #f4f2ea;
  --bg2: #e5e0d6;
  --bg3: #f2b705;
  --ink: #111111;
  --muted: #4f4f4f;
  --accent: #111111;
  --accent-dark: #000000;
  --neon: #ff6b35;
  --tile-bg: #fdfbf7;
  --tile-border: #111111;
  --correct: #00b67a;
  --present: #f2b705;
  --absent: #b2b2b2;
  --card: #ffffff;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
  --radius: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: linear-gradient(90deg, var(--bg) 0%, var(--bg2) 100%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: absolute;
  border-radius: 0;
  z-index: -1;
  filter: none;
}

body::before {
  width: 240px;
  height: 240px;
  background: #111111;
  top: -40px;
  right: -40px;
}

body::after {
  width: 260px;
  height: 260px;
  background: #f2b705;
  bottom: -60px;
  left: -60px;
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.15;
  mix-blend-mode: normal;
  pointer-events: none;
  border-radius: 0;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 22px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  position: relative;
}

.hero {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-family: "Bungee", cursive;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #111111;
  text-shadow: 4px 4px 0 #f2b705;
}

.tagline {
  color: var(--muted);
  font-size: 0.98rem;
  margin-top: 6px;
}

.namebar {
  display: grid;
  gap: 6px;
  justify-items: end;
  text-align: right;
  font-size: 0.9rem;
}

.name-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.name-value {
  font-weight: 700;
  font-size: 1.1rem;
}

button {
  font-family: inherit;
}

.ghost {
  border: 2px solid #111111;
  background: #ffffff;
  color: #111111;
  padding: 6px 12px;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost:hover {
  background: #111111;
  color: #ffffff;
}

.game {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.board {
  display: grid;
  gap: 10px;
  width: 100%;
  justify-items: center;
  animation: boardFade 0.6s ease both;
}

.board.shake {
  animation: shake 0.35s ease;
}

.row {
  display: grid;
  grid-template-columns: repeat(5, minmax(48px, 64px));
  gap: 10px;
}

.tile {
  width: clamp(48px, 10vw, 64px);
  height: clamp(48px, 10vw, 64px);
  display: grid;
  place-items: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: clamp(1.2rem, 3vw, 2rem);
  border-radius: 0;
  background: var(--tile-bg);
  border: 3px solid var(--tile-border);
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: inset 0 0 0 rgba(0, 0, 0, 0);
}

.tile.filled {
  animation: pop 0.12s ease;
}

.tile.reveal {
  animation: flip 0.55s ease forwards;
}

.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
  box-shadow: 0 12px 20px rgba(46, 139, 94, 0.35);
}

.tile.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
  box-shadow: 0 12px 20px rgba(208, 161, 41, 0.3);
}

.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
  box-shadow: 0 12px 20px rgba(33, 34, 38, 0.3);
}

.keyboard {
  display: grid;
  gap: 8px;
  width: min(520px, 100%);
}

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

.key {
  border: none;
  background: #ffffff;
  padding: 12px 10px;
  border-radius: 0;
  min-width: 34px;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.2s ease, color 0.2s ease;
  box-shadow: 4px 4px 0 #111111;
  border: 2px solid #111111;
}

.key:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 2px 2px 0 #111111;
}

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

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

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

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

.message {
  min-height: 24px;
  color: var(--accent-dark);
  font-weight: 600;
}

.message.hype {
  animation: hype 0.6s ease;
}

.message-row {
  width: min(520px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ghost.small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

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

.panel {
  display: grid;
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 3px solid #111111;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.date {
  font-size: 0.85rem;
  color: var(--muted);
}

.rankings {
  margin-top: 12px;
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.stats {
  font-size: 0.85rem;
  color: var(--muted);
  background: #fff7ea;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.rank-table th,
.rank-table td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px dashed #d7d1c8;
}

.rank-table th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.rank-label {
  font-weight: 700;
}

.how {
  margin: 10px 0 0 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-card {
  background: #fff;
  padding: 26px;
  border-radius: 0;
  width: min(360px, 100%);
  box-shadow: none;
  border: 3px solid #111111;
  display: grid;
  gap: 12px;
}

.modal-card input {
  padding: 10px 12px;
  border-radius: 0;
  border: 2px solid #111111;
  font-size: 1rem;
}

.primary {
  background: #111111;
  color: #ffffff;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.primary:hover {
  background: #000000;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #ffffff;
  color: var(--ink);
  border-radius: 0;
  padding: 10px 18px;
  box-shadow: 6px 6px 0 #111111;
  border: 2px solid #111111;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sparkle {
  animation: sparkle 0.8s ease;
}

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

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

@keyframes boardFade {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(8px);
  }
  75% {
    transform: translateX(-6px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes hype {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sparkle {
  0% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(255, 107, 53, 0);
  }
  60% {
    transform: scale(1.08);
    text-shadow: 0 0 18px rgba(255, 107, 53, 0.7);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(255, 107, 53, 0);
  }
}

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

  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .namebar {
    justify-items: start;
    text-align: left;
  }

  .panel {
    order: 3;
  }
}

@media (max-width: 520px) {
  .row {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }

  .tile {
    width: min(56px, 16vw);
    height: min(56px, 16vw);
  }

  .key {
    padding: 10px 6px;
  }
}
