/* Letter Boxed Game - WordPress plugin styles
   Everything is scoped under .lbx-root so it cannot leak into the theme. */

.lbx-root {
  --lbx-bg: #FF9EB1;
  --lbx-surface: #ffffff;
  --lbx-ink: #000000;
  --lbx-ink-soft: #000000;
  --lbx-border: #ffffff;
  --lbx-line-inactive: rgba(0, 0, 0, 0.28);
  --lbx-line-active: #d6336c;
  --lbx-accent: #3b6bf5;
  --lbx-accent-ink: #ffffff;
  --lbx-danger: #d64545;
  --lbx-success: #2e8b57;
  --lbx-pill-bg: #ffc2cf;
  --lbx-node-bg: #ffffff;
  --lbx-node-active-bg: #3b6bf5;
  --lbx-node-active-ink: #ffffff;
  --lbx-btn-bg: #d6336c;
  --lbx-btn-ink: #ffffff;
  --lbx-shadow: 0 1px 3px rgba(0,0,0,0.08);
  color-scheme: light;

  box-sizing: border-box;
  background: var(--lbx-bg);
  color: var(--lbx-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-bottom: 30px;
  overflow: hidden;
  line-height: normal;
}

.lbx-root[data-lbx-theme="dark"] {
  --lbx-bg: #17181a;
  --lbx-surface: #222327;
  --lbx-ink: #f0efec;
  --lbx-ink-soft: #a8a6a1;
  --lbx-border: #f0efec;
  --lbx-line-inactive: rgba(0, 0, 0, 0.3);
  --lbx-line-active: #d6336c;
  --lbx-accent: #6f89ff;
  --lbx-accent-ink: #101114;
  --lbx-pill-bg: #2b2c30;
  --lbx-node-bg: #222327;
  --lbx-node-active-bg: #6f89ff;
  --lbx-node-active-ink: #ffffff;
  --lbx-btn-bg: #d6336c;
  --lbx-btn-ink: #ffffff;
  --lbx-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.lbx-root, .lbx-root * {
  box-sizing: border-box;
}

/* Reset theme styles that would otherwise leak in and break spacing.
   WordPress themes routinely ship rules like ".single-content p" whose
   specificity beats a plain class selector, so this reset uses !important
   on BARE element selectors (specificity 0,0,1) — deliberately lower than
   any of our own .lbx-* component classes (0,1,0), so every specific rule
   further down the file wins the cascade without needing !important itself. */
:where(.lbx-root) p,
:where(.lbx-root) h1,
:where(.lbx-root) h2,
:where(.lbx-root) h3,
:where(.lbx-root) ul,
:where(.lbx-root) ol,
:where(.lbx-root) li,
:where(.lbx-root) div,
:where(.lbx-root) span,
:where(.lbx-root) svg {
  margin: 0 !important;
  padding: 0 !important;
  line-height: normal !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  float: none !important;
  text-indent: 0 !important;
}

:where(.lbx-root) button {
  margin: 0 !important;
  line-height: normal !important;
  text-transform: none !important;
  min-height: 0 !important;
  min-width: 0 !important;
  width: auto !important;
  height: auto !important;
  box-shadow: none !important;
  text-decoration: none !important;
  letter-spacing: normal !important;
  text-shadow: none !important;
}

.lbx-topbar {
  background: #ffffff !important;
  flex: 0 0 auto;
}

.lbx-topbar-inner {
  max-width: 540px !important;
  margin: 0 auto !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 6px !important;
  padding: 10px 16px !important;
}

@media (max-width: 480px) {
  .lbx-topbar-inner {
    flex-direction: column;
    justify-content: center;
  }
}

.lbx-brand {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.15rem;
  margin: 0 !important;
  letter-spacing: 0.3px !important;
  color: #1a1a1a;
}

.lbx-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lbx-topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--lbx-line-inactive);
  margin: 0 4px !important;
}

.lbx-icon-btn {
  background: none;
  border: none;
  color: #1a1a1a;
  cursor: pointer;
  padding: 8px !important;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  line-height: 0 !important;
}
.lbx-icon-btn svg { fill: none; stroke: currentColor; }
.lbx-icon-btn svg rect { fill: currentColor; stroke: none; }
.lbx-icon-btn:hover { background: var(--lbx-pill-bg); }

