:root {
  --text: #f4f2ee;
  --muted: rgba(244, 242, 238, 0.6);
  --glass: rgba(16, 17, 16, 0.55);
  --line: rgba(255, 255, 255, 0.14);
  --pick: #f4f2ee;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; cursor: grab; touch-action: none; }
canvas#view.drag { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.top {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 0; pointer-events: none;
}
.top > * { pointer-events: auto; }
h1 { margin: 0; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
     text-shadow: 0 1px 6px rgba(0,0,0,0.6); }
.round { width: 32px; height: 32px; border-radius: 50%; background: var(--glass); border: 1px solid var(--line);
         font-size: 14px; font-style: italic; font-family: Georgia, serif;
         backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.round[aria-expanded="true"] { background: var(--text); color: #111; }

.bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: calc(100vw - 16px);
}
.caption { margin: 0; font-size: 12.5px; color: var(--text); text-align: center; text-shadow: 0 1px 6px rgba(0,0,0,0.7);
           padding: 0 8px; }
.rows { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
        background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px;
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.group { display: flex; gap: 4px; align-items: center; }
.group + .group { border-left: 1px solid var(--line); padding-left: 6px; }

.dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; position: relative;
       font-size: 12px; font-weight: 600; color: var(--muted); }
.dot .sw { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.3); }
.dot[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--pick); color: var(--text); }
.dot.word { width: auto; border-radius: 999px; padding: 0 10px; font-weight: 500; font-size: 12px; }
.dot:focus-visible { outline: 1.5px solid var(--pick); outline-offset: 1px; }
@media (hover: hover) { .dot:hover { background: rgba(255,255,255,0.1); } }
.sw.herring { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.15) 0 2px, transparent 2px 5px),
                                repeating-linear-gradient(-45deg, rgba(0,0,0,0.15) 0 2px, transparent 2px 5px); }
.sw.tiles { background-image: linear-gradient(rgba(0,0,0,0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.3) 1px, transparent 1px);
            background-size: 7px 7px; }
.sw.planks { background-image: linear-gradient(rgba(0,0,0,0.22) 1px, transparent 1px); background-size: 100% 5px; }
.sw.ribbed { background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.2) 0 1.5px, transparent 1.5px 4px); }

.sheet {
  position: fixed; top: 58px; right: 12px; width: 360px; max-height: calc(100vh - 190px); overflow: auto;
  background: rgba(16, 17, 16, 0.86); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); font-size: 13px; line-height: 1.4;
}
.sheet .close { position: absolute; top: 6px; right: 10px; font-size: 22px; color: var(--muted); }
.plan { display: block; width: 100%; border-radius: 8px; margin-top: 18px; }
.sheet h2 { font-size: 15px; font-weight: 600; margin: 12px 0 2px; }
.sheet h3 { font-size: 11px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.muted { color: var(--muted); margin: 0 0 8px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet td { padding: 5px 0; border-top: 1px solid var(--line); vertical-align: top; }
.sheet td small { display: block; color: var(--muted); font-size: 11.5px; }
.sheet td.p { text-align: right; white-space: nowrap; padding-left: 10px; }
.sheet a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(255,255,255,0.35); text-underline-offset: 2px; }
.sheet ul { margin: 0; padding-left: 16px; }
.sheet li { margin: 3px 0; }
.fine { color: var(--muted); font-size: 11px; margin: 12px 0 0; }

.hint { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); font-size: 12.5px; color: var(--text);
        background: var(--glass); padding: 7px 14px; border-radius: 999px; pointer-events: none; transition: opacity 0.8s;
        backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hint.gone { opacity: 0; }
.loading { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--text); transition: width 0.3s, opacity 0.4s; }

@media (max-width: 640px) {
  .bar { width: calc(100vw - 16px); }
  .caption { font-size: 12px; }
  .rows { width: 100%; border-radius: 18px; row-gap: 4px; column-gap: 2px; padding: 6px 4px; }
  .group.layout { width: 100%; justify-content: center; }
  .group.layout + .group { border-left: 0; padding-left: 0; }
  .group + .group { padding-left: 4px; }
  .dot { width: 30px; height: 30px; }
  .dot .sw { width: 20px; height: 20px; }
  .sheet { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 78vh; border-radius: 16px 16px 0 0;
           border-bottom: 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .plan { max-height: 28vh; object-fit: contain; background: #1a1a1a; }
  body.info-open .bar { display: none; }
}
@media (max-width: 360px) {
  .dot { width: 27px; height: 27px; }
  .dot .sw { width: 18px; height: 18px; }
}
