:root {
  --bg: #0d1117;
  --panel: #151b23;
  --border: #2a323d;
  --border-lit: #3d4b5c;
  --text: #e6edf3;
  --dim: #7d8a99;
  --amber: #e3a04f;
  --amber-dim: #8a6a3d;
  --danger: #c9695f;
  --ok: #5fb88f;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  overflow-x: hidden;
  /* prevent iOS bounce/selection weirdness when installed as an app */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.mono {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px 0;
  max-width: 100vw;
  overflow: hidden;
}

#scroll-area {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(200px + env(safe-area-inset-bottom));
}

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

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--amber);
  margin-bottom: 6px;
}

h1 {
  font-family: "JetBrains Mono", monospace;
  font-size: 30px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 1px;
}

h1 .accent {
  color: var(--amber);
}

.subtitle {
  font-size: 13px;
  color: var(--dim);
  margin-top: 6px;
  max-width: 340px;
}

.puzzle-number {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--amber);
  margin-top: 8px;
  letter-spacing: 0.5px;
}

#board-wrap {
  margin-top: 14px;
}

.mode-toggle {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px;
}

.mode-btn {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--dim);
}

.mode-btn.active {
  background: var(--amber);
  color: var(--bg);
}

.mode-btn:disabled {
  cursor: not-allowed;
}

.mode-btn:disabled:not(.active) {
  opacity: 0.4;
}

.lock-msg {
  display: none;
  font-size: 10px;
  color: var(--dim);
  margin-top: 4px;
  text-align: center;
}

.hint-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}

.hint-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.hint-tiles {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.hint-tile {
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--danger);
}

.hint-tile.revealed {
  border-color: var(--danger);
  background: rgba(201, 105, 95, 0.12);
}

.btn-hint {
  padding: 7px 18px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--danger);
  background: transparent;
  border: 1.5px solid var(--danger);
  border-radius: 4px;
  cursor: pointer;
}

.btn-hint:disabled {
  color: var(--dim);
  border-color: var(--border);
  cursor: not-allowed;
}

@keyframes popin {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.popin {
  animation: popin 0.25s ease;
}

#board {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.row.shake {
  animation: shake 0.3s ease;
}

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

.tiles {
  display: flex;
  gap: 6px;
}

.tile {
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.tile.filled {
  border-color: var(--border-lit);
}

.tile.locked {
  background: var(--panel);
}

.tile.eliminated {
  background: #e3a04f;
  border-color: #e3a04f;
  color: #111111;
}

.peg-cluster {
  width: 34px;
  height: 46px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  align-content: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  padding: 6px;
}

.peg {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-sizing: border-box;
}

.peg-black {
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber-dim);
}

.peg-white {
  background: var(--text);
  border: 1.5px solid var(--text);
}

.peg-empty {
  border: 1.5px dashed var(--border);
}

#flash {
  height: 24px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
}

#playing-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
}

button {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  padding: 10px 28px;
}

.btn-primary {
  color: var(--bg);
  background: var(--amber);
}

.btn-primary:disabled {
  color: var(--dim);
  background: var(--border);
  cursor: not-allowed;
}

.btn-secondary {
  color: var(--text);
  background: transparent;
  border: 1.5px solid var(--border-lit);
  padding: 10px 22px;
}

#guess-count {
  font-size: 12px;
  color: var(--dim);
  margin-top: 10px;
}

.hint {
  font-size: 12px;
  color: var(--dim);
  margin-top: 4px;
}

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  width: 100%;
}

.key {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 0;
  min-width: 0;
  height: 46px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.key:active {
  background: var(--border-lit);
}

.key-wide {
  flex: 1.6 1 0;
  font-size: 10px;
  letter-spacing: 0.3px;
  color: var(--amber);
}

.kb-spacer {
  flex: 0.5 1 0;
}

@media (max-width: 360px) {
  .key {
    height: 42px;
    font-size: 12px;
  }
  .key-wide {
    font-size: 9px;
  }
  .kb-row {
    gap: 3px;
  }
}

#game-over {
  display: none;
  flex-direction: column;
  align-items: center;
  margin-top: 10px;
  text-align: center;
}

#result-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

#result-word {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 6px;
}

#stats-line {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 14px;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

@keyframes popin {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.row .peg-cluster {
  animation: none;
}

#site-footer {
  margin-top: auto;
  padding-top: 32px;
  font-size: 11px;
  color: var(--dim);
  text-align: center;
}

#site-footer a {
  color: var(--dim);
  text-decoration: none;
}

#site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-sep {
  margin: 0 6px;
}