.lbx-mode-btn {
  background: none;
  border: none;
  color: #1a1a1a;
  cursor: pointer;
  padding: 7px 13px !important;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px !important;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.lbx-mode-btn:hover { background: #ffc2cf; }
.lbx-mode-btn.lbx-active { background: #d6336c; color: #ffffff; }
.lbx-mode-btn.lbx-active:hover { background: #d6336c; }

.lbx-game-wrap {
  max-width: 540px !important;
  margin: 0 auto !important;
  padding: 10px 16px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
}

.lbx-status-row {
  position: relative;
  display: flex;
  margin: 0 0 20px !important;
  padding: 0 !important;
  width: 100%;
  justify-content: center;
  min-height: 1.3em;
}

.lbx-instruction-line {
  margin: 0 !important;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--lbx-ink-soft);
  text-align: center;
  transition: opacity 0.15s;
}
.lbx-instruction-line.lbx-hidden {
  opacity: 0;
}

.lbx-board-area {
  position: relative;
  width: 100%;
  max-width: 320px !important;
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px !important;
}

.lbx-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.lbx-board {
  position: absolute;
  inset: 12%;
  border: 3px solid #000000;
  border-radius: 4px;
  background: #FF6B8A;
}

.lbx-letter-node {
  position: absolute;
  width: 34px;
  height: 34px;
  margin-left: -17px !important;
  margin-top: -17px !important;
  cursor: pointer;
  user-select: none;
  z-index: 2;
}

/* enlarged, invisible hit area covering both the dot and its floating label,
   so taps on the letter text (not just the tiny dot) register correctly */
.lbx-node-hitarea {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

/* the small clickable dot sitting directly on the square's edge */
.lbx-node-dot {
  position: absolute;
  inset: 0;
  margin: auto !important;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: none;
  transition: background 0.12s, transform 0.1s;
}

.lbx-letter-node.lbx-active .lbx-node-dot {
  background: var(--lbx-node-active-bg);
  transform: scale(1.35);
}

.lbx-letter-node.lbx-used .lbx-node-dot {
  background: var(--lbx-success);
}

/* the floating letter label, offset outward from the dot */
.lbx-node-label {
  position: absolute;
  font-size: 1rem;
  font-weight: 700;
  color: var(--lbx-ink);
  line-height: 1 !important;
  white-space: nowrap;
  pointer-events: none;
}

.lbx-node-label-up {
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
}
.lbx-node-label-down {
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
}
.lbx-node-label-left {
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}
.lbx-node-label-right {
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
}

.lbx-letter-node.lbx-active .lbx-node-label {
  color: var(--lbx-node-active-bg);
}

.lbx-current-word-row {
  min-height: 30px;
  margin: 8px 0 16px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lbx-current-word {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px !important;
  min-width: 1em;
  text-align: center;
  color: var(--lbx-ink);
}

.lbx-current-word.lbx-shake {
  animation: lbx-shake 0.35s;
  color: var(--lbx-danger);
}

@keyframes lbx-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.lbx-controls-row {
  display: flex;
  gap: 10px;
  margin: 0 !important;
  padding-top: 0 !important;
}

.lbx-ctrl-btn {
  background: var(--lbx-btn-bg);
  border: 2px solid var(--lbx-btn-bg);
  color: var(--lbx-btn-ink);
  padding: 6px 14px !important;
  border-radius: 18px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.lbx-ctrl-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.lbx-ctrl-btn:not(:disabled):active {
  transform: scale(0.96);
}
.lbx-ctrl-btn.lbx-primary {
  background: var(--lbx-btn-bg);
  border-color: var(--lbx-btn-bg);
  color: var(--lbx-btn-ink);
}

.lbx-wordlist-wrap {
  width: 100%;
  max-width: 420px !important;
  min-height: 0;
  margin: 0 0 16px !important;
  padding: 0 !important;
}

.lbx-wordlist-title {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: none !important;
  letter-spacing: normal !important;
  color: var(--lbx-ink-soft);
  text-align: center;
  margin: 0 0 10px !important;
}

.lbx-word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.lbx-word-pill {
  background: var(--lbx-surface);
  color: var(--lbx-ink);
  padding: 6px 15px !important;
  border-radius: 999px;
  font-weight: 400;
  font-size: 0.85rem;
  letter-spacing: 0.5px !important;
  animation: lbx-pop-in 0.2s ease;
}

@keyframes lbx-pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.lbx-letters-used-line {
  margin: 0 0 20px !important;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--lbx-ink-soft);
  text-align: center;
}
.lbx-letters-used-line span { color: var(--lbx-ink); }

.lbx-message-banner {
  position: absolute;
  inset: 0;
  margin: 0 !important;
  color: var(--lbx-btn-bg);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 5;
}
.lbx-message-banner.lbx-show {
  opacity: 1;
}

/* Modals */
.lbx-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px !important;
}
.lbx-modal-overlay.lbx-show { display: flex; }

.lbx-modal {
  background: var(--lbx-surface);
  color: var(--lbx-ink);
  border-radius: 16px;
  padding: 28px 24px !important;
  max-width: 400px !important;
  width: 100%;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.lbx-modal h2 {
  margin-top: 0 !important;
  margin-bottom: 0.5em !important;
  font-family: Georgia, serif;
  color: var(--lbx-ink);
  font-size: 1.4rem;
  line-height: 1.3 !important;
}

.lbx-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--lbx-ink-soft);
  line-height: 1 !important;
  padding: 4px !important;
}

.lbx-rules-list {
  padding-left: 20px !important;
  line-height: 1.6 !important;
  margin: 0 !important;
  color: var(--lbx-ink);
}
.lbx-rules-list li { margin-bottom: 10px !important; }

.lbx-example-block {
  background: var(--lbx-pill-bg);
  border-radius: 10px;
  padding: 14px !important;
  margin: 16px 0 !important;
  text-align: center;
}
.lbx-example-title {
  font-size: 0.75rem;
  text-transform: uppercase !important;
  color: var(--lbx-ink-soft);
  letter-spacing: 1px !important;
  margin-bottom: 6px !important;
}
.lbx-example-chain {
  font-weight: 700;
  letter-spacing: 1px !important;
  color: var(--lbx-ink);
}
.lbx-example-chain .lbx-arrow { color: var(--lbx-accent); margin: 0 4px !important; }

.lbx-modal-ok { width: 100% !important; margin-top: 6px !important; }

.lbx-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px !important;
}
.lbx-stat-box {
  background: var(--lbx-pill-bg);
  border-radius: 12px;
  padding: 16px !important;
  text-align: center;
}
.lbx-stat-num {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--lbx-ink);
}
.lbx-stat-label {
  font-size: 0.75rem;
  color: var(--lbx-ink-soft);
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  margin-top: 4px !important;
}

.lbx-stats-solved-wrap {
  margin-top: 20px !important;
  text-align: center;
}

.lbx-win-modal { text-align: center; }
.lbx-win-sub { color: var(--lbx-ink-soft); margin-top: -8px !important; }
.lbx-win-chain {
  background: var(--lbx-pill-bg);
  border-radius: 10px;
  padding: 14px !important;
  margin: 16px 0 !important;
  font-weight: 700;
  letter-spacing: 1px !important;
  line-height: 1.8 !important;
  color: var(--lbx-ink);
}
.lbx-win-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 400px) {
  .lbx-letter-node { width: 30px; height: 30px; margin-left: -15px !important; margin-top: -15px !important; }
  .lbx-node-dot { width: 12px; height: 12px; }
  .lbx-node-label { font-size: 0.9rem; }
  .lbx-ctrl-btn { padding: 6px 12px !important; font-size: 0.75rem; }
  .lbx-brand { font-size: 1.05rem; }
  .lbx-icon-btn { padding: 6px !important; }
  .lbx-icon-btn svg { width: 19px; height: 19px; }
  .lbx-mode-btn { padding: 6px 10px !important; font-size: 0.72rem; }
  .lbx-topbar-divider { display: none; }
}

