:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
  }

  html, body {
    touch-action: manipulation;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;      /* 🚫 no page scrolling */
  }

  body {
    margin: 0;
    min-height: 100vh;
    background: #ffffff;
    color: #111827;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }

  .app {
    width: 100%;
    max-width: 480px;
    padding: 0;
    box-sizing: border-box;
    position: relative; /* for overlay elements (status, confetti) */
    min-height: 100vh;   /* make sure app fills the visible area */
  }

  /* NAVBAR */

  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 6px;
    border-bottom:1px solid rgb(194, 192, 192);
    padding: 4px 6px 6px 6px;
    background-color: rgb(253, 248, 239);
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.0rem;
    font-weight: 700;
  }

  .logo-word {
    display: flex;
    gap: 2px;
    letter-spacing: 0.18em;
  }

  .logo-icon {
    height: 27px;
    flex-shrink: 0;
    display: block;
    margin-top:4px;
  }

  .logo-letter {
    position: relative;
    padding-bottom: 2px;
    padding-left:3px;
    display: inline-block;
    transform: scaleY(1.35);
    transform-origin: center;
  }

  .logo-letter::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background: #111827;
    border-radius: 999px;
  }

  /* Right-side navbar icons */

  .navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .icon-button {
    border: none;
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .icon-button:active {
    transform: translateY(1px);
  }

  .icon-button-icon {
    width: 27px;
    height: 27px;
    display: block;
  }


  .guess-progress-row{
    position: relative;
    min-height: 22px;
    padding-right: 190px; /* reserve right space so the label never sits under the pill */
  }

  .status-pill{
    position: absolute;
    right: 0;
    top: 0px;
    z-index: 60;

    background: #000;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;

    font-size: 0.78rem;
    font-weight: 600;

    opacity: 0;
    pointer-events: none;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
  }

  .status-pill.visible{
    opacity: 1;
  }
  /* SUBTITLE */

  .subtitle {
    margin-top: 12px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    padding:0 6px;
  }

  /* LADDER */

  .ladder {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 10px 10px;
    padding: 0 6px;
  }

  .rung {
    display: flex;
    align-items: center;
    gap: 26px;
  }

  .rung-side {
    width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    box-sizing: border-box;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.8;
    text-align: center;
  }

  .rung-side-right {
    position: relative;
  }

  .rung-word {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 1.8rem;
    letter-spacing: 0;
    padding: 5px 5px;
    border-radius: 999px;
    border: 2px solid rgba(148,163,184,0.8);
    min-height: 40px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9fafb;
    position: relative;
    transition:
      background 0.15s ease,
      border-color 0.15s ease,
      box-shadow 0.15s ease,
      transform 0.12s ease;
  }

  .rung-word.start-end {
    background: #f9fafb;
    border-color: rgba(148,163,184,0.9);
  }

  .rung-word.middle {
    cursor: default;
  }

  .rung-word.middle.active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 1px rgba(56,189,248,0.5);
    transform: translateY(-1px);
  }

  .rung-word.middle.future {
    background: #eef2f7;
    border-color: rgba(148,163,184,0.8);
    opacity: 0.97;
  }

  /* Solved middle rungs should match START/END border */
  .rung-word.middle.solved {
    background: #f9fafb;
    border-color: rgba(148,163,184,0.9);
  } 

  .rung-word.solved {
    background: #f9fafb;
    border-color: #cbd5e1;
  }

  .rung-word.failed {
    background: #f9fafb;
    border-style: dashed;
    border-color: #fecaca;
  }

  /* Subtle grow animation when a rung is solved */
  @keyframes rung-solved-grow {
    0% {
      transform: scale(1);
    }
    40% {
      transform: scale(1.30);
    }
    75% {
      transform: scale(1.12);
    }
    100% {
      transform: scale(1);
    }
  }

  .rung-word.solved-pop {
    animation: rung-solved-grow 260ms ease-out;
  }

  /* Arrow rows between rungs */
  .rung-arrow .ladder-arrow-row {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 10px;
    color: #4f5051;
    font-size: 0.85rem;
    pointer-events: none;
    user-select: none;
  }

  /* Letters */

  /* Hint letters: keep underscore normal, overlay faint letter */
  .letter-hint {
    /* don't change opacity here or the underscore will fade too */
  }

  .letter-hint::before {
    content: attr(data-hint);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -55%);
    opacity: 0.38;        /* ghosty */
    pointer-events: none;
    font-weight: 400;
    color: #16a34a;
    font-size: 1.6rem;
  }

  .letter {
    display: inline-block;
    min-width: 1.05em;
    text-align: center;
    margin: 0 0.04em;
    font-size: 1.8rem;   /* 👈 explicit size */
    font-weight: 800;    /* 👈 consistent weight for ALL letters */
    transition: color 0.22s ease, transform 0.18s ease;
    position: relative;
  }

  .letter-correct {
    color: #16a34a;
    
  }

  .letter-wrong {
    color: #dc2626;
  }

  /* Force score colors to win against theme/inherited colors */
