:root {
  color-scheme: dark;
  font: 16px/1.55 system-ui, sans-serif;
  background: #101820;
  color: #f2e8d5;
  --accent: #ffbb71;
  --muted: #b4b8bf;
  --line: #303942;
  --surface: #18222a;
  --inset: #111b23;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.page { max-width: 1160px; padding: 24px 32px; margin: auto; }
.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 245px;
  padding: 32px 42px;
  overflow: hidden;
  border: 1px solid #3e3f42;
  border-radius: 16px;
  background: linear-gradient(90deg, #111a24 3%, #111a24db 34%, #111a2430 67%, transparent),
    url("./media/valley.jpg") 72% 49% / cover no-repeat #162330;
}
.hero .brand, .label {
  color: var(--accent);
  font-size: .74rem;
  font-weight: 750;
  letter-spacing: .17em;
  text-transform: uppercase;
}
.hero p { margin: 9px 0 0; }
.hero h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 500; line-height: 1.12; }
.hero h1 { font-size: clamp(2.25rem, 6vw, 4.25rem); margin-top: 6px; }
.hero p:last-child { color: #d9d4ca; max-width: 25em; font-size: 1rem; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(275px, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.play { padding: 21px; }
.play-head, .play-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-head { margin-bottom: 15px; }
.label { margin: 0 0 4px; letter-spacing: .12em; }
.play-head h2 { font-size: clamp(1.34rem, 3vw, 2rem); }
.count { flex: 0 0 auto; display: grid; text-align: right; line-height: 1.3; margin: 0; }
.count strong { font-size: 1.4rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.count span { font-size: .72rem; color: var(--muted); }
.board-wrap {
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 9px;
  background-color: var(--inset);
  background-image: radial-gradient(#82919d22 1px, transparent 1px);
  background-size: 14px 14px;
  border: 1px solid #36414a;
}
.board { display: grid; grid-template-columns: repeat(var(--columns, 4), 1fr); gap: 3px; width: min(100%, calc(var(--columns, 4) * 65px)); }
.tile {
  display: block;
  position: relative;
  min-width: 0;
  padding: 0;
  aspect-ratio: 1;
  border: 1px solid #3e4c58;
  border-radius: 6px;
  background: #232f39;
  color: #8398ab;
}
button.tile { cursor: pointer; }
.tile[aria-disabled="true"] { cursor: default; }
.tile:focus-visible { z-index: 1; }
.tile.empty { background: #131d25a8; border: 1px dashed #34414c; }
.tile.powered { background: #3b2d29; border-color: #8e6550; color: #ffc276; }
.tile.hinted::after { content: ""; position: absolute; inset: 2px; border: 1px dashed #ffce92; border-radius: 3px; pointer-events: none; }
.tile .center, .arm { position: absolute; pointer-events: none; }
.center {
  display: grid;
  place-items: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 1.35em;
  width: 1.35em;
  border-radius: 50%;
  font-size: clamp(.65rem, 2.5vw, 1.08rem);
  line-height: 1;
  background: #232f39;
}
.tower .center, .post .center { box-shadow: 0 0 0 1px currentColor; }
.powered .center { background: #51392c; text-shadow: 0 0 9px #ffab5b; }
.arm { background: currentColor; border-radius: 1px; }
.arm-0, .arm-2 { left: calc(50% - 2px); width: 4px; height: 51%; }
.arm-1, .arm-3 { top: calc(50% - 2px); height: 4px; width: 51%; }
.arm-0 { top: 0; }
.arm-1 { right: 0; }
.arm-2 { bottom: 0; }
.arm-3 { left: 0; }
.powered .arm { box-shadow: 0 0 8px #f7a44a5c; }
.play-foot { min-height: 45px; padding-top: 10px; flex-wrap: wrap; }
.status { margin: 0; color: var(--muted); font-size: .85rem; }
.status.won { color: var(--accent); font-weight: 700; }
.side { display: grid; gap: 12px; }
.side .panel { padding: 18px; }
.side h2 { font-size: 1.33rem; }
.guide p { margin: 7px 0 0; color: var(--muted); font-size: .91rem; }
.guide .keys { font-size: .76rem; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; list-style: none; padding: 0; margin: 12px 0; font-size: .8rem; }
.glyph { color: #bacbe0; }
.glyph.glow, .glyph.signal { color: var(--accent); }
.actions { display: flex; gap: 8px; }
.actions button, .primary {
  border: 1px solid #5a5758;
  border-radius: 7px;
  padding: 7px 10px;
  background: #26323a;
  color: #f2e8d5;
  font-size: .85rem;
  font-weight: 650;
  cursor: pointer;
}
.actions button:disabled { color: #8e96a0; background: transparent; }
.primary { background: var(--accent); color: #2b221c; border-color: var(--accent); }
.guide .hint { color: var(--accent); }
.guide .hint:empty { margin: 0; }
.route ol { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 5px; }
.route button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid #384652;
  border-radius: 6px;
  background: var(--inset);
  color: #e7e1d7;
  text-align: left;
  font-size: .86rem;
  cursor: pointer;
}
.route button[aria-current="step"] { border-color: #aa794c; background: #3d302a; color: #ffe0b5; }
.route button:disabled { color: #a4a9af; cursor: default; }
.route small { color: var(--muted); flex-shrink: 0; }
.route button[aria-current="step"] small { color: #ffc78c; }
footer { padding: 14px 0 0; color: var(--muted); font-size: .77rem; }
@media (hover: hover) {
  button.tile:not([aria-disabled="true"]):hover { border-color: #e8b17b; }
  .actions button:enabled:hover, .route button:enabled:not([aria-current="step"]):hover { border-color: #b59578; }
}
@media (max-width: 760px) {
  .page { padding: 14px; }
  .layout { grid-template-columns: 1fr; }
  .hero { min-height: 188px; padding: 20px; background-position: 76% center; }
  .play { padding: 13px; }
  .board-wrap { padding: 8px; }
  .side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .side { grid-template-columns: 1fr; }
}
