:root {
  --cell-red: #eb7594;
  --cell-red-light: #f7b8c9;
  --cell-green: #91c94b;
  --cell-green-light: #c8e59e;
  --cell-blue: #73b8e6;
  --cell-blue-light: #b9ddf4;
  --cell-yellow: #f2cc4d;
  --cell-yellow-light: #f9e8a2;
  --cell-orange: #e88739;
  --cell-orange-light: #f5bd8d;
  color: #262117;
  background: #eee8dc;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgb(255 255 255 / 75%), transparent 35rem),
    #eee8dc;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.page-header,
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-header {
  margin-bottom: 38px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: #a4482c;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 6vw, 4.75rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 500;
}

.intro {
  margin-bottom: 0;
  color: #736b5e;
  font-size: 1rem;
}

.server-status,
.dimensions {
  flex: 0 0 auto;
  border: 1px solid #d3cab9;
  border-radius: 999px;
  padding: 8px 12px;
  color: #736b5e;
  background: rgb(255 255 255 / 45%);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.server-status::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #c4963d;
  content: "";
}

.server-status.is-online::before {
  background: #4d8b62;
}

.server-status.is-offline::before {
  background: #b64b3d;
}

.card-stage {
  border: 1px solid rgb(87 72 49 / 16%);
  border-radius: 26px;
  padding: 24px;
  background: rgb(255 255 255 / 35%);
  box-shadow: 0 24px 70px rgb(75 57 27 / 9%);
}

.editor-controls {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(210px, 1.1fr) minmax(150px, 0.7fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 16px;
  border-top: 1px solid #d8cfbf;
  padding-top: 20px;
}

.field {
  display: grid;
  gap: 7px;
  color: #62594c;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  border: 1px solid #bbb09e;
  border-radius: 9px;
  padding: 0 11px;
  color: #262117;
  background: #fffdf8;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.field input:focus,
.field select:focus,
.button:focus-visible,
.paint-swatch:focus-visible {
  outline: 3px solid rgb(164 72 44 / 25%);
  outline-offset: 2px;
}

.field input[aria-invalid="true"] {
  border-color: #b64b3d;
}

.palette,
.star-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.palette legend,
.star-tools legend {
  width: 100%;
  margin-bottom: 7px;
  color: #62594c;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.star-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

.marker-tool {
  min-height: 30px;
  border: 1px solid #bbb09e;
  border-radius: 8px;
  padding: 0 9px;
  color: #5f574b;
  background: #fffdf8;
  font-size: 0.7rem;
  font-weight: 750;
  cursor: pointer;
}

.marker-tool span {
  margin-right: 3px;
  color: #444640;
}

.marker-tool[aria-pressed="true"] {
  border-color: #302a21;
  color: #fffdf8;
  background: #343c34;
  box-shadow: 0 0 0 2px rgb(48 42 33 / 18%);
}

.marker-tool[aria-pressed="true"] span {
  color: #fffdf8;
}

.paint-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border: 2px solid #fffdf8;
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 0 0 1px #bdb3a2;
  color: transparent;
  cursor: pointer;
}

.paint-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 3px #302a21;
}

.paint-swatch.erase {
  color: #746b5e;
  background:
    linear-gradient(135deg, transparent 44%, #b64b3d 45%, #b64b3d 55%, transparent 56%),
    #fffdf8;
  font-size: 0;
}

.color-red,
.is-red {
  --cell-light: var(--cell-red-light);
  background-color: var(--cell-red);
}

.color-green,
.is-green {
  --cell-light: var(--cell-green-light);
  background-color: var(--cell-green);
}

.color-blue,
.is-blue {
  --cell-light: var(--cell-blue-light);
  background-color: var(--cell-blue);
}

.color-yellow,
.is-yellow {
  --cell-light: var(--cell-yellow-light);
  background-color: var(--cell-yellow);
}

.color-orange,
.is-orange {
  --cell-light: var(--cell-orange-light);
  background-color: var(--cell-orange);
}

.editor-actions,
.saved-card-controls {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 14px;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.button.primary {
  color: #fffdf8;
  background: #343c34;
}

.button.secondary {
  border-color: #bbb09e;
  color: #534b40;
  background: #fffdf8;
}

.button.quiet {
  color: #8a4032;
  background: transparent;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.saved-card-controls {
  margin-bottom: 20px;
}

.card-validation {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid #d8cfbf;
  border-radius: 10px;
  padding: 6px;
  background: rgb(255 255 255 / 40%);
}

.validation-heading {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
  margin: 0;
}

.validation-heading > div {
  display: block;
}

.validation-heading .section-kicker {
  margin: 0;
}

.validation-heading h3 {
  display: none;
}

.validation-summary {
  border-radius: 999px;
  padding: 3px 6px;
  color: #8a4032;
  background: #f7e6df;
  font-size: 0.6rem;
  font-weight: 800;
}

.card-validation.is-valid .validation-summary {
  color: #315f3e;
  background: #dfefdf;
}

.validation-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(58px, 1fr));
  gap: 4px;
  overflow-x: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 4px;
  min-width: 0;
  border: 1px solid #d6cbbb;
  border-top: 3px solid currentColor;
  border-radius: 6px;
  padding: 4px 5px;
  color: #665d50;
  background: #fffdf8;
  font-size: 0.58rem;
}

.validation-item strong {
  grid-column: 1 / -1;
  color: #3e382f;
  font-size: 0.62rem;
  text-transform: capitalize;
}

.validation-item.color-red {
  border-top-color: var(--cell-red);
}

.validation-item.color-green {
  border-top-color: var(--cell-green);
}

.validation-item.color-blue {
  border-top-color: var(--cell-blue);
}

.validation-item.color-yellow {
  border-top-color: var(--cell-yellow);
}

.validation-item.color-orange {
  border-top-color: var(--cell-orange);
}

.check-pass {
  color: #477b55;
}

.check-fail {
  color: #8a6258;
}

.validation-mark {
  position: absolute;
  top: 3px;
  right: 4px;
  color: #a25645;
  font-size: 0.72rem;
  font-weight: 900;
}

.validation-item.is-valid .validation-mark {
  color: #4d8b62;
}

.field.compact {
  width: min(220px, 100%);
}

.save-status {
  align-self: center;
  margin: 20px 0 0 5px;
  color: #756c5f;
  font-size: 0.78rem;
}

.section-heading {
  margin-bottom: 20px;
}

.playing-card {
  overflow: hidden;
  border: 1px solid #cdc2af;
  border-radius: 17px;
  padding: 21px;
  background: var(--card-background, #fffdf8);
  box-shadow:
    0 2px 2px rgb(61 44 18 / 7%),
    0 18px 35px rgb(61 44 18 / 12%);
}

.card-layout {
  display: grid;
  grid-template-columns: minmax(0, 15fr) minmax(0, 2fr);
  align-items: start;
  gap: 9px;
}

.card-grid {
  width: 100%;
  container-name: playing-grid;
  container-type: inline-size;
}

.card-label-row,
.card-score-row,
.card-cell-grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 2px;
}

.card-label-row {
  margin-bottom: 9px;
  background: transparent;
}

.card-score-rows {
  display: grid;
  gap: 2px;
  margin-top: 9px;
}

.card-side-panel {
  display: flex;
  align-self: stretch;
  flex-direction: column;
  gap: 9px;
  margin-top: calc(clamp(25px, 4vw, 42px) + 9px);
}

.card-bonus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}

.card-bonus-row {
  display: contents;
}

.card-cell-grid {
  width: 100%;
  overflow: hidden;
  border: 2px solid #4a4d49;
  border-radius: 3px;
  padding: 0;
  background: #4a4d49;
}

@container playing-grid (max-width: 421px) {
  .card-cell-grid {
    gap: 1px;
  }
}

.card-data-row {
  display: contents;
}

.card-column-header,
.card-score-cell,
.card-bonus-cell {
  display: grid;
  place-items: center;
  height: clamp(25px, 4vw, 42px);
  border-radius: 5px;
  padding: 0;
  color: #4a4d49;
  background: #fff;
  font-family: "Trebuchet MS", Trebuchet, Arial, sans-serif;
  font-size: clamp(0.96rem, 2.3vw, 1.65rem);
  font-weight: 900;
  line-height: 1;
  -webkit-text-stroke: 0.6px currentColor;
}

.card-score-cell,
.card-bonus-cell {
  border: 0;
  appearance: none;
  cursor: pointer;
  touch-action: manipulation;
}

.card-bonus-cell.is-green {
  background: color-mix(in srgb, var(--cell-green) 88%, white);
}

.card-bonus-cell.is-yellow {
  background: color-mix(in srgb, var(--cell-yellow) 88%, white);
}

.card-bonus-cell.is-blue {
  background: color-mix(in srgb, var(--cell-blue) 88%, white);
}

.card-bonus-cell.is-red {
  background: color-mix(in srgb, var(--cell-red) 88%, white);
}

.card-bonus-cell.is-orange {
  background: color-mix(in srgb, var(--cell-orange) 88%, white);
}

.dice-cast {
  display: grid;
  gap: 5px;
  margin-top: 14px;
}

.dice-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(4px, 1vw, 12px);
}

.game-die {
  position: relative;
  display: grid;
  width: min(100%, 78px);
  aspect-ratio: 1;
  justify-self: center;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgb(38 33 23 / 38%);
  border-radius: clamp(7px, 1.3vw, 16px);
  background-image:
    repeating-linear-gradient(
      7deg,
      rgb(255 255 255 / 7%) 0,
      rgb(255 255 255 / 7%) 1px,
      transparent 1px,
      transparent 5px
    ),
    repeating-linear-gradient(
      94deg,
      transparent 0,
      transparent 8px,
      rgb(83 50 20 / 6%) 9px,
      transparent 10px,
      transparent 16px
    ),
    radial-gradient(ellipse at 28% 18%, rgb(255 255 255 / 10%), transparent 52%);
  background-blend-mode: soft-light, multiply, normal;
  box-shadow:
    inset 0 2px 2px rgb(255 255 255 / 36%),
    inset 0 -1px 2px rgb(38 33 23 / 12%),
    0 3px 5px rgb(38 33 23 / 22%),
    0 1px 1px rgb(38 33 23 / 16%);
}

.value-die {
  background-color: #303230;
}

.value-die.is-question {
  color: #fff;
  font: 900 clamp(1.4rem, 6.5vw, 4.2rem) / 0.9 "Trebuchet MS", Trebuchet, Arial, sans-serif;
  -webkit-text-stroke: 0.4px currentColor;
}

.die-pip {
  position: absolute;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
}

.die-pip.is-top-left {
  top: 20%;
  left: 20%;
}

.die-pip.is-top-right {
  top: 20%;
  right: 20%;
}

.die-pip.is-middle-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.die-pip.is-bottom-left {
  bottom: 20%;
  left: 20%;
}

.die-pip.is-bottom-right {
  right: 20%;
  bottom: 20%;
}

.cross-die {
  --die-cross-color: #161716;
  border-color: rgb(97 79 50 / 22%);
  background-color: #fffaf0;
}

.cross-die::before,
.cross-die::after {
  position: absolute;
  width: 78%;
  height: 30%;
  border-radius: 0;
  background: var(--die-cross-color);
  box-shadow: 0 0.5px 0 rgb(0 0 0 / 22%);
  content: "";
  transform: rotate(42deg);
}

.cross-die::after {
  width: 74%;
  border-radius: 0;
  transform: rotate(-43deg);
}

.cross-die.is-red {
  --die-cross-color: #e83f70;
}

.cross-die.is-green {
  --die-cross-color: #65b82e;
}

.cross-die.is-blue {
  --die-cross-color: #299ee5;
}

.cross-die.is-yellow {
  --die-cross-color: #efba16;
}

.cross-die.is-orange {
  --die-cross-color: #eb6d19;
}

.roll-dice-button {
  display: block;
  margin: 10px 0 0 auto;
  border: 1px solid rgb(38 33 23 / 35%);
  border-radius: 8px;
  padding: 8px 14px;
  color: #4a4d49;
  background: rgb(255 255 255 / 88%);
  font: 800 0.78rem / 1 "Trebuchet MS", Trebuchet, Arial, sans-serif;
  cursor: pointer;
}

.roll-dice-button:hover {
  background: #fff;
}

.roll-dice-button:focus-visible {
  outline: 2px solid #4a4d49;
  outline-offset: 2px;
}

.penalty-bar {
  --penalty-control-size: clamp(16px, 4.4vw, 48px);
  display: grid;
  grid-column: 1;
  grid-template-columns: auto auto auto auto repeat(8, minmax(16px, 1fr));
  align-items: center;
  gap: clamp(1px, 0.7vw, 9px);
  margin-top: 9px;
  border-radius: 7px;
  padding: clamp(4px, 0.8vw, 9px);
  color: #4a4d49;
  background: rgb(255 255 255 / 88%);
  font-family: "Trebuchet MS", Trebuchet, Arial, sans-serif;
  font-weight: 900;
}

.penalty-help-symbol,
.penalty-multiplier {
  display: grid;
  width: var(--penalty-control-size);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 6px;
  font-size: clamp(1rem, 3.2vw, 2.25rem);
  line-height: 1;
}

.penalty-help-symbol {
  color: #fff;
  background: #5b5e5b;
}

.penalty-multiplier {
  border: 2px solid #5b5e5b;
  background: #fff;
}

.penalty-operator {
  font-size: clamp(1.3rem, 4vw, 2.8rem);
  line-height: 1;
}

.penalty-slash {
  transform: scaleY(1.35);
}

.penalty-token {
  display: grid;
  width: var(--penalty-control-size);
  aspect-ratio: 1;
  place-self: center;
  place-items: center;
  margin: 0;
  border: clamp(2px, 0.25vw, 3px) solid #4a4d49;
  border-radius: 50%;
  padding: 0;
  color: #4a4d49;
  background: transparent;
  font: 900 clamp(0.9rem, 3.8vw, 2.7rem) / 1 "Trebuchet MS", Trebuchet, Arial, sans-serif;
  -webkit-text-stroke: 0.6px currentColor;
  cursor: pointer;
  transition: color 100ms ease, background-color 100ms ease, transform 100ms ease;
}

.penalty-token-mark {
  display: block;
  transform: skewX(-14deg);
}

.penalty-token:hover {
  transform: scale(1.04);
}

.penalty-token:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px #4a4d49;
}

