/* Arrows: 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; }

: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; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px 4px;
}
.name-block { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 12px; }
.name { margin: 0; font-family: var(--font-head); font-weight: 800; font-size: 30px; line-height: 1.15; }
.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: 50%; background: var(--dot); border: 2px solid var(--ink); flex: none; }

.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: 2px;
  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 .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; }
.count { margin: 0 0 8px; font-size: 18px; }

.board-wrap {
  background: var(--iconbg); border: 3px solid var(--ink); border-radius: 16px;
  padding: 6px; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom;
}
.board {
  --cell: 56px; --w: 5; --h: 5;
  position: relative; margin: 0 auto;
  width: calc(var(--w) * var(--cell)); height: calc(var(--h) * var(--cell));
  overflow: hidden; border-radius: 8px;
  box-shadow: 0 0 0 2px var(--rule);
  background-image:
    linear-gradient(to right, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

.arrow {
  position: absolute; padding: 0; margin: 0; border: 0; background: none; cursor: pointer;
  left: calc(var(--x) * var(--cell)); top: calc(var(--y) * var(--cell));
  width: var(--cell); height: var(--cell);
  transition: transform 0.38s cubic-bezier(0.45, 0, 0.9, 0.6);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.arrow.gone { display: none; }
.arrow .card {
  position: absolute; inset: 5px;
  display: grid; place-items: center;
  background: var(--card); border: 3px solid var(--ink); border-radius: 12px;
}
.glyph { width: 66%; height: 66%; fill: var(--ink); stroke: var(--ink); stroke-width: 1.4; stroke-linejoin: round; }
.glyph.d-U { transform: rotate(0deg); }
.glyph.d-R { transform: rotate(90deg); }
.glyph.d-D { transform: rotate(180deg); }
.glyph.d-L { transform: rotate(270deg); }

/* A solid orange outline means "try this one". A dashed outline means "this one is in the way". */
.arrow.hint .card { outline: 4px solid var(--dot); background: var(--iconbg); }
.arrow.blocker .card { outline: 4px dashed var(--accent-text); }
.arrow.nudge .card { animation: nudge 0.35s ease-in-out; }
.arrow.back .card { animation: pop 0.3s ease-out; }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: none; } }

.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: 0; grid-template-columns: repeat(3, 1fr); }
.dock .controls .btn { padding: 6px 4px; }
.dock.static { position: static; }
.zoombar { margin-top: 4px; }
.arrow { scroll-margin: 12px 12px 210px 12px; }
@media (max-height: 480px) { .dock { position: static; } .arrow { scroll-margin-bottom: 12px; } }
.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; }

/* ---------- 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; }

@media (prefers-reduced-motion: reduce) {
  .arrow { transition: none; }
  .arrow.nudge .card, .arrow.back .card { animation: none; }
}
