/* Rutegåta: a nonogram on bare warp. */
.stage.rg { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 8px 8px 12px; max-width: 1120px }
.rg-play { min-width: 0; display: flex; flex-direction: column; align-items: center }
.rg-side { display: none }
@media (min-width: 980px) {
  .stage.rg { grid-template-columns: minmax(0, 1fr) 300px; padding-top: 14px; align-items: start }
  .rg-side { display: block; position: sticky; top: 12px }
}

/* The bar above the board: which puzzle, and arrows to step through them */
.rg-top { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; max-width: 480px; margin-bottom: 6px }
.rg-arrow { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--pill-border); background: var(--card); color: var(--ink); font: 500 26px/1 Barlow, sans-serif; cursor: pointer; padding: 0 0 3px }
.rg-arrow:hover:not(:disabled) { border-color: var(--ink-3) }
.rg-arrow:disabled { opacity: .35; cursor: default }
.rg-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; padding: 2px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer; font-family: Barlow, sans-serif }
.rg-title:hover { background: rgba(255, 255, 255, .6) }
.rg-title-main { font: 700 17px/1.15 Barlow, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100% }
.rg-title-sub { font: 600 13px/1.2 Barlow, sans-serif; color: var(--ink-3); font-variant-numeric: tabular-nums }
.rg-title-sub::after { content: " · prøveklut ▾"; font-weight: 500 }

/* The board: clues on top and to the left, the grid of ruter */
.rg-board { --cell: 24px; --clue: 13px; --rowclue: 40px; --colclue: 40px; display: grid; grid-template-columns: var(--rowclue) auto; grid-template-rows: var(--colclue) auto; touch-action: none; user-select: none; -webkit-user-select: none }
.rg-cols { display: flex; align-items: stretch }
.rg-rows { display: flex; flex-direction: column }
.rg-clue { font: 600 var(--clue)/1.08 Barlow, sans-serif; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); transition: color .2s, opacity .2s }
.rg-cols .rg-clue { width: var(--cell); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: calc(var(--clue) * .35); border-radius: 6px 6px 0 0 }
.rg-rows .rg-clue { height: var(--cell); display: flex; justify-content: flex-end; align-items: center; gap: calc(var(--clue) * .42); padding-right: calc(var(--clue) * .5); border-radius: 6px 0 0 6px }
.rg-cols .rg-clue:nth-child(2n) { background: rgba(207, 194, 162, .22) }
.rg-rows .rg-clue:nth-child(2n) { background: rgba(207, 194, 162, .22) }
.rg-clue.on { background: rgba(30, 75, 143, .12) !important; color: var(--sign-blue) }
.rg-clue.done { color: var(--ink-3); opacity: .42 }
.rg-clue.done.on { opacity: .6 }
.rg-grid { image-rendering: pixelated; box-shadow: 0 1px 2px rgba(42, 35, 31, .18), 0 10px 26px rgba(42, 35, 31, .14); cursor: pointer; touch-action: none; outline-offset: 3px }
.rg-solved .rg-grid { cursor: default }
.rg-solved .rg-clue { opacity: .3 }

/* Tools under the board */
.rg-tools { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; min-height: 44px }
.rg-mode { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--card); border: 1px solid var(--pill-border) }
.rg-mode button { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font: 600 16px Barlow, sans-serif; cursor: pointer; touch-action: manipulation }
.rg-mode button[aria-pressed="true"] { background: var(--w-svart); color: #fff }
.ico-fill { width: 13px; height: 13px; border-radius: 2px; background: var(--w-svart); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .0) }
[aria-pressed="true"] > .ico-fill { background: var(--w-kvit) }
.ico-cross { position: relative; width: 13px; height: 13px }
.ico-cross::before, .ico-cross::after { content: ""; position: absolute; left: 50%; top: -1px; width: 2px; height: 15px; margin-left: -1px; border-radius: 1px; background: currentColor; transform: rotate(45deg) }
.ico-cross::after { transform: rotate(-45deg) }
.rg-tool { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--pill-border); background: var(--card); color: var(--ink); font: 600 16px Barlow, sans-serif; cursor: pointer; touch-action: manipulation }
.rg-tool:hover:not(:disabled) { border-color: var(--ink-3) }
.rg-tool:disabled { opacity: .4; cursor: default }
.rg-tool[hidden], .rg-mode button[hidden] { display: none }
.rg-mode:has(button[hidden]) { display: none }
.rg-next { background: var(--sign-blue); border-color: var(--sign-blue); color: #fff }
@media (max-width: 400px) { .rg-mode button { padding: 0 11px } .rg-tool { padding: 0 13px } .rg-tools { gap: 6px } }

/* The sampler: every puzzle a square, woven when solved */
.rg-side h2 { display: flex; justify-content: space-between; align-items: baseline }
.rg-count { font: 600 13px Barlow, sans-serif; letter-spacing: 0; text-transform: none; color: var(--ink-3) }
.rg-side-lead { margin: 0 0 10px; font-size: 14px; color: var(--ink-2) }
.rg-sampler { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; padding: 10px; border-radius: 8px; background: var(--linen); box-shadow: inset 0 0 0 1px rgba(207, 194, 162, .7) }
.rg-tile { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; border: 1.5px dashed var(--warp); border-radius: 4px; background: repeating-linear-gradient(90deg, rgba(207, 194, 162, .55) 0 2px, transparent 2px 6px), var(--linen); color: var(--ink-3); cursor: pointer; overflow: hidden; font-family: Barlow, sans-serif }
.rg-tile:hover { border-color: var(--ink-3); color: var(--ink) }
.rg-tile .rg-q { font: 700 24px/1 Barlow, sans-serif }
.rg-tile .rg-size { margin-top: 3px; font: 600 11px/1 Barlow, sans-serif; font-variant-numeric: tabular-nums }
.rg-tile.is-started::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 1px; background: var(--w-svart) }
.rg-tile.is-done { border: 0; background: var(--w-kvit); box-shadow: 0 1px 2px rgba(42, 35, 31, .25) }
.rg-tile.is-done canvas { width: 100%; height: 100%; image-rendering: pixelated }
.rg-tile[aria-current="true"] { outline: 3px solid var(--sign-blue); outline-offset: 2px }
.rg-sheet .rg-sampler { margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)) }

/* The solved sheet */
.rg-done-head { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: start; margin-top: 4px }
.rg-done-art { width: 112px; height: 112px; image-rendering: pixelated; border-radius: 4px; box-shadow: 0 1px 2px rgba(42, 35, 31, .25), 0 6px 16px rgba(42, 35, 31, .16) }
.rg-done-head p { margin: 0; font-size: 15px; line-height: 1.45 }
@media (max-width: 420px) { .rg-done-head { grid-template-columns: 84px 1fr; gap: 12px } .rg-done-art { width: 84px; height: 84px } .sheet-body { padding: 18px 16px 16px } }
@media (prefers-reduced-motion: reduce) { .rg-clue { transition: none } }