.penalty-token[aria-pressed="true"] {
  color: #4a4d49;
  background: transparent;
}

.cross-selectable {
  position: relative;
}

.cross-selectable.is-selected::before,
.cross-selectable.is-selected::after,
.cross-selectable[aria-pressed="true"]::before,
.cross-selectable[aria-pressed="true"]::after {
  position: absolute;
  z-index: 8;
  top: 49%;
  left: 9%;
  width: 82%;
  height: clamp(2.2px, 0.3vw, 4.2px);
  border-radius: 65% 30% 60% 35%;
  background: linear-gradient(
    90deg,
    transparent,
    #0b0b0b 3%,
    #171717 48%,
    #090909 95%,
    transparent
  );
  box-shadow:
    0 0.45px 0 rgb(0 0 0 / 55%),
    0 -0.3px 0 rgb(0 0 0 / 28%);
  content: "";
  transform: rotate(38deg) skewX(-4deg);
  transform-origin: center;
  pointer-events: none;
}

.cross-selectable.is-selected::after,
.cross-selectable[aria-pressed="true"]::after {
  top: 48%;
  left: 11%;
  width: 79%;
  border-radius: 35% 65% 40% 55%;
  transform: rotate(-42deg) skewX(5deg);
}

.card-column-header:nth-child(8),
.card-score-cell:nth-child(8) {
  color: #c61d34;
}