.rung-word .letter.letter-correct { color: #16a34a !important; }
.rung-word .letter.letter-wrong   { color: #dc2626 !important; }

  /* END rung win flip */
  /* END / START rung win flip + bubble-grow */
@keyframes letterWinBubble {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.32);  /* grow */
  }
  65% {
    transform: scale(0.95);  /* slight overshoot */
  }
  100% {
    transform: scale(1);     /* settle */
  }
}

.letter-end-win {
  color: #16a34a;
  animation: letterWinBubble 240ms ease-out;
}

  @keyframes letterFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .letter-reveal {
    animation: letterFadeIn 180ms ease-out;
  }

  /* Rung state dots */

  .rung-state {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: #e5e7eb;
    flex-shrink: 0;
    box-sizing: border-box;
  }

  .rung-state--idle {
    opacity: 0.9;
  }

  .rung-state--active {
    border-color: #38bdf8;
    background: #e0f2fe;
    box-shadow: 0 0 0 1px rgba(56,189,248,0.4);
  }

  .rung-state--solved {
    border-color: #22c55e;
    background: #bbf7d0;
  }

  .rung-state--error {
    border-color: #fb7185;
    background: #fecaca;
  }

  .letter-pending {
    color: #6b7280; /* gray */
  }

  .footer {
    margin-top: 4px;
    font-size: 0.8rem;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding:0 6px;
  }

  #resultInfo {
    font-weight: 500;
  }

  /* Guesses progress bar */
  .guess-progress-wrapper {
    margin-top: 6px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    padding: 0 6px;
  }

  .guess-progress-label {
    opacity: 0.85;
  }

  .guess-label-title {
    font-weight: 600;
  }

  /* SHARE BOX (hidden backing store) */
  .share {
    display: none;
  }

  textarea.share-text {
    width: 100%;
    min-height: 60px;
    margin-top: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(148,163,184,0.7);
    background: #f9fafb;
    color: inherit;
    resize: vertical;
    box-sizing: border-box;
    font-size: 0.8rem;
  }

  /* VIRTUAL KEYBOARD */

  .keyboard {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    user-select: none;
    padding:0 6px;
  }

  .keyboard-row {
    display: flex;
    justify-content: space-between;
    gap: 4px;
  }

  .keyboard-key {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 0;
    border-radius: 8px;
    border: 1px solid #020617;
    background: #444546;
    color: #f9fafb;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15,23,42,0.45);
  }

  .keyboard-key-enter,
  .keyboard-key-backspace {
    flex: 1.5 1 0;
    background: #444546;
  }
  
  .keyboard-key-enter {
    font-size: 0.85rem;
  }

  .keyboard-key.wide {
    flex: 1.5 1 0;
  }

  .keyboard-key:active {
    transform: translateY(1px);
    box-shadow: 0 0 0 rgba(0,0,0,0);
    filter: brightness(1.05);
  }

  /* Enter key "ready" state – background pulsing green */
  .keyboard-key--ready {
    background-color: #14532d;
    color: #f9fafb;
    animation: enterBgPulse 1s ease-in-out infinite;
    /*transform: translateY(-1px);*/
  }

  @keyframes enterBgPulse {
    0% {
      background-color: #14532d;  /* slightly darker than your current green */
    }
    50% {
      background-color: #15803d;  /* your current green */
    }
    100% {
      background-color: #14532d;
    }
  }

  /*
  @keyframes enterBgPulse {
    0% {
      background-color: #16a34a;
      transform: translateY(-1px) scale(1);
    }
    50% {
      background-color: #22c55e;
      transform: translateY(-2px) scale(1.01);
    }
    100% {
      background-color: #16a34a;
      transform: translateY(-1px) scale(1);
    }
  }*/

  /* Backspace key "error" pulse */
  .keyboard-key--error-pulse {
    background-color: #7f1d1d;
    color: #f9fafb;
    animation: backspaceBgPulse 0.9s ease-in-out infinite;
    /*transform: translateY(-1px);*/
  }

  /* GAME OVER keyboard state */
.keyboard.keyboard--gameover .keyboard-key,
.keyboard.keyboard--gameover .keyboard-key-enter,
.keyboard.keyboard--gameover .keyboard-key-backspace {
  background: #d1d5db;   /* lighter grey */
  color: #4b5563;        /* muted text */
  border-color: #6b7280;
  box-shadow: none;
  cursor: default;
}

