:root {
  --bg: #f7f5f0;
  --fg: #1c1d22;
  --muted: #62636b;
  --line: #d9d5cc;
  --card: #ffffff;
  --card2: #f0ede6;
  --k0: #d4790f;
  --k1: #12857a;
  --k2: #8a3f9e;
  --you: #1d4ed8;
  --you-soft: #dce6ff;
  --house: #9a3412;
  --house-soft: #fbe2d3;
  --hit: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141519;
    --fg: #eceef2;
    --muted: #9a9ea9;
    --line: #33353d;
    --card: #1e2026;
    --card2: #262830;
    --k0: #f29a33;
    --k1: #33b5a8;
    --k2: #c07ad3;
    --you: #86a8ff;
    --you-soft: #1e2a4a;
    --house: #f0895a;
    --house-soft: #45261a;
    --hit: #f87171;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
main {
  max-width: 460px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px 4px;
}
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
h1 {
  font-size: 22px;
  margin: 0;
}
h2 {
  font-size: 18px;
  margin: 12px 0 4px;
}
p {
  margin: 6px 0;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
.small {
  font-size: 12px;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  padding: 9px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--fg);
  cursor: pointer;
}
button.primary {
  background: var(--you);
  border-color: var(--you);
  color: #fff;
  font-weight: 600;
  padding: 9px 18px;
}
@media (prefers-color-scheme: dark) {
  button.primary {
    color: #0b1020;
  }
}
#play {
  width: 100%;
  margin-top: 4px;
}

/* A piece: its shape, then hit (bold) and grit (grey). */
.pc {
  position: relative;
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 14px 2px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  font: inherit;
  color: inherit;
}
.pc svg {
  width: 28px;
  height: 28px;
}
.pc .n {
  display: flex;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.pc .p {
  font-weight: 800;
}
.pc .g {
  color: var(--muted);
}
.pc.took {
  opacity: 0.38;
}
.pc .tag {
  position: absolute;
  top: 1px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
}
.pc.you .tag {
  color: var(--you);
}
.pc.house .tag {
  color: var(--house);
}
button.pc:active {
  background: var(--card2);
}
button.pc:focus-visible {
  outline: 2.5px solid var(--you);
  outline-offset: 1px;
}

/* The first screen's worked example. */
.lead {
  font-size: 16px;
}
.example {
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.ex-rule {
  font-size: 14px;
  padding: 3px 8px;
  border-left: 4px solid var(--house);
  background: var(--house-soft);
  border-radius: 0 6px 6px 0;
}
.ex-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}
.ex-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.ex-who {
  white-space: nowrap;
}
.ex-who.you {
  color: var(--you);
  font-weight: 700;
}
.ex-who.house {
  color: var(--house);
  font-weight: 700;
}
.ex-arrow {
  color: var(--muted);
}
.pc.mini {
  padding: 4px 6px;
  flex-direction: row;
  gap: 4px;
}
.pc.mini svg {
  width: 20px;
  height: 20px;
}
.example figcaption {
  font-size: 13px;
  color: var(--muted);
}
.legend > span {
  white-space: nowrap;
}
.tri-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.tri-icons svg {
  width: 13px;
  height: 13px;
}

/* The table. */
.rule {
  font-size: 15px;
  margin: 8px 0;
  padding: 5px 10px;
  border-left: 4px solid var(--house);
  background: var(--house-soft);
  border-radius: 0 6px 6px 0;
}
#pool {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin: 5px 2px 6px;
}
.stats {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 2px;
  font-size: 14px;
}
#mode {
  color: var(--muted);
}
#mode.practice {
  color: var(--you);
  font-weight: 600;
}
.lines {
  display: grid;
  grid-template-columns: 50px repeat(5, 1fr);
  gap: 5px;
  align-items: center;
}
.who {
  font-size: 13px;
  font-weight: 700;
}
.who.you {
  color: var(--you);
}
.who.house {
  color: var(--house);
}
.slot {
  position: relative;
  min-height: 58px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.slot .pc {
  border: 0;
  background: transparent;
  padding: 2px 0;
}
.slot.front {
  outline: 2.5px solid var(--fg);
  outline-offset: 1px;
}
.slot.out .pc {
  opacity: 0.25;
}
.slot.out {
  border-style: solid;
}
.landscape-only {
  display: none;
}
.hit {
  position: absolute;
  top: -10px;
  right: -6px;
  z-index: 1;
  font-weight: 800;
  font-size: 13px;
  color: var(--hit);
  background: var(--bg);
  border-radius: 6px;
  padding: 0 3px;
}
#msg {
  min-height: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0;
}
#msg:empty {
  display: none;
}
#skip {
  width: 100%;
}
#done {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
#done pre {
  font: 15px/1.4 ui-monospace, Menlo, Consolas, monospace;
  margin: 6px 0 8px;
  white-space: pre-wrap;
}
.row {
  display: flex;
  gap: 8px;
}
.row button {
  flex: 1;
}

/* A phone held sideways: the table on the left, the lines and the result on the right, no scroll. */
@media (orientation: landscape) and (max-height: 500px) {
  main {
    max-width: 860px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  header {
    padding-bottom: 3px;
  }
  h1 {
    font-size: 19px;
  }
  #game {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  #intro {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }
  #intro > * {
    grid-column: 1;
  }
  #intro .example {
    grid-column: 2;
    grid-row: 1 / span 5;
    align-self: start;
    margin-top: 12px;
  }
  h2 {
    margin-top: 6px;
  }
  .rule {
    margin: 5px 0;
  }
  .pc {
    padding-top: 12px;
    padding-bottom: 3px;
  }
  .pc svg {
    width: 24px;
    height: 24px;
  }
  .slot {
    min-height: 50px;
  }
  #msg {
    margin: 4px 0;
    min-height: 20px;
  }
  .landscape-only {
    display: block;
  }
  .portrait-only {
    display: none;
  }
  #done {
    padding: 6px 10px;
  }
  #done b {
    font-size: 14px;
  }
  #done pre {
    margin: 4px 0 6px;
  }
  #done .row button {
    padding: 7px 0;
  }
  .kiln-maker {
    padding-top: 4px;
  }
}

/* The maker line under the game (game-kiln#144): small, the same on every sketch. */
.kiln-maker {
  margin: 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.kiln-maker a {
  color: inherit;
}