.card-cell {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  padding: 0;
  background-color: #fffdf8;
  text-align: center;
  cursor: crosshair;
  touch-action: none;
  transition: background-color 80ms ease;
}

.cell-star {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  color: var(--cell-light, #fffdf8);
  font-size: clamp(1rem, 4.5vw, 3.25rem);
  line-height: 1;
  paint-order: stroke fill;
  -webkit-text-stroke: clamp(1px, 0.18vw, 2px) #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.card-cell.is-painted.has-star {
  background-image: none;
}

.card-cell.is-painted {
  background-color: inherit;
}

.card-cell.is-red {
  background:
    radial-gradient(circle closest-side, var(--cell-red-light) 0 calc(100% - 3px), transparent 100%),
    var(--cell-red);
}

.card-cell.is-green {
  background:
    radial-gradient(circle closest-side, var(--cell-green-light) 0 calc(100% - 3px), transparent 100%),
    var(--cell-green);
}

.card-cell.is-blue {
  background:
    radial-gradient(circle closest-side, var(--cell-blue-light) 0 calc(100% - 3px), transparent 100%),
    var(--cell-blue);
}

.card-cell.is-yellow {
  background:
    radial-gradient(circle closest-side, var(--cell-yellow-light) 0 calc(100% - 3px), transparent 100%),
    var(--cell-yellow);
}

.card-cell.is-orange {
  background:
    radial-gradient(circle closest-side, var(--cell-orange-light) 0 calc(100% - 3px), transparent 100%),
    var(--cell-orange);
}

/* Column H is the eighth item in every 15-cell grid row. */
.card-cell:nth-child(15n + 8) {
  z-index: 1;
  outline: 2px solid #fff;
  outline-offset: 0;
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 32px;
  }

  .page-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .card-stage {
    padding: 16px;
  }

  .editor-controls {
    grid-template-columns: 1fr;
  }

  .editor-actions,
  .saved-card-controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .editor-actions .button {
    flex: 1;
  }

  .save-status {
    flex-basis: 100%;
    margin: 4px 0 0;
  }

  .playing-card {
    padding: 10px;
  }
}
