:root {
  --bg: #0b0f17;
  --panel: #111827;
  --panel2: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;

  --neutral: #334155;
  --gray: #475569;
  --yellow: #f59e0b;
  --green: #22c55e;

  --gap: 3px;
  --radius: 2px;
  --keyH: 48px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial;
}

* {
  box-sizing: border-box;
}
button,
input {
  font: inherit;
  color: inherit;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* <-- prevent page scroll */
  overscroll-behavior: none; /* <-- prevent bounce */
  touch-action: manipulation;
  background: var(--bg);
  color: var(--text);
}

#root {
  height: 100%;
  min-height: 100%;
  overflow: hidden; /* <-- prevent root scroll */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 9:18 stage that scales but preserves aspect ratio */
.stageWrap {
  width: min(100vw, calc(100vh * 9 / 18));
  height: min(100vh, calc(100vw * 18 / 9));
  aspect-ratio: 9 / 16;
  max-width: 980px; /* allow bigger than 720x1280 */
  max-height: 1742px;
  display: flex;
  padding: 12px;
}

.stage {
  flex: 1;
  border-radius: 2px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* keep content clipped */
}

.topbar {
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: blur(10px);
}

.variantRow {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: nowrap; /* prevent wrapping */
}
.leftRow {
  white-space: nowrap;
  display: flex; /* keeps A B C D in a row */
}
.rightRow {
  margin-left: auto; /* pushes it to the right */
  display: flex; /* keeps A B C D in a row */
  gap: 8px; /* spacing between them */
  white-space: nowrap;
}
.variantBtn {
  flex: 1;
  text-align: center;
  padding: 3px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.7em;
  white-space: nowrap; /* prevent text wrapping */
  flex-wrap: nowrap; /* prevent items wrapping */
}
.variantBtn:active {
  transform: translateY(1px);
}
.variantBtn.selected {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.35);
}

.langRow {
  display: flex;
  gap: var(--gap);
  justify-content: center;
  flex-wrap: nowrap;
}
.langToggle {
  border-radius: 2px;
  padding: 3px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 2px;
}
.langToggle[aria-pressed="false"] {
  opacity: 0.45;
  filter: grayscale(1);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 3px;
  overflow: hidden; /* <-- no scrolling */
}

