:root {
  --guide-font-scale: 1;
  --guide-ink: var(--weg-text-primary, #222);
  --guide-muted: var(--weg-text-secondary, #5b6270);
  --guide-paper: var(--weg-bg-primary, #fff);
  --guide-soft: var(--weg-bg-secondary, #f4f3f3);
  --guide-line: var(--weg-border-light, #ccc);
  --guide-blue: var(--weg-accent-primary, #335190);
  --guide-blue-dark: var(--weg-accent-primary-hover, #263c6a);
  --guide-gold: #c8912f;
  --guide-warning: #fff6dc;
  --guide-success: #edf7ef;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  color: var(--guide-ink);
  background: var(--guide-paper);
}

.weg-skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 1200;
  padding: 0.7rem 1rem;
  border-radius: 0 0 0.4rem 0.4rem;
  color: #fff;
  background: #111;
  font-family: "Roboto", "Helvetica Neue", sans-serif;
  font-weight: 700;
}

.weg-skip-link:focus {
  top: 0;
  color: #fff;
}

.scrabble-guide {
  --guide-base-size: calc(18px * var(--guide-font-scale));
  color: var(--guide-ink);
  background:
    linear-gradient(180deg, var(--guide-soft) 0, var(--guide-paper) 22rem),
    var(--guide-paper);
  font-family: "Roboto", "Helvetica Neue", sans-serif;
  font-size: var(--guide-base-size);
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

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

.scrabble-guide a {
  color: var(--guide-blue-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.scrabble-guide a:hover {
  color: var(--guide-blue);
  text-decoration-thickness: 2px;
}

.scrabble-guide img,
.scrabble-guide svg {
  max-width: 100%;
  height: auto;
}

.guide-hero {
  margin-top: 34px;
  border-bottom: 5px solid var(--guide-gold);
  color: #fff;
  background:
    linear-gradient(120deg, rgba(38, 60, 106, 0.98), rgba(51, 81, 144, 0.95)),
    repeating-linear-gradient(45deg, transparent 0 26px, rgba(255, 255, 255, 0.05) 26px 52px);
}

.header-inner,
.toolbar-inner,
.guide-scope,
.page-grid {
  width: 800px;
  margin-inline: auto;
}

.guide-hero .header-inner {
  padding: clamp(1.25rem, 3vw, 2rem) 0 1.4rem;
}

.scrabble-guide h1,
.scrabble-guide h2,
.scrabble-guide h3,
.scrabble-guide h4 {
  line-height: 1.2;
}

.scrabble-guide h1 {
  max-width: none;
  margin: 0;
  color: #fff;
  font-family: "Lora", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.scrabble-guide .subtitle {
  max-width: 48rem;
  margin: 0.55rem 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1rem, 1.6vw, 1.15rem);
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.18rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  font-weight: 700;
}

.hero-link {
  margin: 0.9rem 0 0;
}

.hero-link a {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 0.35rem;
  color: var(--guide-blue-dark);
  background: #fff;
  box-shadow: 0 0.15rem 0.4rem rgba(14, 24, 47, 0.18);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.hero-link a:hover {
  color: #fff;
  background: var(--guide-blue-dark);
}

.hero-link a:focus-visible,
.scrabble-guide summary:focus-visible,
.toc a:focus-visible {
  outline: 3px solid var(--guide-gold);
  outline-offset: 3px;
}

.toolbar {
  border-bottom: 1px solid var(--guide-line);
  background: var(--guide-paper);
  box-shadow: 0 1px 0 rgba(35, 42, 50, 0.04);
}

.toolbar-inner {
  display: flex;
  align-items: center;
  min-height: 3.5rem;
  padding: 0.4rem 0;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.toolbar-label {
  margin-right: 0.2rem;
  color: var(--guide-muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.control-button {
  min-width: 2.8rem;
  min-height: 2.6rem;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--guide-line);
  border-radius: 0.4rem;
  color: var(--guide-ink);
  background: var(--guide-paper);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.control-button:hover,
.control-button:focus-visible {
  border-color: var(--guide-blue);
  background: var(--guide-soft);
}

.control-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--guide-blue) 35%, transparent);
  outline-offset: 2px;
}

.page-grid {
  padding: 1.8rem 0 4.5rem;
}

.toc {
  margin: 0 0 2rem;
  overflow: hidden;
  border: 1px solid var(--guide-line);
  border-top: 4px solid var(--guide-blue);
  border-radius: 0.45rem;
  background: var(--guide-paper);
  box-shadow: var(--weg-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.15));
}

.scrabble-guide .toc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  color: var(--guide-ink);
  background: var(--guide-paper);
  font-family: "Lora", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  list-style-position: inside;
}

.scrabble-guide .toc > summary::after {
  margin-left: 1rem;
  color: var(--guide-muted);
  content: "Mostrar secciones";
  font-family: "Roboto", "Helvetica Neue", sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
}

.scrabble-guide .toc[open] > summary {
  border-bottom: 1px solid var(--guide-line);
  background: var(--guide-soft);
}

.scrabble-guide .toc[open] > summary::after {
  content: "Ocultar secciones";
}

.toc nav {
  padding: 0.85rem 1.1rem 1rem;
}

.toc ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 2rem;
  margin: 0;
  padding-left: 1.25rem;
}

.toc li {
  min-width: 0;
  margin: 0.28rem 0;
}

.toc a {
  display: block;
  padding: 0.08rem 0;
  color: var(--guide-ink);
  font-size: 0.82rem;
  line-height: 1.35;
  text-decoration: none;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--guide-blue);
  text-decoration: underline;
}

.scrabble-guide main {
  width: 100%;
  max-width: 56rem;
  min-width: 0;
}

.scrabble-guide section {
  margin: 0 0 3.8rem;
  scroll-margin-top: 4.5rem;
}

.scrabble-guide section > h2 {
  margin: 0 0 1.15rem;
  padding-bottom: 0.48rem;
  border-bottom: 3px solid var(--guide-gold);
  color: var(--guide-ink);
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

.scrabble-guide h3 {
  margin: 1.7rem 0 0.55rem;
  color: var(--guide-ink);
  font-size: 1.24rem;
}

.scrabble-guide h4 {
  margin: 1.3rem 0 0.45rem;
  font-size: 1.05rem;
}

.scrabble-guide p {
  margin: 0.65rem 0 1rem;
}

.scrabble-guide ul,
.scrabble-guide ol {
  padding-left: 1.45rem;
}

.scrabble-guide li {
  margin: 0.38rem 0;
}

.lead {
  font-family: "Lora", Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.65;
}

.card-grid,
.tile-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.9rem;
}

.scrabble-guide .card,
.tile-group,
.choice {
  padding: 1rem 1.1rem;
  border: 1px solid var(--guide-line);
  border-radius: 0.45rem;
  background: var(--guide-paper);
  box-shadow: 0 0.15rem 0.55rem rgba(35, 42, 50, 0.045);
}

.scrabble-guide .card h3,
.tile-group h3,
.choice h3 {
  margin-top: 0;
}

.callout {
  margin: 1.2rem 0;
  padding: 1rem 1.1rem;
  border-left: 5px solid var(--guide-blue);
  border-radius: 0 0.45rem 0.45rem 0;
  background: color-mix(in srgb, var(--guide-blue) 9%, var(--guide-paper));
}

.callout.warning {
  border-left-color: var(--guide-gold);
  background: var(--guide-warning);
  color: #32270d;
}

.callout.good {
  border-left-color: #37784a;
  background: var(--guide-success);
  color: #173d22;
}

.guide-scope {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.scope-callout {
  margin: 0;
  padding: 0.8rem 1rem;
}

.scope-callout h2,
.mode-callout h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.scope-callout p {
  margin: 0.35rem 0;
}

.callout p:last-child,
.card p:last-child,
.card ul:last-child {
  margin-bottom: 0;
}

.quick-steps {
  counter-reset: guide-step;
  display: grid;
  gap: 0.75rem;
  padding: 0 !important;
  list-style: none;
}

.quick-steps li {
  counter-increment: guide-step;
  display: grid;
  grid-template-columns: 2.3rem 1fr;
  gap: 0.75rem;
  align-items: start;
  margin: 0;
  padding: 0.82rem 0.95rem;
  border: 1px solid var(--guide-line);
  border-radius: 0.42rem;
  background: var(--guide-paper);
}

.quick-steps li::before {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  content: counter(guide-step);
  color: #fff;
  background: var(--guide-blue);
  font-weight: 800;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.choice-number {
  display: inline-grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  color: #fff;
  background: var(--guide-blue);
  font-size: 0.82rem;
}

.figure,
.example-card {
  margin: 1.35rem 0 1.8rem;
  border: 1px solid var(--guide-line);
  border-radius: 0.5rem;
  background: var(--guide-paper);
  box-shadow: 0 0.2rem 0.8rem rgba(35, 42, 50, 0.06);
}

.figure {
  padding: 1rem;
}

.figure img {
  display: block;
  margin: 0 auto;
}

.figure figcaption {
  margin-top: 0.9rem;
  color: var(--guide-muted);
  font-size: 0.9rem;
}

.examples {
  display: grid;
  gap: 1.25rem;
}

.example-card {
  overflow: hidden;
}

.example-card > header {
  padding: 1rem 1.1rem 0;
}

.example-card h3 {
  margin: 0;
}

.example-card figure {
  margin: 0;
  padding: 0.85rem 1rem;
}

.example-card img {
  display: block;
  width: 100%;
  max-height: 31rem;
  object-fit: contain;
}

.example-text {
  padding: 0 1.1rem 1.1rem;
}

.score-line {
  display: inline-block;
  margin: 0.3rem 0 0;
  padding: 0.4rem 0.65rem;
  border-radius: 0.3rem;
  color: #352600;
  background: #fff0ba;
  font-weight: 800;
}

.rule-table {
  width: 100%;
  margin: 1rem 0 1.6rem;
  border-collapse: collapse;
  background: var(--guide-paper);
}

.rule-table caption {
  padding-bottom: 0.5rem;
  text-align: left;
  font-weight: 800;
}

.rule-table th,
.rule-table td {
  padding: 0.65rem 0.72rem;
  border: 1px solid var(--guide-line);
  text-align: left;
  vertical-align: top;
}

.rule-table th {
  background: var(--guide-soft);
}

.tile-group h3 {
  color: var(--guide-blue);
  font-size: 1.02rem;
}

.tile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tile-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 2.25rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid #9c8554;
  border-radius: 0.28rem;
  color: #2d2618;
  background: #f2e2bc;
  font-weight: 800;
}

.tile-chip small {
  color: #5c4b2c;
  font-size: 0.7rem;
}

.faq details,
.variations details,
.mode-details {
  margin: 0.7rem 0;
  border: 1px solid var(--guide-line);
  border-radius: 0.42rem;
  background: var(--guide-paper);
}

.scrabble-guide summary {
  min-height: 3rem;
  padding: 0.78rem 1rem;
  cursor: pointer;
  font-weight: 800;
}

.scrabble-guide summary:hover {
  background: var(--guide-soft);
}

.scrabble-guide details[open] summary {
  border-bottom: 1px solid var(--guide-line);
  background: var(--guide-soft);
}

.details-body {
  padding: 0.2rem 1rem 1rem;
}

.scrabble-guide .rules-review {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--guide-line);
  color: var(--guide-muted);
  font-size: 0.82rem;
}

.scrabble-guide .rules-review > h2 {
  margin: 0 0 0.35rem;
  padding: 0;
  border: 0;
  color: var(--guide-muted);
  font-family: "Roboto", "Helvetica Neue", sans-serif;
  font-size: 1rem;
}

.rules-review p {
  margin: 0;
}

.word-list-page .page-grid {
  padding-top: 2.2rem;
}

.two-letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.25rem, 1fr));
  gap: 0.55rem;
  margin: 1.2rem 0 1.5rem;
  padding: 0 !important;
  list-style: none;
}

.two-letter-word {
  display: grid;
  place-items: center;
  min-height: 3.1rem;
  margin: 0 !important;
  border: 1px solid #9c8554;
  border-radius: 0.32rem;
  color: #2d2618;
  background: #f2e2bc;
  box-shadow: inset 0 -0.15rem 0 rgba(91, 67, 25, 0.12);
  font-family: "Lora", Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.word-list-page .word-note h3 {
  margin-top: 0;
}

.source-note {
  color: var(--guide-muted);
  font-size: 0.82rem;
}

.word-list-cta {
  margin-top: 0;
}

@media (min-width: 1024px) {
  .header-inner,
  .toolbar-inner,
  .guide-scope,
  .page-grid {
    width: 1000px;
  }
}

@media (max-width: 980px) {
  .header-inner,
  .toolbar-inner,
  .guide-scope,
  .page-grid {
    width: 92%;
  }
}

@media (max-width: 900px) {
  .scrabble-guide main {
    max-width: none;
  }

  .toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.3rem 2rem;
  }

  .toc li {
    min-width: 0;
    padding-right: 0.35rem;
    break-inside: avoid;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header-inner,
  .toolbar-inner,
  .guide-scope,
  .page-grid {
    width: 94%;
  }
}

@media (max-width: 580px) {
  html {
    scroll-padding-top: 1rem;
  }

  .scrabble-guide {
    --guide-base-size: calc(17px * var(--guide-font-scale));
    padding-top: 34px;
    line-height: 1.62;
  }

  .guide-hero {
    margin-top: 0;
  }

  .header-inner,
  .toolbar-inner,
  .guide-scope,
  .page-grid {
    width: 90%;
  }

  .guide-hero .header-inner {
    padding: 1.1rem 0 1.25rem;
  }

  .toolbar-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .toolbar-label {
    grid-column: 1 / -1;
    margin: 0 0 0.1rem;
  }

  .control-button {
    width: 100%;
  }

  .toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    padding-left: 0;
    list-style: none;
  }

  .toc li {
    margin: 0;
    padding: 0;
  }

  .toc a {
    display: flex;
    align-items: center;
    min-height: 2.35rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.3rem;
    background: var(--guide-soft);
    font-size: 0.76rem;
    line-height: 1.25;
  }

  .page-grid {
    padding-top: 1.25rem;
  }

  .scrabble-guide section {
    margin-bottom: 3rem;
  }

  .scrabble-guide section > h2 {
    margin-bottom: 0.9rem;
    font-size: clamp(1.55rem, 8vw, 2rem);
  }

  .two-letter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .two-letter-word {
    min-height: 2.9rem;
  }

  .quick-steps li {
    grid-template-columns: 2rem 1fr;
    gap: 0.65rem;
    padding: 0.75rem;
  }

  .quick-steps li::before {
    width: 1.9rem;
    height: 1.9rem;
  }

  .rule-table {
    display: block;
    overflow-x: auto;
  }

  .badge {
    font-size: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

@media print {
  :root {
    --guide-ink: #111;
    --guide-muted: #333;
    --guide-paper: #fff;
    --guide-soft: #fff;
    --guide-line: #777;
    --guide-blue: #111;
    --guide-blue-dark: #111;
  }

  html,
  body,
  .scrabble-guide {
    color: #111;
    background: #fff !important;
    color-scheme: light;
  }

  #main-header,
  body > footer,
  .weg-skip-link,
  .scrabble-guide .toolbar,
  .scrabble-guide .toc,
  .scrabble-guide .hero-link {
    display: none !important;
  }

  .guide-hero {
    margin-top: 0;
    border-bottom: 2px solid #111;
    color: #111;
    background: #fff;
  }

  .scrabble-guide h1,
  .scrabble-guide .subtitle {
    color: #111;
  }

  .scrabble-guide .badge {
    border-color: #777;
    color: #111;
    background: #fff;
  }

  .header-inner,
  .guide-scope,
  .page-grid {
    width: auto;
    margin-inline: 0;
  }

  .scrabble-guide .mode-details > .details-body {
    display: block !important;
  }

  .scope-callout,
  .mode-callout,
  .mode-details,
  .rules-review,
  .example-card,
  .figure {
    break-inside: avoid;
  }

  .two-letter-grid {
    grid-template-columns: repeat(9, 1fr);
  }

  .two-letter-word {
    min-height: 2rem;
    box-shadow: none;
  }
}
