/* Colours pulled from the GDVC logo: club red, white, dark headset grey */
:root {
  --bg: #12131a;
  --bg-2: #1b1d27;
  --text: #ffffff;
  --muted: #a6a9b6;
  --red: #d7262e;
  --red-dark: #9e161c;
  --silver: #c9ccd6;

  --tile-border: #3a3d4c;
  --tile-border-filled: #8a8e9e;
  --correct: #d7262e;   /* right letter, right spot - club red */
  --present: #e3a72f;   /* right letter, wrong spot */
  --absent: #3a3c47;    /* not in the word */
  --key-bg: #5c5f6e;
}

* { box-sizing: border-box; }

/* Stop phones zooming in when a key is tapped twice quickly (double-tap zoom). */
html, body, button { touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 2px solid var(--red);
  background: var(--bg-2);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 54px; height: 54px; }
.brand-text h1 {
  margin: 0;
  font-family: "Silkscreen", "Courier New", monospace;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.brand-text { text-align: center; }
.brand-text p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--silver);
  background: transparent;
  color: var(--silver);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--red); color: var(--red); }
.icon-btn.spacer { visibility: hidden; }

/* ---------- Board ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 8px 10px;
  position: relative;
}

.board {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.board-grid { display: grid; gap: 6px; }
.row { display: grid; gap: 6px; }
.row.shake { animation: shake 0.5s; }

.tile {
  width: var(--tile-size, 58px);
  height: var(--tile-size, 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--tile-border);
  border-radius: 4px;
  font-size: calc(var(--tile-size, 58px) * 0.55);
  font-weight: 800;
  text-transform: uppercase;
  user-select: none;
}
.tile.filled { border-color: var(--tile-border-filled); animation: pop 0.1s; }
.tile.correct, .tile.present, .tile.absent { border-color: transparent; }
.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); }
.tile.absent  { background: var(--absent); }
.tile.flip { animation: flip 0.5s ease forwards; }
.tile.bounce { animation: bounce 0.6s ease; }

/* ---------- Keyboard ---------- */
.keyboard { width: 100%; user-select: none; }
.kb-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 8px; }
.key {
  flex: 1;
  max-width: 44px;
  height: 56px;
  border: 0;
  border-radius: 6px;
  background: var(--key-bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}
.key.wide { max-width: 68px; flex: 1.5; font-size: 12px; }
.key:active { transform: scale(0.95); }
.key.correct { background: var(--correct); }
.key.present { background: var(--present); }
.key.absent  { background: var(--absent); color: #8b8e9b; }
.kb-spacer { flex: 0.5; max-width: 22px; }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 5;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 10;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--tile-border);
  border-top: 4px solid var(--red);
  border-radius: 8px;
  padding: 24px 22px;
  text-align: center;
  animation: rise 0.3s ease;
}
.modal-logo { width: 96px; height: 96px; }
.modal-card h2 { margin: 8px 0 12px; font-family: "Silkscreen", "Courier New", monospace; font-size: 26px; }
.modal-card p { color: var(--silver); line-height: 1.5; }
.modal-card .big-message {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  background: var(--bg);
  border-left: 4px solid var(--red);
  padding: 12px 14px;
  border-radius: 6px;
  text-align: left;
  white-space: pre-wrap;
}
.modal-card .answer { font-size: 28px; font-weight: 900; letter-spacing: 6px; color: var(--red); }
.close-btn {
  position: absolute; top: 8px; right: 12px;
  background: none; border: 0; color: var(--muted);
  font-size: 28px; cursor: pointer;
}
.example { display: flex; gap: 4px; justify-content: center; margin: 8px 0 2px; }
.example .tile { --tile-size: 38px; }
.gate-buttons { display: flex; gap: 12px; margin-top: 20px; }
.gate-btn {
  flex: 1;
  height: 48px;
  border: 0;
  border-radius: 6px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.gate-btn.yes { background: var(--red); }
.gate-btn.no { background: var(--key-bg); }
.gate-btn:active { transform: scale(0.97); }
#gate { background: var(--bg); }
.help-list { text-align: left; color: var(--silver); padding-left: 18px; line-height: 1.6; }

/* ---------- Animations ---------- */
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
@keyframes bounce {
  0%, 20% { transform: translateY(0); }
  40% { transform: translateY(-24px); }
  50% { transform: translateY(4px); }
  60% { transform: translateY(-12px); }
  80% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-height: 640px) {
  .brand-logo { width: 42px; height: 42px; }
  .brand-text h1 { font-size: 24px; }
  .key { height: 48px; }
}