@media (max-width: 340px) {
  .lbx-controls-row { gap: 6px; }
  .lbx-ctrl-btn { padding: 6px 10px !important; font-size: 0.75rem; }
  .lbx-node-dot { width: 10px; height: 10px; }
  .lbx-node-label { font-size: 0.82rem; }
  .lbx-topbar-actions { gap: 2px; }
  .lbx-icon-btn { padding: 5px !important; }
  .lbx-icon-btn svg { width: 17px; height: 17px; }
  .lbx-mode-btn { padding: 5px 8px !important; font-size: 0.68rem; }
}

/* Shrink the game to fit short viewports without scrolling.
   The letter labels float outside the board square by design, so the
   node/dot/label sizes must shrink in step with the board — otherwise
   a smaller board with full-size labels lets them poke into the text
   above/below and everything visually collides. */
@media (max-height: 750px) {
  .lbx-topbar-inner { padding: 8px 16px !important; }
  .lbx-board-area { max-width: 230px !important; margin-bottom: 8px !important; }
  .lbx-letter-node { width: 28px; height: 28px; margin-left: -14px !important; margin-top: -14px !important; }
  .lbx-node-hitarea { width: 52px; height: 52px; }
  .lbx-node-dot { width: 12px; height: 12px; }
  .lbx-node-label { font-size: 0.85rem; }
  .lbx-current-word-row { margin: 5px 0 8px !important; min-height: 22px; }
  .lbx-current-word { font-size: 1.1rem; }
  .lbx-wordlist-wrap { margin-bottom: 8px !important; }
  .lbx-wordlist-title { margin-bottom: 6px !important; }
  .lbx-ctrl-btn { padding: 6px 13px !important; }
}

@media (max-height: 620px) {
  .lbx-brand { font-size: 1rem; }
  .lbx-board-area { max-width: 190px !important; margin-bottom: 8px !important; }
  .lbx-letter-node { width: 22px; height: 22px; margin-left: -11px !important; margin-top: -11px !important; }
  .lbx-node-hitarea { width: 40px; height: 40px; }
  .lbx-node-dot { width: 9px; height: 9px; }
  .lbx-node-label { font-size: 0.72rem; }
  .lbx-instruction-line { font-size: 0.8rem; }
  .lbx-word-pill { padding: 4px 10px !important; font-size: 0.75rem; }
}

/* Desktop: more breathing room between the current-word display and the
   board (this plugin's markup places the word display above the board,
   unlike the main game where it sits below), and above the "Words:" section. */
@media (min-width: 768px) {
  .lbx-current-word-row { margin-bottom: 19px !important; }
  .lbx-wordlist-wrap { margin-top: 12px !important; }
}
