:root {
  --cream: #f6f1e7;
  --linen: #efe6d3;
  --basalt: #33393d;
  --basalt-dark: #23282b;
  --ink: #1f2422;
  --green: #12805c;
  --green-dark: #0d6248;
  --yellow: #c9982e;
  --grey: #7b8286;
  --red: #b23b3b;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  touch-action: manipulation; /* stops double-tap zoom on mobile */
}

button, .key, .tile, .icon-btn, a {
  touch-action: manipulation;
}

/* ---------- Header ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 2px solid var(--basalt);
  background: var(--linen);
}

.title-block {
  text-align: center;
  flex: 1;
}

.title-block h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--basalt-dark);
}

.title-block p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px 10px;
  color: var(--basalt-dark);
  line-height: 1;
}

.icon-btn:hover {
  color: var(--green);
}

/* ---------- Live counter ---------- */
.live-counter {
  text-align: center;
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--basalt-dark);
  font-weight: 600;
}

/* ---------- Promo banner (site-wide) ---------- */
.promo-banner {
  display: block;
  text-align: center;
  margin: 8px 12px 0;
  padding: 8px 12px;
  background: var(--linen);
  border: 1px solid #d7cfb8;
  border-radius: 8px;
  color: var(--basalt-dark);
  text-decoration: none;
  font-size: 0.82rem;
}

.promo-banner:hover {
  background: #e6dcbf;
}

.promo-banner strong {
  color: var(--green-dark);
}

/* ---------- Promo card (inside end-of-game modal) ---------- */
.promo-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  background: var(--linen);
  border-radius: 8px;
  border-left: 4px solid var(--green);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.85rem;
}

.promo-card:hover {
  background: #e6dcbf;
}

.promo-card-emoji {
  font-size: 1.4rem;
}

.promo-card strong {
  color: var(--green-dark);
}

/* ---------- Board ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  gap: 14px;
}

#board {
  --cols: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(34px, 52px));
  gap: 6px;
}

.row.shake {
  animation: shake 0.4s;
}

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

.tile {
  aspect-ratio: 1;
  border: 2px solid #c9c1ac;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--basalt-dark);
  background: var(--cream);
  text-transform: uppercase;
  transition: transform 0.15s;
}

.tile.filled {
  border-color: var(--grey);
  transform: scale(1.03);
}

.tile.flip {
  animation: flip 0.35s ease;
}

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

.tile.revealed.correct {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.tile.revealed.present {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #fff;
}

.tile.revealed.absent {
  background: var(--basalt);
  border-color: var(--basalt);
  color: #fff;
}

/* ---------- Keyboard ---------- */
#keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 520px;
}

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

.key {
  flex: 1;
  max-width: 44px;
  min-width: 28px;
  height: 50px;
  border: none;
  border-radius: 6px;
  background: #d7d0bd;
  color: var(--basalt-dark);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
}

.key:active {
  background: #c3bba5;
}

.key.wide {
  max-width: 66px;
  font-size: 0.68rem;
}

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

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

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

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

.toast-msg {
  background: var(--basalt-dark);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  opacity: 1;
  transition: opacity 0.3s;
}

.toast-msg.out {
  opacity: 0;
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--cream);
  border-radius: 12px;
  padding: 22px;
  max-width: 420px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.modal h2 {
  margin-top: 0;
  color: var(--basalt-dark);
}

.modal .close-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--grey);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.legend-tile {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.legend-tile.correct { background: var(--green); }
.legend-tile.present { background: var(--yellow); }
.legend-tile.absent { background: var(--basalt); }

.modal .slang-note {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--linen);
  border-left: 4px solid var(--green);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* End modal specifics */
#end-word {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: 0.04em;
  margin: 6px 0 4px;
}

#end-def {
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--basalt-dark);
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey);
  text-align: center;
}

.share-btn {
  width: 100%;
  padding: 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.share-btn:hover {
  background: var(--green-dark);
}

.countdown-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--grey);
  margin-top: 10px;
}

footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--grey);
  padding: 10px;
}

@media (max-width: 380px) {
  .tile {
    font-size: 1.15rem;
  }
  .key {
    height: 44px;
    font-size: 0.85rem;
  }
}
