/* Lantern Flip Puzzle (w035) */
.lf { display: grid; gap: .5rem; }
.lf > * { min-width: 0; }

.lf .lf-modes { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: .25rem; padding: .25rem; border: 1px solid var(--border); border-radius: .8rem; background: #0c1220; }
.lf .lf-modes button { min-width: 0; padding-inline: .3rem; border: 0; background: transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lf .lf-modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.lf .lf-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 .75rem; }
.lf .lf-title { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.lf .lf-count { display: flex; gap: .6rem; margin: 0 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
[dir="rtl"] .lf .lf-count { margin: 0 auto 0 0; }
.lf .lf-count b { color: var(--text); font-size: 1.15rem; }

/* Board: fixed left-to-right geometry; cells stay square and at least 44 px. */
.lf .lf-board { --n: 5; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: .35rem; inline-size: min(100%, calc(var(--n) * 5.4rem)); margin-inline: auto; border-radius: .9rem; }
.lf .lf-board[data-size="3"] { inline-size: min(100%, 19rem); }
.lf .lf-row { display: contents; }
.lf .lf-gridcell { display: block; min-width: 0; }
.lf .lf-cell { display: grid; place-items: center; inline-size: 100%; aspect-ratio: 1; min-width: 44px; min-height: 44px; padding: 0; border: 2px solid #2b3954; border-radius: .7rem; background: #111827; color: inherit; }
.lf .lf-cell:hover:not(:disabled) { border-color: var(--accent); }
.lf .lf-cell:disabled { opacity: 1; cursor: default; }
.lf .lf-cell.lit { border-color: #c98a2e; background: radial-gradient(circle at 50% 50%, #6a4512 0%, #2c2112 62%, #1b1710 100%); box-shadow: 0 0 14px rgba(255, 184, 77, .35); }
.lf .lf-lantern { inline-size: 84%; block-size: 84%; overflow: visible; }
.lf .lf-lantern .lf-string { fill: none; stroke: #5d6a86; stroke-width: 1.6; stroke-linecap: round; }
.lf .lf-lantern .lf-cap { fill: #3a4560; }
.lf .lf-lantern .lf-body { fill: #151d2e; stroke: #7d8bab; stroke-width: 1.8; stroke-dasharray: 3 2.2; }
.lf .lf-lantern .lf-rib { fill: none; stroke: #4b5774; stroke-width: 1.3; }
.lf .lf-lantern .lf-flame, .lf .lf-lantern .lf-rays { display: none; }
.lf .lit .lf-lantern .lf-string { stroke: #e0b56a; }
.lf .lit .lf-lantern .lf-cap { fill: #b4432f; }
.lf .lit .lf-lantern .lf-body { fill: #ffb547; stroke: #ffe1a1; stroke-dasharray: none; }
.lf .lit .lf-lantern .lf-rib { stroke: #d9822b; }
.lf .lit .lf-lantern .lf-flame { display: inline; fill: #fff6cf; stroke: #ff8a3d; stroke-width: 1; }
.lf .lit .lf-lantern .lf-rays { display: inline; fill: none; stroke: #ffd27a; stroke-width: 2; stroke-linecap: round; }

.lf .lf-cell.lf-hint { position: relative; border: 3px dashed var(--accent); outline: 3px solid rgba(112, 225, 200, .35); outline-offset: 1px; }
.lf .lf-cell.lf-hint::after { content: '✦'; position: absolute; inset-block-start: -.55rem; inset-inline-end: -.45rem; display: grid; place-items: center; inline-size: 1.35rem; block-size: 1.35rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .8rem; line-height: 1; }
.lf .lf-cell.lf-hint:focus-visible { outline: 3px solid #ffd36e; }
.lf .lf-board.solved { box-shadow: 0 0 0 .3rem #13231f, 0 0 0 .45rem var(--accent); }

@keyframes lf-flip { 0% { transform: scaleX(1); } 50% { transform: scaleX(.15); } 100% { transform: scaleX(1); } }
.lf .lf-cell.lf-flip .lf-lantern { animation: lf-flip .22s ease-in-out; }
@media (prefers-reduced-motion: reduce) {
  .lf .lf-cell.lf-flip .lf-lantern { animation: none; }
}

.lf .lf-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.lf .lf-actions button { flex: 1 1 auto; padding-inline: .5rem; white-space: nowrap; }
.lf .lf-new { min-height: 44px; padding: .3rem .7rem; white-space: nowrap; }
.lf .kit-status:empty { display: none; }
.lf .kit-status { margin: 0; }

.lf .lf-result { display: grid; gap: .6rem; padding: 1rem; border: 2px solid var(--accent); border-radius: 1rem; background: #13231f; text-align: center; }
.lf .lf-result h2 { margin: 0; font-size: clamp(1.3rem, 5vw, 1.8rem); }
.lf .lf-result h2:focus { outline: none; }
.lf .lf-stars { margin: 0; color: #ffc861; font-size: 2.4rem; line-height: 1; letter-spacing: .15em; }
.lf .lf-result-note { display: grid; gap: .2rem; margin: 0; color: var(--muted); }
.lf .lf-result-actions { justify-content: center; }
.lf .lf-result-actions button { min-height: 52px; }

.lf .lf-how { border: 1px solid var(--border); border-radius: .85rem; background: #0c1220; }
.lf .lf-how summary { display: flex; align-items: center; min-height: 48px; padding: .5rem 1rem; cursor: pointer; font-weight: 700; }
.lf .lf-how-body { display: grid; gap: .6rem; padding: 0 1rem 1rem; }
.lf .lf-how-body p { margin: 0; }
.lf .lf-example { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; justify-items: center; gap: .5rem; padding: .75rem; border-radius: .7rem; background: var(--card); }
.lf .lf-example figure { display: grid; justify-items: center; gap: .35rem; min-width: 0; margin: 0; }
.lf .lf-example figcaption { color: var(--muted); font-size: .9rem; font-weight: 700; text-align: center; }
.lf .lf-example-arrow { align-self: center; font-size: 1.5rem; color: var(--muted); }
[dir="rtl"] .lf .lf-example-arrow { transform: scaleX(-1); }
.lf .lf-mini { display: grid; grid-template-columns: repeat(3, clamp(1.8rem, 8vw, 2.4rem)); gap: .2rem; }
.lf .lf-mini-cell { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid #2b3954; border-radius: .4rem; background: #111827; }
.lf .lf-mini-cell.lit { border-color: #c98a2e; background: #3a2a12; }
.lf .lf-mini-cell .lf-lantern { inline-size: 80%; block-size: 80%; }

.lf .lf-stats { display: grid; gap: .6rem; padding: 1rem; border: 1px solid var(--border); border-radius: .85rem; }
.lf .lf-stat-grid, .lf .lf-best { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: 0; text-align: center; }
.lf .lf-best { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lf .lf-stat-grid dt, .lf .lf-best dt { color: var(--muted); font-size: .85rem; overflow-wrap: break-word; hyphens: auto; }
.lf .lf-stat-grid dd { margin: 0; font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.lf .lf-best dd { margin: 0; font-size: .9rem; color: var(--muted); }
.lf .lf-best dd.lf-stars-small { color: #ffc861; font-size: 1.3rem; letter-spacing: .1em; }
.lf .lf-best-title { margin: .25rem 0 0; font-size: 1rem; color: var(--muted); }
.lf .lf-footer-actions { justify-content: flex-end; }

/* Phones: one board size for every mode, so the controls stay on the first screen. */
@media (max-width: 480px) {
  .lf .lf-board, .lf .lf-board[data-size="3"] { inline-size: min(100%, 16.5rem); }
}
@media (max-width: 380px) {
  .lf .lf-actions button span[aria-hidden="true"] { display: none; }
  .lf .lf-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lf .lf-board { gap: .3rem; }
}
