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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card: #0f3460;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text: #eee;
  --text-dim: #aab;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Menu Screen ── */
#menu {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.header p {
  color: var(--text-dim);
  font-size: 1.05rem;
  margin-top: 6px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

/* Featured grid */
.featured-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 48px;
}

.game-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid transparent;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: var(--accent);
}

.game-card .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.game-card .name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.game-card .desc {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* All games list */
.divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 32px;
}

.all-games-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: 8px;
  padding: 14px 18px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.game-list-item:hover {
  background: var(--card);
  border-color: var(--accent);
}

.game-list-item .icon { font-size: 1.4rem; }
.game-list-item .name { font-weight: 600; flex: 1; }
.game-list-item .desc { color: var(--text-dim); font-size: 0.85rem; }
.game-list-item .arrow { color: var(--text-dim); font-size: 1.2rem; }

/* ── Game Screen ── */
#game-screen {
  display: none;
  min-height: 100vh;
}

.game-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.back-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

.game-topbar .game-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.game-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ── Shared Game UI Elements ── */
.btn {
  display: inline-block;
  padding: 12px 28px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.btn-secondary:hover { background: rgba(255,255,255,0.16); }

.btn-small {
  padding: 8px 18px;
  font-size: 0.9rem;
}

/* Result screen */
.result-screen {
  text-align: center;
  padding: 40px 20px;
}

.result-screen .score {
  font-size: 3rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.result-screen .verdict {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: 32px;
}

.result-screen .btn { margin: 0 8px; }

/* Question / prompt styling */
.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 24px;
  line-height: 1.4;
}

.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-bottom: 28px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.choice-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  background: var(--surface);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 16px 20px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.choice-btn:hover {
  border-color: var(--accent);
  background: var(--card);
}

.choice-btn.correct {
  border-color: var(--success);
  background: rgba(46,204,113,0.15);
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: rgba(231,76,60,0.15);
}

.choice-btn.reveal {
  border-color: var(--success);
  opacity: 0.7;
}

.choice-btn:disabled { cursor: default; }

.feedback-text {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.score-display {
  text-align: right;
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.score-display span {
  color: var(--accent);
  font-weight: 700;
}

/* Timer bar */
.timer-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}

.timer-bar .fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* Input styling */
.game-input {
  background: var(--surface);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 14px 18px;
  color: var(--text);
  font-size: 1.1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.game-input:focus { border-color: var(--accent); }

.game-input::placeholder { color: rgba(255,255,255,0.3); }

/* ── Set Matcher specific ── */
.set-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.set-card {
  background: var(--surface);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 16px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-card:hover { border-color: rgba(255,255,255,0.3); }
.set-card.selected { border-color: var(--accent); transform: scale(1.04); }
.set-card.correct-flash { border-color: var(--success); background: rgba(46,204,113,0.15); }
.set-card.wrong-flash { border-color: var(--danger); background: rgba(231,76,60,0.15); }

/* ── Cipher specific ── */
.cipher-display {
  font-family: 'Courier New', monospace;
  font-size: 1.2rem;
  letter-spacing: 2px;
  line-height: 2.2;
  margin-bottom: 24px;
  word-break: break-all;
}

.cipher-letter {
  display: inline-block;
  text-align: center;
  width: 28px;
  cursor: pointer;
  position: relative;
}

.cipher-letter .encrypted {
  color: var(--text-dim);
  font-size: 0.75rem;
  display: block;
}

.cipher-letter .decoded {
  color: var(--accent);
  font-weight: 700;
  display: block;
  border-bottom: 2px solid rgba(255,255,255,0.15);
  min-height: 1.4em;
}

.cipher-letter .decoded.filled { border-bottom-color: var(--accent); }
.cipher-letter .decoded.correct { color: var(--success); border-bottom-color: var(--success); }
.cipher-letter.active .decoded { border-bottom-color: var(--warning); }
.cipher-space { display: inline-block; width: 16px; }

.cipher-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.cipher-key {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--surface);
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
}

.cipher-key:hover { background: var(--card); }
.cipher-key.used { opacity: 0.3; }

/* ── Connections specific ── */
.conn-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.conn-tile {
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 16px 8px;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conn-tile:hover { border-color: rgba(255,255,255,0.3); }
.conn-tile.selected { border-color: var(--accent); background: rgba(233,69,96,0.2); }
.conn-tile.solved { cursor: default; opacity: 0.9; color: #fff; font-weight: 700; }

.conn-solved-group {
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  text-align: center;
}

.conn-solved-group .group-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.conn-solved-group .group-words {
  font-size: 0.95rem;
}

.conn-mistakes {
  text-align: center;
  margin: 12px 0;
  color: var(--text-dim);
}

.conn-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 3px;
}

.conn-dot.used { background: rgba(255,255,255,0.15); }

.conn-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* Group colors */
.group-0 { background: #c9b458; color: #1a1a2e; }
.group-1 { background: #6aaa64; color: #1a1a2e; }
.group-2 { background: #85c0f9; color: #1a1a2e; }
.group-3 { background: #f5793a; color: #1a1a2e; }

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
}

.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  overflow: visible;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 6px;
  z-index: 9999;
}

/* ── Focus Styles ── */
a:focus-visible,
button:focus-visible,
.game-card:focus-visible,
.game-list-item:focus-visible,
.choice-btn:focus-visible,
.set-card:focus-visible,
.conn-tile:focus-visible,
.cipher-key:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Back to Site ── */
.site-back {
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.back-to-site {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.back-to-site:hover { color: var(--text); }

/* ── Footer ── */
.site-footer {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .featured-grid { grid-template-columns: 1fr; }
  .header h1 { font-size: 1.8rem; }
  .set-board { grid-template-columns: repeat(3, 1fr); }
  .conn-board { grid-template-columns: repeat(4, 1fr); }
  .conn-tile { font-size: 0.8rem; padding: 12px 4px; }
}
