:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #2b2723;
  --muted: #6f675c;
  --line: #d8d0c2;
  --accent: #c46a1b;
  --accent-dark: #a4560f;
  --sand: #f7efe0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, #fbf6ec 0%, var(--bg) 60%);
  line-height: 1.5;
  padding: 0 16px 48px;
}

/* ---- Header ---- */

.page-header {
  max-width: 760px;
  margin: 32px auto 8px;
  text-align: left;
}

.page-header h1 {
  /* Scales with viewport and never wraps, so it stays on one row even on
     a narrow phone, while capping at 1.9rem on desktop. */
  font-size: clamp(0.95rem, 5vw, 1.9rem);
  white-space: nowrap;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}

.howto-wrap {
  max-width: 760px;
  margin: 16px auto 0;
  text-align: center;
}

.howto {
  display: inline-block;
  text-align: left;
  margin: 0 auto;
  padding: 14px 22px 14px 38px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.howto li { margin: 2px 0; }
.howto strong { color: var(--accent-dark); }

/* ---- App layout ---- */

#app {
  max-width: 760px;
  margin: 24px auto 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

#app > p { margin: 2px 0; }

.svg-container,
.svg-container-wide {
  display: block;
  position: relative;
  width: 100%;
  vertical-align: top;
  overflow: hidden;
  /* touch-action:none on the <svg> below is not honoured by every mobile
     browser (notably iOS Safari), so also disable panning, text selection
     and the long-press callout on the HTML container itself — otherwise the
     touch is hijacked as a scroll/selection and camels won't drag. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(60, 45, 20, 0.06);
}

/* SVGs scale to the full width of their card, keeping their aspect ratio.
   touch-action:none stops mobile browsers hijacking the touch for
   scroll/zoom, so camels and tiles can actually be dragged on a phone. */
.svg-container svg,
.svg-container-wide svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Board SVG ---- */

#boardsvg rect {
  fill: #fffdf8;
  stroke: var(--line);
  stroke-width: 1.5px;
  rx: 5;
}

.camel {
  stroke: #3a322a;
  stroke-width: 1px;
  stroke-linejoin: round;
  cursor: grab;
}

.camel:active { cursor: grabbing; }

.tile { cursor: grab; }

.posnum {
  fill: #b3a890;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
}

/* ---- Simulate button ---- */

button {
  align-self: center;
  margin: 10px 0;
  padding: 11px 30px;
  font: 600 1rem/1 inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--accent-dark);
  transition: transform 0.05s ease, background 0.15s ease;
}

button:hover { background: var(--accent-dark); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark); }

/* ---- Results table ---- */

.results-table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(60, 45, 20, 0.06);
}

.results-table.is-empty { display: none; }

.results-table table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.results-table th,
.results-table td {
  padding: 9px 12px;
  text-align: right;
}

.results-table thead th {
  background: var(--ink);
  color: #f4f1ea;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.results-table tbody td:first-child,
.results-table thead th:first-child {
  text-align: center;
  width: 56px;
}

.results-table tbody td img {
  display: block;
  margin: 0 auto;
  /* The camel PNGs have a solid white background; multiply blends that
     white into the row colour behind it (white / cream / hover) so it
     reads as transparent, while the coloured camel stays visible. */
  mix-blend-mode: multiply;
}

.results-table tbody tr:nth-child(even) { background: #faf6ee; }
.results-table tbody tr:hover { background: #f3ead8; }

/* ---- Mobile: use almost the full screen width ---- */

@media (max-width: 700px) {
  body { padding: 0 6px 28px; }
  .page-header,
  #app,
  .howto-wrap,
  .page-footer { max-width: 100%; }
  .howto {
    display: block;
    font-size: 0.85rem;
    padding: 10px 14px 10px 28px;
  }
  .svg-container,
  .svg-container-wide {
    padding: 6px;
    border-radius: 10px;
  }
  .results-table th,
  .results-table td { padding: 8px 8px; }
  .results-table thead th { font-size: 0.74rem; }
}

/* ---- Footer ---- */

.page-footer {
  max-width: 760px;
  margin: 28px auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
