/* Guess Word — Zantatech Solutions (Poppins, brand accents, daily toast) */

:root {
  --bg: #020617;
  --text: #f8fafc;
  --muted: #94a3b8;
  --tile-border: #334155;
  --tile-bg: #020617;
  --keyboard-bg: #1e293b;
  --key-bg: #334155;
  --key-bg-active: #475569;
  --score-correct: #22c55e;
  --score-present: #eab308;
  --score-dud: #475569;
  --brand: #38bdf8;
  --brand-dim: rgba(56, 189, 248, 0.12);
  --brand-strong: #0ea5e9;
  --nav-height: 56px;
  --radius-lg: 14px;
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
}

body.light-mode {
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --tile-border: #cbd5e1;
  --tile-bg: #ffffff;
  --keyboard-bg: #e2e8f0;
  --key-bg: #cbd5e1;
  --key-bg-active: #94a3b8;
  --score-dud: #94a3b8;
  --brand: #0284c7;
  --brand-dim: rgba(2, 132, 199, 0.1);
  --brand-strong: #0369a1;
  --shadow-soft: 0 4px 24px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  height: -webkit-fill-available;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.keyboard-open {
  overflow: auto;
}

.app {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  width: 100%;
}

/* Top nav — pinned (outside scroll area) */
.top-nav {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: var(--nav-height);
  padding: 6px 8px;
  padding-top: max(6px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--tile-border);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, rgba(56, 189, 248, 0.06) 0%, transparent 100%);
  flex-shrink: 0;
  z-index: 10;
}

body.light-mode .top-nav {
  background-color: var(--bg);
  background-image: linear-gradient(180deg, rgba(2, 132, 199, 0.06) 0%, transparent 100%);
}

.nav-brand {
  text-align: center;
  min-width: 0;
  padding: 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.nav-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-strong);
  background: var(--brand-dim);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.nav-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--keyboard-bg);
}

body.light-mode .nav-btn:hover {
  background: var(--key-bg);
}

/* Daily toast (after lunch reminder) */
.daily-toast {
  position: fixed;
  top: var(--nav-height);
  left: 12px;
  right: 12px;
  z-index: 60;
  max-width: 440px;
  margin: 10px auto 0;
  animation: toast-in 0.35s ease-out;
  flex: none;
  height: 0;
  min-height: 0;
  overflow: visible;
  pointer-events: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.daily-toast-inner {
  pointer-events: auto;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--tile-border);
  border-left: 3px solid var(--brand);
  background: var(--keyboard-bg);
  box-shadow: var(--shadow-soft), 0 0 0 1px var(--brand-dim);
  backdrop-filter: blur(12px);
}

body.light-mode .daily-toast-inner {
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.daily-toast-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.daily-toast-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-strong);
  background: var(--brand-dim);
  padding: 4px 8px;
  border-radius: 6px;
}

.daily-toast-brand {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.daily-toast-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.daily-toast-msg {
  margin: 0 0 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.daily-toast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-toast {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}

.btn-toast.primary {
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
  color: #020617;
}

body.light-mode .btn-toast.primary {
  color: #fff;
}

.btn-toast.secondary {
  background: var(--key-bg);
  color: var(--text);
  border: 1px solid var(--tile-border);
}

.btn-toast:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Scrolls main content between header and footer */
.app-scroll {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* Main content block inside .app-scroll */
.main {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px 16px;
}

.difficulty {
  margin-bottom: 10px;
}

.difficulty-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.diff-btn {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.diff-btn.active {
  color: var(--text);
  border-color: var(--brand);
  background: var(--brand-dim);
  box-shadow: 0 0 0 1px var(--brand-dim);
}

body.light-mode .diff-btn.active {
  background: var(--brand-dim);
}

/* Reset — separate from difficulty; own row, distinct control */
.game-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.btn-reset-standalone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 18px;
  border: 1px solid var(--tile-border);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.08) 0%, transparent 120%);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn-reset-standalone:hover {
  color: var(--text);
  border-color: var(--brand);
  background: var(--brand-dim);
}

.btn-reset-standalone:active {
  transform: scale(0.98);
}

.btn-reset-icon {
  flex-shrink: 0;
  opacity: 0.85;
}

body.light-mode .btn-reset-standalone {
  background: linear-gradient(180deg, rgba(2, 132, 199, 0.06) 0%, transparent 120%);
}

.btn-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 16px;
  border: 1px solid rgba(234, 179, 8, 0.5);
  border-radius: 10px;
  background: rgba(234, 179, 8, 0.14);
  color: #facc15;
  cursor: pointer;
}

.btn-hint:hover:not(:disabled) {
  background: rgba(234, 179, 8, 0.2);
}

.btn-hint:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

body.light-mode .btn-hint {
  color: #a16207;
  background: rgba(234, 179, 8, 0.22);
}

.btn-hint-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(234, 179, 8, 0.5);
  border-radius: 10px;
  background: rgba(234, 179, 8, 0.14);
  color: #facc15;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-hint-inline[hidden] {
  display: none !important;
}