/* Kill any pulsing when game over */
.keyboard.keyboard--gameover .keyboard-key--ready,
.keyboard.keyboard--gameover .keyboard-key--error-pulse {
  animation: none !important;
  background: #d1d5db !important;
  color: #4b5563 !important;
}

/* Dark mode + game over (still lighter than normal dark keys) */
body.theme-dark .keyboard.keyboard--gameover .keyboard-key,
body.theme-dark .keyboard.keyboard--gameover .keyboard-key-enter,
body.theme-dark .keyboard.keyboard--gameover .keyboard-key-backspace {
  background: #374151;
  color: #d1d5db;
  border-color: #9ca3af;
}
body.theme-dark .keyboard.keyboard--gameover .keyboard-key--ready,
body.theme-dark .keyboard.keyboard--gameover .keyboard-key--error-pulse {
  animation: none !important;
  background: #374151 !important;
  color: #d1d5db !important;
}

  @keyframes backspaceBgPulse {
    0% {
      background-color: #7f1d1d;  /* deep red */
    }
    50% {
      background-color: #b91c1c;  /* your current red */
    }
    100% {
      background-color: #7f1d1d;
    }
  }
  /*
  @keyframes backspaceBgPulse {
    0% {
      background-color: #dc2626;
      transform: translateY(-1px) scale(1);
    }
    50% {
      background-color: #f97316;
      transform: translateY(-2px) scale(1.01);
    }
    100% {
      background-color: #dc2626;
      transform: translateY(-1px) scale(1);
    }
  }*/

  
  /* Help overlay */
  .help-example{
    border-radius: 10px;
    border: 1px solid rgb(203, 202, 202);

  }

  .help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }

  .help-overlay.active {
    display: flex;
  }

  .help-content {
    max-width: 500px;
    width: 90%;
    background: #f5f5f5;
    color: #111;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    position: relative;
    box-sizing: border-box;
  }

  .help-content h2 {
    margin-top: 0;
    margin-bottom: 8px;
  }

  .help-content ol {
    padding-left: 20px;
    margin-top: 8px;
  }

  .help-content li {
    margin-bottom: 6px;
    font-size: 0.9rem;
  }

  .help-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .help-title {
    font-size: 1.3rem;
    font-weight: 700;
  }

  .help-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #111827;
    padding: 0;
    -webkit-appearance: none;
  }

  /* Strong shake for errors */

  @keyframes rung-shake-strong {
    0%   { left: 0; }
    15%  { left: -6px; }
    30%  { left: 6px; }
    45%  { left: -6px; }
    60%  { left: 6px; }
    75%  { left: -4px; }
    90%  { left: 4px; }
    100% { left: 0; }
  }

  .rung-word.shake {
    animation: rung-shake-strong 0.28s ease-in-out;
  }

  /* Confetti overlay */

  .confetti-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 80;
  }

  .confetti-piece {
    position: absolute;
    top: -10%;
    opacity: 0;
    border-radius: 2px;
    --x-drift: 0px;
    --fall-duration: 2s;
    animation: confetti-fall var(--fall-duration) ease-out forwards;
  }

  @keyframes confetti-fall {
    0% {
      top: -10%;
      opacity: 0;
      transform: translateX(0) rotate(0deg);
    }
    10% {
      opacity: 1;
    }
    50% {
      transform: translateX(calc(var(--x-drift) * 0.5)) rotate(180deg);
    }
    100% {
      top: 110%;
      opacity: 0;
      transform: translateX(var(--x-drift)) rotate(360deg);
    }
  }

  /* STATS OVERLAY / MODAL */

  .stats-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
  }

  .stats-overlay.active {
    display: flex;
  }

  .stats-modal {
    max-width: 480px;
    width: 90%;
    background: #fafafa;
    color: #111827;
    border-radius: 16px;
    padding: 18px 20px 16px;
    box-shadow: 0 10px 30px rgba(15,23,42,0.35);
    position: relative;
    box-sizing: border-box;
  }

  .stats-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .stats-right-controls {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .stats-title {
    font-size: 1.3rem;
    font-weight: 700;
  }

  .stats-back {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    padding-top: 2px;
  }

  .stats-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #111827;
    padding: 0;
    -webkit-appearance: none;
  }

  .stats-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 10px 0 16px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .stats-grid {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    border-top: 1px solid rgb(56, 54, 54);
    border-bottom: 1px solid rgb(56, 54, 54);
    padding: 8px 0;
  }

  .stats-grid-item {
    flex: 1;
    text-align: center;
  }

  .stats-number {
    font-size: 1.6rem;
    font-weight: 700;
  }

  .stats-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
  }

  .stats-guess-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 10px;
  }

  .stats-guess-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
  }

  .stats-guess-label {
    width: 70px;
    text-align: center;
    font-weight: 600;
    background: #c9caca;
    color: #494b4c;
    padding: 2px 6px;
    border-radius: 2px;
  }

  .stats-guess-header-label--left {
    flex: 0 0 85px;
    text-align: center;
  }

  .stats-guess-bar-wrap {
    flex: 1;
    background: transparent;
    border-radius: 0;
    overflow: visible;
  }

  .stats-guess-bar {
    height: 20px;
    min-width: 6%;
    background: #6b7280;
    border-radius: 2px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-right: 6px;
    box-sizing: border-box;
    color: #f9fafb;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .stats-guess-bar--current {
    background: #22c55e;
  }

  .stats-guess-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    opacity: 0.75;
    margin-bottom: 2px;
  }

  .stats-guess-header-label--right {
    flex: 1;
    text-align: left;
  }

  .stats-share-row {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    border-top: 1px solid black;
    padding-top:20px;
  }

  .stats-share-btn {
    min-width: 180px;
    border-radius: 999px;
    padding: 10px 18px;
    border: none;
    background: #4d4e4d;
    color: #f9fafb;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
  }

  .stats-share-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(34,197,94,0.7);
  }

  /* SETTINGS OVERLAY */

  .settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
  }

  .settings-overlay.active {
    display: flex;
  }

  .settings-modal {
    max-width: 480px;
    width: 90%;
    background: #f5f5f5;
    color: #111827;
    border-radius: 16px;
    padding: 16px 18px 14px;
    box-shadow: 0 10px 30px rgba(15,23,42,0.35);
    box-sizing: border-box;
  }

  .settings-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .settings-title {
    font-size: 1.3rem;
    font-weight: 700;
  }

  .settings-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #111827;
    padding: 0;
    -webkit-appearance: none;
  }

  .settings-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
  }

  .settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .settings-text {
    flex: 1;
    min-width: 0;
  }

  .settings-label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
  }

  .settings-description {
    font-size: 0.8rem;
    opacity: 0.8;
  }

  .settings-byline {
    font-size: 0.8rem;
    color:#838181
  }

  /* Toggle switch */

  .settings-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
  }

  .settings-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .settings-toggle-slider {
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #d4d4d8;
    position: relative;
    transition: background 0.2s ease;
  }

  .settings-toggle-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
  }

  /* Checked state */
  .settings-toggle input:checked + .settings-toggle-slider {
    background: #16a34a;
  }

  .settings-toggle input:checked + .settings-toggle-slider::before {
    transform: translateX(18px);
  }

  /* DARK THEME */

  body.theme-dark {
    background: #020617;
    color: #e5e7eb;
  }

  body.theme-dark .navbar {
    background-color: #020617;
    border-bottom-color: #374151;
  }

  body.theme-dark .subtitle {
    color: #e5e7eb;
  }

  body.theme-dark .ladder {
    /* keep background neutral; pill handles most */
  }

  body.theme-dark .rung-word {
    background: #020617;
    border-color: #4b5563;
    color: #e5e7eb;
  }

  body.theme-dark .rung-word.future {
    background: #111827;
  }

  body.theme-dark .rung-word.solved {
    border-color: #6b7280;
  }

  body.theme-dark .rung-state {
    background: #111827;
    border-color: #4b5563;
  }

  body.theme-dark .rung-state--solved {
    background: #064e3b;
    border-color: #22c55e;
  }

  body.theme-dark .guess-progress-bar {
    background: #1f2937;
  }

  body.theme-dark .guess-progress-fill {
    background: #22c55e;
  }

  body.theme-dark .keyboard-key,
  body.theme-dark .keyboard-key-enter,
  body.theme-dark .keyboard-key-backspace {
    background: #111827;
    border-color: #e5e7eb;
    color: #f9fafb;
  }

  body.theme-dark .global-status,
  body.theme-dark .final-status {
    background: #111827;
    color: #f9fafb;
  }

  body.theme-dark .stats-modal,
  body.theme-dark .help-content,
  body.theme-dark .settings-modal {
    background: #020617;
    color: #e5e7eb;
    border: 1px solid white;
  }

  body.theme-dark .stats-guess-label {
    background: #111827;
    color: #e5e7eb;
  }

  body.theme-dark .help-close,
  body.theme-dark .stats-close,
  body.theme-dark .settings-close {
    color: #e5e7eb;          /* light X in dark mode */
  }
  

  @media (max-width: 400px) {
    .logo {
      font-size: 1.0rem;
    }
    .stats-title {
      font-size: 1.2rem;
    }
  }