/* Arrow Cube: game styles. Colors and fonts come from ../shared/eg-theme.css */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.45;
}
[hidden] { display: none !important; }

.noscript { margin: 16px; padding: 16px; border: 2px solid var(--ink); border-radius: 12px; background: #FBF6EA; color: #1F3246; }

/* The cube is dark so the colored arrows stand out. High contrast makes it black and white. */
:root {
  --f0: #1D2C4A; --f1: #182640; --f2: #1A2946; --f3: #1F2F4E; --f4: #263862; --f5: #121D33;
  --grid: #3A4E74; --edge: #8EA3C7; --stage: #0E1728; --hintc: #FFFFFF;
}
:root[data-contrast="high"] {
  --f0: #000; --f1: #000; --f2: #000; --f3: #000; --f4: #000; --f5: #000;
  --grid: #555; --edge: #FFF; --stage: #000; --hintc: #FFA040;
}

:focus-visible { outline: 4px solid var(--mid); outline-offset: 2px; }
/* Headings and the board frame take focus only so screen readers land in the right place; they are not controls. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

/* ---------- header and settings ---------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px;
  padding: 8px 16px 4px;
}
.name-block { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.name { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 24px; line-height: 1.15; white-space: nowrap; }
.kind { margin: 0; white-space: nowrap; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.kind::before { content: ""; width: 14px; height: 14px; border-radius: 2px; background: var(--dot); border: 2px solid var(--ink); flex: none; } /* square = Challenge */

.textlink {
  color: var(--ink); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px; white-space: nowrap;
}
.linkbtn { background: none; border: 0; cursor: pointer; }

.settings {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 4px 16px 10px; border-bottom: 2px solid var(--rule);
}
.settings-label { font-size: 18px; margin-right: 2px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px; padding: 8px 16px;
  font: inherit; font-weight: 700; font-size: 20px; line-height: 1.2;
  color: var(--ink); background: var(--card);
  border: 2px solid var(--ink); border-radius: 12px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn.small { min-height: 46px; font-size: 18px; padding: 6px 14px; }
.btn.primary { background: var(--ink); color: var(--card); }
.btn[aria-disabled="true"] { opacity: 0.5; border-style: dashed; cursor: default; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--card); }

/* ---------- layout ---------- */
main { padding: 12px 12px 40px; max-width: 760px; margin: 0 auto; }
.h2 { margin: 8px 0 12px; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.panel { background: var(--card); border: 2px solid var(--rule); border-radius: 20px; padding: 4px 18px; margin: 0 0 16px; }
.howto { margin: 14px 0; font-size: 20px; }
.note { margin: 12px 0 0; font-size: 18px; }

.msg {
  margin: 0 0 8px; padding: 8px 12px;
  font-size: 19px; line-height: 1.35;
  background: var(--card); border: 2px solid var(--rule); border-radius: 12px;
}
.msg:empty { display: none; }

/* ---------- choose a puzzle ---------- */
.plist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ptile {
  width: 100%; min-height: 92px; padding: 12px 14px; text-align: left;
  font: inherit; color: var(--ink); background: var(--card);
  border: 3px solid var(--ink); border-radius: 20px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.ptile .pn { font-family: var(--font-head); font-weight: 800; font-size: 26px; line-height: 1.1; }
.ptile .pz { font-size: 18px; }
.ptile .ps { font-size: 18px; min-height: 1.3em; }
.ptile.done .ps, .ptile.going .ps { font-weight: 700; color: var(--accent-text); }

/* ---------- playing ---------- */
.titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.titlerow .h2 { font-size: 26px; margin: 4px 0; }
.stats { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 16px; row-gap: 2px; margin: 0 0 8px; }
.count, .tries { margin: 0; font-size: 18px; }
.tries { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.pips { display: inline-flex; gap: 4px; }
.pip { width: 16px; height: 16px; border: 2px solid var(--ink); border-radius: 3px; background: var(--dot); }
.pip.used { background: transparent; border-style: dashed; }

.board-wrap {
  background: var(--stage); border: 3px solid var(--ink); border-radius: 16px;
  padding: 6px; overflow: hidden; cursor: grab;
  touch-action: none;                /* a finger on the cube turns it in any direction; the page does not scroll here */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.board-wrap.dragging { cursor: grabbing; }
.board {
  --box: 340px;
  position: relative; margin: 0 auto; line-height: 0;
  width: var(--box); height: var(--box);
}
.board svg { display: block; width: 100%; height: 100%; }
.board.over { opacity: 0.55; pointer-events: none; }

/* Faces */
.face .fill { stroke: none; }
.face .fill, .face .grid, .face .edge { pointer-events: none; }  /* only the arrows take taps */
.face-0 .fill { fill: var(--f0); } .face-1 .fill { fill: var(--f1); } .face-2 .fill { fill: var(--f2); }
.face-3 .fill { fill: var(--f3); } .face-4 .fill { fill: var(--f4); } .face-5 .fill { fill: var(--f5); }
.face .grid { fill: none; stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.face .edge { fill: none; stroke: var(--edge); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* One arrow = (on each side it touches) a halo that shows hints, blockers and touches, the colored line with its head,
   and a wide invisible touch area. Sizes are in cells. */
.arrow { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.arrow.gone { display: none; }
.arrow.moving { visibility: hidden; }
.arrow .line, .fxa .line { fill: none; stroke: var(--c); stroke-width: 0.15; stroke-linecap: round; stroke-linejoin: round; }
.arrow .head, .fxa .head { fill: var(--c); stroke: var(--c); stroke-width: 0.04; stroke-linejoin: round; }
:root[data-contrast="high"] .arrow .line, :root[data-contrast="high"] .fxa .line { stroke: #FFF; }
:root[data-contrast="high"] .arrow .head, :root[data-contrast="high"] .fxa .head { fill: #FFF; stroke: #FFF; }
.arrow .halo { fill: none; stroke: transparent; stroke-width: 0.62; stroke-linecap: round; stroke-linejoin: round; }
.arrow .hit { fill: none; stroke: transparent; stroke-width: 0.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: stroke; }

/* A solid bright band means "try this one". A dashed band means "this one is in the way". */
.arrow.hint .halo { stroke: var(--hintc); }
.arrow.blocker .halo { stroke: var(--hintc); stroke-dasharray: 0.3 0.2; stroke-linecap: butt; }
.arrow.touch .halo { stroke: #7FB2FF; opacity: 0.5; }
.arrow:focus-visible .halo { stroke: #7FB2FF; }

.dock {
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 10px; padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: var(--bg); border-top: 2px solid var(--rule);
}
.dock .controls { margin-top: 8px; grid-template-columns: repeat(2, 1fr); }
.dock .turnbar { margin-top: 6px; }
.dock.static { position: static; }
@media (max-height: 480px) { .dock { position: static; } }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.controls.two { grid-template-columns: 1fr 1fr; }
.controls .btn { min-height: 56px; font-size: 19px; }

.turnbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.turnbar .btn { min-height: 60px; padding: 4px 2px; font-size: 18px; line-height: 1.15; }

/* ---------- all clear ---------- */
.clear { margin-top: 16px; padding: 18px; }
.clear-title { margin: 0 0 6px; font-family: var(--font-head); font-weight: 800; font-size: 36px; line-height: 1.1; }
.clear p { margin: 0 0 14px; }
.clear-buttons { display: grid; gap: 8px; }
.clear-buttons .btn { min-height: 56px; }