.body {
  flex: 1;
  background: rgba(17, 24, 39, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 3px;
  overflow: hidden; /* <-- no scrolling */
}

.bottom {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.lookup {
  background: rgba(17, 24, 39, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lookupTop {
  display: flex;
  gap: 10px;
  align-items: center;
}
.lookup input {
  flex: 1;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.65);
  outline: none;
}
.lookup small {
  color: var(--muted);
}
.lookupResults {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}
.defCard {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.45);
  border-radius: 14px;
  padding: 10px 12px;
}
.defCard header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}
.defCard ul {
  margin: 8px 0 0 18px;
  color: #dbeafe;
}

.keyboard {
  background: rgba(17, 24, 39, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px;
}

.kRow {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 4px;
}
.key {
  height: var(--keyH);
  min-width: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  user-select: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.key.wide {
  min-width: 64px;
  padding: 0 14px;
}
.key:active {
  transform: translateY(1px);
}

/* single-color fill (wordle/weaver) */
.key[data-fill="gray"] {
  background: rgba(71, 85, 105, 0.9);
}
.key[data-fill="yellow"] {
  background: rgba(245, 158, 11, 0.9);
}
.key[data-fill="green"] {
  background: rgba(34, 197, 94, 0.9);
}

/* quordle quadrants */
.keyQuad {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.keyQuad i {
  position: absolute;
  width: 50%;
  height: 50%;
}
.keyQuad .ul {
  left: 0;
  top: 0;
}
.keyQuad .ur {
  right: 0;
  top: 0;
}
.keyQuad .ll {
  left: 0;
  bottom: 0;
}
.keyQuad .lr {
  right: 0;
  bottom: 0;
}
.key > span {
  position: relative;
  z-index: 1;
}

/* boards */
.boardsGrid1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.boardsGrid4 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.board {
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  padding: 10px;
}
.boardTitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}
.grid {
  display: grid;
  gap: 5px;
}
.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}
.cell {
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  user-select: none;
}

/* Active row stays square (the "last guess" / current row) */
.row.active .cell {
  aspect-ratio: 1 / 1;
  font-size: 16px;
}

/* Older rows are squashed (still readable, but compact) */
.row.compact .cell {
  aspect-ratio: auto;
  height: 18px;
  font-size: 10px;
  border-radius: 6px;
}
.cell[data-s="gray"] {
  background: rgba(71, 85, 105, 0.75);
}
.cell[data-s="yellow"] {
  background: rgba(245, 158, 11, 0.75);
}
.cell[data-s="green"] {
  background: rgba(34, 197, 94, 0.75);
}

.weaverTop {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 800;
}
.path {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.45);
}
.step small {
  color: var(--muted);
}
/* Add to your styles.css */
@keyframes blink-animation {
  50% {
    opacity: 0.2;
  }
}
.cell[data-s="hint"] {
  animation: blink-animation 1s step-end infinite;
}
.hint-box-inline {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}
.word-hint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  overflow-y: auto;
}
.word-hint-item {
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
  font-weight: bold;
}
.word-hint-item:hover {
  background: rgba(255, 255, 255, 0.1);
}
.word-hint-item.selected {
  background: rgba(59, 130, 246, 0.3);
  border: 1px solid rgba(59, 130, 246, 0.8);
}
.key-hint {
  animation: pulse-zoom 1.5s infinite;
  z-index: 10;
}
@keyframes pulse-zoom {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(59, 130, 246, 0);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* BOGGLE */
/* --- Boggle --- */
/* --- Boggle --- */
.boggleTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.boggleBtns {
  display: flex;
  gap: 10px;
}

.miniBtn {
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-weight: 800;
}
.miniBtn:active {
  transform: translateY(1px);
}

.swipeWord {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.swipeWord .pill {
  min-width: 160px;
  text-align: center;
}

/* Commit + Cancel row */
.commitRow {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}
.commitBtn {
  height: 42px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.2);
  cursor: pointer;
  font-weight: 950;
}
.commitBtn:active {
  transform: translateY(1px);
}

.boggleStats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.langStat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.langStatRight {
  display: flex;
  gap: 10px;
}

/* board with gaps so diagonal swipe isn’t sticky */
.boggleBoard {
  display: grid;
  gap: 10px;
  align-content: start;
  touch-action: none; /* allow pointer swipes */
}

/* outlined tiles */
.tile {
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px solid rgba(147, 197, 253, 0.45);
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-size: px;*/
  font-weight: 950;
  letter-spacing: 0.5px;
  user-select: none;
  transition:
    transform 80ms ease,
    background 120ms ease,
    border-color 120ms ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  user-select: none;
  -webkit-user-select: none;
}

.tile.sel {
  border-color: rgba(59, 130, 246, 0.95);
  background: rgba(59, 130, 246, 0.22);
}
.tile.validNew {
  border-color: rgba(34, 197, 94, 0.95);
  background: rgba(34, 197, 94, 0.18);
}
.tile.validOld {
  border-color: rgba(245, 158, 11, 0.95);
  background: rgba(245, 158, 11, 0.18);
}

/* subtle drag effect */
.tile.dragFX {
  transform: scale(1.04);
  animation: bgl-shake 140ms linear infinite;
}
@keyframes bgl-shake {
  0% {
    transform: scale(1.04) translate(0, 0);
  }
  25% {
    transform: scale(1.04) translate(0.6px, -0.4px);
  }
  50% {
    transform: scale(1.04) translate(-0.4px, 0.6px);
  }
  75% {
    transform: scale(1.04) translate(0.4px, 0.2px);
  }
  100% {
    transform: scale(1.04) translate(0, 0);
  }
}

/* soft hint pulse */
.tile.hintPulse {
  border-color: rgba(167, 139, 250, 0.95);
  background: rgba(167, 139, 250, 0.22);
  transform: scale(1.06);
}

/* overlay */
.stage {
  position: relative;
}

.overlayBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.overlayPanel {
  width: min(520px, 92vw);
  max-height: min(70vh, 720px);
  background: rgba(17, 24, 39, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.overlayHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.overlayTitle {
  font-weight: 950;
  letter-spacing: 0.2px;
}
.overlayClose {
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-weight: 900;
}

.overlayToggles {
  padding: 10px 12px;
  display: flex;
  gap: 10px;
}
.toggleBtn {
  flex: 1;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-weight: 900;
}
.toggleBtn.on {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.18);
}

.overlayList {
  padding: 10px 12px 14px;
  overflow: auto; /* internal only */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.wordItem {
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 23, 42, 0.55);
  font-weight: 900;
}
.wordItem.found {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.16);
}
.wordItem.remaining {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.14);
}
/* slower soft-hint highlight that lingers */
.tile.hintHold {
  border-color: rgba(167, 139, 250, 0.95);
  background: rgba(167, 139, 250, 0.22);
  transform: scale(1.05);
  transition:
    background 650ms ease,
    border-color 650ms ease,
    transform 250ms ease;
}

.wordRow {
  color: white;
  background-color: rgba(59, 130, 246, 0.3);
}

.langChip {
  color: white;
  background-color: rgba(59, 130, 246, 0.3);
}
