/* Wordle — bright Baithak theme (game tiles keep their green/yellow/gray states) */
:root {
  --bg0: #fff8e7;
  --bg1: #ffefd9;
  --gold: #ffb020;
  --gold-light: #ffd166;
  --gold-deep: #c77e00;
  --text: #3a2c1c;
  --text-dim: #8a755c;
  --tile-bg: #fffdf8;
  --tile-border: #d8c9a8;
  --tile-active: #ffb020;
  --correct: #22c55e;
  --present: #f5c518;
  --absent: #2a3342;
  --key-bg: #e9ddc6;
  --radius: 10px;
}
body[data-bgfx="wordle"] { --accent: #3fd97a; --accent-2: #f5c518; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  /* page background comes from shared baithak.css (bright gradient) */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
  overscroll-behavior: none;
  user-select: none;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 2px solid rgba(255, 176, 32, .35);
}
.h-side { flex: 1; display: flex; }
.h-right { justify-content: flex-end; gap: 6px; }
.logo {
  margin: 0;
  font-family: 'Baloo 2', system-ui, sans-serif;
  font-size: 26px;
  letter-spacing: 10px;
  text-indent: 10px;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(255, 176, 32, .45);
  font-weight: 800;
}
.back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 6px;
}
.back:active { color: var(--gold); }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 176, 32, .5);
  background: rgba(255, 176, 32, .10);
  color: var(--gold);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.icon-btn:active { transform: scale(.92); background: rgba(255, 176, 32, .22); }

/* ---------- mode bar ---------- */
.modebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 12px 0;
  min-height: 34px;
}
.mode-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: .4px;
}
.mode-label b { color: var(--gold-light); }
.new-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #3a2400;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--gold-deep);
}
.new-btn:active { transform: translateY(2px); box-shadow: none; }
.hidden { display: none !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(43, 32, 20, .95);
  border: 1px solid rgba(255, 176, 32, .5);
  color: #fffdf8;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
  white-space: nowrap;
  max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- board ---------- */
.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  min-height: 0;
}
.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
}
.brow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile {
  width: min(14.5vw, 62px, 9dvh);
  height: min(14.5vw, 62px, 9dvh);
  border: 2px solid var(--tile-border);
  background: var(--tile-bg);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(8vw, 32px);
  font-weight: 800;
  text-transform: uppercase;
  perspective: 200px;
}
.tile.filled { border-color: var(--gold); animation: pop .12s; }
.tile.correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.tile.present { background: var(--present); border-color: var(--present); color: #fff; }
.tile.absent { background: var(--absent); border-color: var(--absent); color: #fff; }
.tile.flip { animation: flip .6s ease-in-out; }
.tile.shake { animation: shake .5s; }
.tile.win-bounce { animation: bounce .55s; }

@keyframes pop {
  0% { transform: scale(.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-16px); }
  70% { transform: translateY(0); }
  85% { transform: translateY(-7px); }
}

/* ---------- keyboard ---------- */
.keyboard {
  padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.krow { display: flex; gap: 5px; }
.key {
  flex: 1 1 0;
  min-width: 0;
  height: 56px;
  border: 0;
  border-radius: 7px;
  background: var(--key-bg);
  color: #3a2c1c;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
}
.key.wide { flex: 1.55 1 0; font-size: 12px; }
.key { transition: transform .08s ease, filter .08s ease; }
.key:active { filter: brightness(1.25); transform: scale(.93); }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent { background: var(--absent); color: #c9c9dd; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(58, 44, 28, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 18px;
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; } }
.modal-card {
  position: relative;
  width: min(92vw, 380px);
  max-height: 84dvh;
  overflow-y: auto;
  background: #fffdf8;
  border: 2px solid #eadfc8;
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 18px 60px rgba(120, 80, 20, .25), 0 0 30px rgba(255, 176, 32, .15);
}
.modal-x {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  color: var(--text-dim);
  font-size: 26px;
  cursor: pointer;
  padding: 6px;
}
.modal-card h2 { margin: 0 0 4px; color: #3a2c1c; font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800; font-size: 22px; }
.modal-card p { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin: 8px 0; }
.modal-card .ex-row { display: flex; gap: 5px; margin: 6px 0 2px; }
.mini-tile {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--tile-border); border-radius: 7px;
  font-weight: 800; font-size: 18px; text-transform: uppercase;
}
.mini-tile.correct { background: var(--correct); border-color: var(--correct); }
.mini-tile.present { background: var(--present); border-color: var(--present); }
.mini-tile.absent { background: var(--absent); border-color: var(--absent); }

/* stats */
.stat-row { display: flex; justify-content: space-around; margin: 14px 0 6px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 900; color: var(--gold-light); }
.stat-lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.dist { margin-top: 12px; }
.dist-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; font-weight: 700; }
.dist-num { width: 12px; color: var(--text-dim); }
.dist-bar {
  min-width: 24px;
  padding: 4px 8px;
  border-radius: 4px;
  background: #4a3f8f;
  color: #fff;
  text-align: right;
}
.dist-bar.best { background: var(--correct); }
.share-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 999px;
  padding: 13px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  color: #3a2400;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--gold-deep);
  font-family: inherit;
}
.share-btn:active { transform: translateY(3px); box-shadow: none; }
.end-word {
  text-align: center;
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 6px;
}
.end-word b { color: var(--gold-light); letter-spacing: 3px; font-size: 20px; }
.countdown { text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 10px; }
.countdown b { color: var(--text); font-size: 18px; display: block; }

@media (max-height: 640px) {
  .tile { width: min(13vw, 54px); height: min(13vw, 54px); font-size: 26px; }
  .key { height: 48px; }
  .logo { font-size: 21px; }
}

/* ---------- Baithak bright theme accents: wordle ---------- */
/* glowing logo pulse */
.logo { animation: logo-glow 3.4s ease-in-out infinite; }
@keyframes logo-glow {
  0%, 100% { text-shadow: 0 2px 12px rgba(255, 176, 32, .45); }
  50% { text-shadow: 0 2px 24px rgba(255, 176, 32, .8); }
}
/* filled tiles carry a soft gold halo */
.tile.filled { box-shadow: 0 0 12px rgba(255, 176, 32, .28); }
@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
  .key { transition: none; }
}
