:root {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color-scheme: light;
  --bg-1: #fff7e8;
  --bg-2: #ffe2a8;
  --card: rgba(255, 255, 255, 0.9);
  --card-border: rgba(0, 0, 0, 0.08);
  --text: #1a1a1a;
  --muted: #5f6472;
  --accent: #ffb100;
  --accent-strong: #ff7a00;
  --accent-dark: #1f1f1f;
  --success: #1f9d55;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.12);
  --radius: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 214, 102, 0.9), transparent 35%),
    radial-gradient(circle at top right, rgba(255, 166, 77, 0.55), transparent 28%),
    linear-gradient(180deg, var(--bg-1) 0%, #fff4d8 45%, #ffe8b9 100%);
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header h1 {
  margin: 0;
  letter-spacing: 0.06em;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

.titleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.iconBtn {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
  color: var(--accent-dark);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.iconBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  background: #fff;
}

.sub {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 1rem;
  max-width: 60ch;
}

.card {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Mode toggle ── */
.mode-toggle {
  display: flex;
  gap: 10px;
}

.mode-btn {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  padding: 8px 14px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

/* ── Difficulty toggle ── */
.diff-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap; /* stays on one line always */
}

.diff-btn {
  flex: 1;
  min-width: 0;      /* allow shrinking below content width */
  padding: 8px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  opacity: 0.55;
  white-space: nowrap;
  transition: opacity 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
  box-shadow: none;
}

.diff-btn:hover:not(:disabled) {
  opacity: 0.85;
  transform: translateY(-1px);
}

.diff-btn.active        { opacity: 1; }

.diff-btn.easy.active   {
  background: rgba(60, 180, 120, 0.18);
  border-color: rgba(60, 180, 120, 0.6);
}
.diff-btn.medium.active {
  background: rgba(255, 190, 60, 0.18);
  border-color: rgba(255, 190, 60, 0.6);
}
.diff-btn.hard.active   {
  background: rgba(255, 90, 90, 0.18);
  border-color: rgba(255, 90, 90, 0.6);
}

/* ── Meta row ── */
.meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   LADDER — the main visual between start and target
══════════════════════════════════════════════════════════ */
.ladder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 4px 0;
}

/* ── Tile base ── */
.ladder-tile {
  width: 100%;
  max-width: 320px;
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
  animation: popIn 0.22s ease;
}

.ladder-tile__word {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  line-height: 1;
}

.ladder-tile__hint {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ── Start tile ── */
.ladder-tile--start {
  background: linear-gradient(180deg, #fff6d9 0%, #ffe7a8 100%);
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.ladder-tile--start::before {
  content: "START";
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── Target tile ── */
.ladder-tile--target {
  background: linear-gradient(180deg, #fff6d9 0%, #ffe7a8 100%);
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  opacity: 0.65;
}

.ladder-tile--target::before {
  content: "TARGET";
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}

/* Target lights up when solved */
.ladder-tile--target.ladder-tile--solved {
  background: linear-gradient(180deg, #d4f5e2 0%, #a8ecc4 100%);
  border-color: rgba(31, 157, 85, 0.5);
  opacity: 1;
}

/* ── Guess tile ── */
.ladder-tile--guess {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ── Empty slot ── */
.ladder-tile--empty {
  background: transparent;
  border: 2px dashed rgba(0, 0, 0, 0.12);
}

.ladder-tile--empty .ladder-tile__word {
  color: rgba(0, 0, 0, 0.18);
  letter-spacing: 0.3em;
  font-size: 1rem;
}

/* ── Connector between tiles ── */
.ladder-connector {
  width: 2px;
  height: 18px;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  position: relative;
}

/* Arrow head on filled connectors */
.ladder-connector::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.2);
}

.ladder-connector--empty {
  background: rgba(0, 0, 0, 0.08);
}

.ladder-connector--empty::after {
  border-top-color: rgba(0, 0, 0, 0.08);
}

/* Changed letter highlight */
.changed {
  color: #ff7a00;
  font-weight: 900;
  background: rgba(255, 122, 0, 0.15);
  padding: 2px 4px;
  border-radius: 6px;
}

/* ── Form ── */
.form {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

input {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.96);
  font-size: 16px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus {
  border-color: rgba(255, 122, 0, 0.55);
  box-shadow: 0 0 0 4px rgba(255, 177, 0, 0.16);
}

button {
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #1f1f1f 0%, #101010 100%);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.22);
}

button:active:not(:disabled) { transform: translateY(0); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.msg {
  min-height: 22px;
  font-size: 14px;
  color: var(--accent-dark);
  font-weight: 700;
}

.btnRow {
  display: flex;
  gap: 10px;
}

.btn      { flex: 1; }
.secondary {
  background: linear-gradient(180deg, #ffb100 0%, #ff8f1f 100%);
  color: #171717;
}

/* ── Stats ── */
.wordsie-stats {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.4);
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Footer ── */
.footer {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ── Dialogs ── */
.dialog {
  border: 0;
  border-radius: 18px;
  padding: 20px;
  max-width: 560px;
  width: calc(100% - 24px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.hidden { display: none; }

.modal-content {
  background: white;
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  max-width: 320px;
  width: 90%;
}

/* ── About / SEO section ── */
.about-seo {
  margin-top: 32px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.about-seo h2 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
  letter-spacing: 0.02em;
}

.about-seo h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin: 16px 0 6px;
}

.about-seo p        { margin: 0 0 10px; }
.about-seo p:last-child { margin-bottom: 0; }
.about-seo strong   { color: var(--text); font-weight: 700; }

/* ── Animation ── */
@keyframes popIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ══════════════════════════════════════════════════════════
   MOBILE
══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .wrap  { padding: 16px 12px 24px; }

  .card  { padding: 16px; gap: 8px; }

  /* Difficulty toggle: shrink text so all 3 fit on one line */
  .diff-btn {
    font-size: 0.78rem;
    padding: 7px 6px;
  }

  .mode-btn {
    font-size: 0.88rem;
    padding: 7px 10px;
  }

  .ladder-tile {
    max-width: 100%;
    padding: 10px 12px;
  }

  .ladder-tile__word {
    font-size: clamp(1.2rem, 6vw, 1.6rem);
  }

  .form   { flex-direction: column; }
  .btnRow { flex-direction: column; }

  /* Full width on mobile — but NOT inside the ladder input row */
  button:not(.ladder-input-row button),
  input:not(.ladder-input-row input) { width: 100%; }

  /* Ladder input stays side-by-side on mobile */
  .ladder-input-row {
    max-width: 100%;
    flex-direction: row;
  }

  .ladder-input-row input {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  .ladder-input-row button {
    width: auto;
    flex-shrink: 0;
    padding: 12px 20px;
  }

  .titleRow { align-items: flex-start; }
}

/* ── Inline ladder input ── */
.ladder-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.ladder-input-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 122, 0, 0.4);
  background: rgba(255, 255, 255, 0.96);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ladder-input-row input:focus {
  border-color: rgba(255, 122, 0, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 177, 0, 0.18);
}

.ladder-input-row button {
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* Feedback message inside the ladder */
.ladder-msg {
  text-align: center;
  min-height: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-dark);
  margin: 2px 0;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Result modal — streak display ── */
.modal-streak {
  font-size: 1.6rem;
  font-weight: 900;
  color: #ff7a00;
  margin: 8px 0 12px;
  letter-spacing: 0.01em;
}

.modal-streak--lost {
  color: #888;
  font-size: 1.1rem;
}

.modal-detail {
  font-size: 0.9rem;
  color: #5f6472;
  margin: 4px 0;
  font-weight: 600;
}

/* ── Social share buttons in result modal ── */
.modal-share-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 12px;
  width: 100%;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 12px;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.share-btn:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.share-btn:active {
  transform: translateY(0);
}

.share-btn__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.share-btn__icon svg {
  width: 18px;
  height: 18px;
}

.share-btn--x       { background: #000; }
.share-btn--wa      { background: #25d366; }
.share-btn--native  { background: #6366f1; }
.share-btn--copy    { background: #ff7a00; }
.share-btn--copied  { background: #1f9d55; }

.modal-close-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.06);
  color: #5f6472;
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease;
}

.modal-close-btn:hover {
  background: rgba(0,0,0,0.1);
  transform: none;
  box-shadow: none;
}

.toggle-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: -4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-row .toggle-label {
  flex-shrink: 0;
  min-width: 70px;
  margin-bottom: 0;
}