.btn-hint-inline:hover:not(:disabled) {
  background: rgba(234, 179, 8, 0.2);
}

.btn-hint-inline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

body.light-mode .btn-hint-inline {
  color: #a16207;
  background: rgba(234, 179, 8, 0.22);
}

.status {
  min-height: 1.25em;
  margin: 0 0 6px;
  font-size: 0.85rem;
  text-align: center;
  color: var(--muted);
}

.status.error {
  color: #f87171;
}

.status.win {
  color: #4ade80;
}

body.light-mode .status.error {
  color: #dc2626;
}

body.light-mode .status.win {
  color: #16a34a;
}

.tries-line {
  margin: 0 0 16px;
  font-size: 0.8rem;
  text-align: center;
  color: var(--muted);
}

.tries-line strong {
  color: var(--text);
}

.tries-line-bottom {
  margin-top: 4px;
}

.hint-bottom-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.hint-note {
  min-height: 1.2em;
  margin: -4px 0 12px;
  text-align: center;
  font-size: 0.82rem;
  color: #facc15;
}

body.light-mode .hint-note {
  color: #a16207;
}

/* Board rows */
.board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.guess-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.guess-row .tiles {
  display: flex;
  gap: 6px;
}

.tile {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  background: var(--tile-bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body.light-mode .tile {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

@media (min-width: 400px) {
  .tile {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}

.guess-row.hard .tile {
  width: 36px;
  height: 40px;
  font-size: 0.95rem;
}

@media (min-width: 400px) {
  .guess-row.hard .tile {
    width: 38px;
    height: 42px;
    font-size: 1rem;
  }
}

/* Per-letter clue colors (same logic as green/yellow counts) */
.guess-row:not(.current) .tile--correct {
  background: var(--score-correct);
  border-color: rgba(34, 197, 94, 0.65);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.35);
}

.guess-row:not(.current) .tile--present {
  background: var(--score-present);
  border-color: rgba(202, 138, 4, 0.55);
  color: #1c1504;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}

body.light-mode .guess-row:not(.current) .tile--present {
  color: #422006;
  border-color: rgba(161, 98, 7, 0.45);
}

.guess-row:not(.current) .tile--absent {
  background: var(--key-bg);
  border-color: var(--tile-border);
  color: var(--muted);
  opacity: 0.92;
}

body.light-mode .guess-row:not(.current) .tile--absent {
  background: #e2e8f0;
  color: #64748b;
}

.score-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

/* Keeps current guess row centered like completed rows (tiles + dot column). */
.score-dots--pending {
  pointer-events: none;
  flex-shrink: 0;
}

.score-dot--placeholder {
  visibility: hidden;
}

.score-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.score-dot.correct {
  background: var(--score-correct);
}

.score-dot.present {
  background: var(--score-present);
}

.score-dot.dud {
  background: var(--score-dud);
  color: rgba(255, 255, 255, 0.9);
}

body.light-mode .score-dot.dud {
  color: #fff;
}

.current-row-wrap {
  margin-bottom: 16px;
}

.game-result {
  margin-top: 6px;
  padding: 14px;
  border: 1px solid var(--tile-border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--brand-dim) 0%, transparent 130%);
  text-align: center;
}

.game-result-text {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-result-text strong {
  color: var(--text);
  letter-spacing: 0.06em;
}

.btn-play-again {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
  color: #020617;
  padding: 10px 18px;
  cursor: pointer;
}

body.light-mode .btn-play-again {
  color: #fff;
}

/* Wrap tiles + overlay so the input matches tile bounds (caret lines up horizontally). */
.current-entry {
  position: relative;
  display: inline-block;
  vertical-align: top;
}

/* Monospace + padding/letter-spacing so caret lines up with centered letters in each tile. */
.guess-input-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  background-color: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--brand);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 44px;
  text-transform: uppercase;
  text-align: left;
  padding-left: calc((44px - 1ch) / 2);
  letter-spacing: calc(6px + 44px - 1ch);
  z-index: 1;
  cursor: text;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  box-shadow: none;
}

/* Keep overlay invisible: no autofill tint, focus fill, or spinners (if any UA treats it like numeric). */
.guess-input-overlay:focus,
.guess-input-overlay:focus-visible {
  outline: none;
  box-shadow: none;
  background: transparent;
  background-color: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.guess-input-overlay:-webkit-autofill,
.guess-input-overlay:-webkit-autofill:hover,
.guess-input-overlay:-webkit-autofill:focus {
  -webkit-text-fill-color: transparent;
  caret-color: var(--brand);
  box-shadow: 0 0 0 100px transparent inset;
  transition: background-color 99999s ease-out;
}

.guess-input-overlay::-webkit-contacts-auto-fill-button,
.guess-input-overlay::-webkit-credentials-auto-fill-button {
  visibility: hidden;
  display: none !important;
  pointer-events: none;
  height: 0;
  width: 0;
  margin: 0;
}

@media (min-width: 400px) {
  .guess-input-overlay {
    font-size: 1.1rem;
    line-height: 48px;
    padding-left: calc((48px - 1ch) / 2);
    letter-spacing: calc(6px + 48px - 1ch);
  }
}

.guess-row.current.hard .guess-input-overlay {
  font-size: 0.88rem;
  line-height: 40px;
  padding-left: calc((36px - 1ch) / 2);
  letter-spacing: calc(6px + 36px - 1ch);
}

@media (min-width: 400px) {
  .guess-row.current.hard .guess-input-overlay {
    font-size: 0.92rem;
    line-height: 42px;
    padding-left: calc((38px - 1ch) / 2);
    letter-spacing: calc(6px + 38px - 1ch);
  }
}

.guess-input-overlay::selection {
  background: transparent;
}

.guess-input-overlay:disabled {
  cursor: default;
  pointer-events: none;
}

.guess-row.current .tile.empty {
  color: transparent;
}

.btn-text {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--tile-border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.btn-text:hover {
  background: var(--keyboard-bg);
  border-color: var(--brand);
}

/* Footer — pinned (outside scroll area) */
.site-footer {
  flex-shrink: 0;
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--tile-border);
  background-color: var(--bg);
}

.footer-tagline {
  margin: 0;
  line-height: 1.5;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}

.site-footer a {
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Modals */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
}

body.light-mode .overlay {
  background: rgba(0, 0, 0, 0.4);
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 400px);
  max-height: 85vh;
  overflow-y: auto;
  z-index: 101;
  background: var(--keyboard-bg);
  color: var(--text);
  border-radius: var(--radius-lg);
  border: 1px solid var(--tile-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.modal.modal-rules {
  width: min(94vw, 440px);
}

.modal-kicker {
  margin: 0 0 6px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
}

.btn-modal-primary {
  display: block;
  width: 100%;
  margin-top: 16px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
  color: #020617;
}

body.light-mode .btn-modal-primary {
  color: #fff;
}

.btn-modal-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-modal-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-modal-secondary {
  display: block;
  width: 100%;
  margin-top: 10px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--tile-border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.btn-modal-secondary:hover {
  color: var(--text);
  border-color: var(--brand);
  background: var(--brand-dim);
}

.modal-small {
  width: min(88vw, 320px);
}

.modal-body {
  position: relative;
  padding: 20px 20px 22px;
}

.modal-body h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.modal-body h3 {
  margin: 18px 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-body p {
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.modal-body p strong {
  color: var(--text);
}

.notify-modal-hint {
  font-size: 0.82rem !important;
  margin-bottom: 14px !important;
}

.modal-body-rules .rules-lead {
  font-size: 0.92rem;
  line-height: 1.55;
}

.rules-game-name {
  color: var(--brand-strong);
  letter-spacing: 0.02em;
}

.rules-green {
  color: var(--score-correct);
}

.rules-yellow {
  color: var(--score-present);
}

.rules-examples-title {
  margin-top: 20px;
}

.rules-example {
  margin-bottom: 18px;
}

.rules-example-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.rules-demo-tiles {
  display: flex;
  gap: 6px;
}

.rules-demo-tiles .tile {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

.rules-example-caption {
  margin: 10px 0 0 !important;
  font-size: 0.84rem !important;
  line-height: 1.45 !important;
  text-align: center;
}

.rules-note {
  margin-top: 16px !important;
  padding-top: 14px;
  border-top: 1px solid var(--tile-border);
  font-size: 0.82rem !important;
}

.rules-modal-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--tile-border);
}

.rules-footer-line {
  margin: 0 0 8px !important;
  font-size: 0.85rem !important;
  text-align: center;
}

.rules-credit {
  margin: 0 !important;
  font-size: 0.75rem !important;
  text-align: center;
  color: var(--muted) !important;
}

.rules-credit a {
  color: var(--brand-strong);
  font-weight: 600;
  text-decoration: none;
}

.rules-credit a:hover {
  text-decoration: underline;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--key-bg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
