.hero-card img {
  object-fit: contain;
  background: #fff;
}

.about-puzzle {
  margin: 28px 0;
  padding: 20px 22px;
  border: 1px solid #c9dbea;
  border-left: 6px solid #5b8fb9;
  border-radius: 14px;
  background: #f1f7fb;
}

.about-puzzle h2 {
  margin: 0 0 10px;
  color: #345f80;
  font-size: 1.25rem;
}

.about-puzzle p {
  margin: 0;
}

.about-puzzle p + p {
  margin-top: 10px;
}

.qlabel.label-red,
.qlabel.label-yellow,
.qlabel.label-green,
.qlabel.label-blue {
  letter-spacing: .08em;
  -webkit-text-stroke: 1px #111;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #111,
    1px -1px 0 #111,
    -1px 1px 0 #111,
    1px 1px 0 #111,
    0 2px 3px #0006;
}

.qlabel.label-red {
  color: #ef3b3b;
}

.qlabel.label-yellow {
  color: #ffd52e;
}

.qlabel.label-green {
  color: #78cf3f;
}

.qlabel.label-blue {
  color: #3b9bea;
}

.dot-red {
  border-color: #d93636;
  background: #d93636;
}

.dot-yellow {
  border-color: #b98a00;
  background: #f2c230;
}

.dot-green {
  border-color: #62a72f;
  background: #8fd14f;
}

.dot-blue {
  border-color: #2475c7;
  background: #3594e8;
}

.dot-red.current,
.dot-yellow.current,
.dot-green.current,
.dot-blue.current {
  outline: 3px solid var(--card);
  box-shadow: 0 0 0 5px var(--ink);
  transform: scale(1.08);
}

.yellow-puzzle {
  margin-top: 8px;
}

.yellow-expand-toolbar {
  display: none;
}

.yellow-expand-button {
  background: #739f27;
  color: #fff;
}

.yellow-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.yellow-reset {
  margin: 0;
}

.yellow-reset-icon {
  margin-right: 4px;
  font-size: 18px;
}

.yellow-expanded-open {
  overflow: hidden;
}

.yellow-puzzle.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 1100;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: rgb(20 29 38 / 96%);
}

.yellow-puzzle.is-expanded .yellow-expand-toolbar {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: block;
}

.yellow-puzzle.is-expanded .yellow-expand-button {
  min-width: 72px;
  min-height: 36px;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 13px;
  box-shadow: 0 3px 12px #0006;
}

.yellow-puzzle.is-expanded .yellow-reset {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 5;
  display: grid;
  width: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  background: #739f27;
  color: #fff;
  box-shadow: 0 3px 12px #0006;
}

.yellow-puzzle.is-expanded .yellow-reset-icon {
  font-size: 25px;
  line-height: 1;
}

.yellow-puzzle.is-expanded .yellow-reset-label {
  display: none;
}

.yellow-puzzle.is-expanded .yellow-expanded-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(1100px, calc(100vw - 24px));
  padding: 18px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: 0 12px 28px #0006;
  transform: translate(-50%, -50%);
}

.yellow-puzzle.is-expanded .yellow-board {
  --yellow-cell-size: clamp(58px, 8vw, 86px);
  width: 100%;
  justify-content: center;
  overflow: visible;
  padding: 0;
}

.yellow-puzzle.is-expanded .yellow-instruction {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 13px;
}

.yellow-board {
  --yellow-cell-size: clamp(44px, 8vw, 76px);
  --yellow-gap: clamp(7px, 1.5vw, 16px);
  --yellow-line: #9bd968;
  --yellow-line-active: #62bd2d;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: var(--yellow-gap);
  width: 100%;
  padding: 18px 0;
}

.yellow-first-group {
  display: grid;
  grid-template-columns: repeat(2, var(--yellow-cell-size));
  grid-template-rows: repeat(2, var(--yellow-cell-size));
}

.yellow-column {
  display: grid;
  grid-template-rows: repeat(2, var(--yellow-cell-size));
  width: var(--yellow-cell-size);
}

.yellow-cell {
  position: relative;
  width: var(--yellow-cell-size);
  height: var(--yellow-cell-size);
}

.yellow-row-top {
  grid-row: 1;
}

.yellow-row-bottom {
  grid-row: 2;
}

.first-i-cell {
  grid-column: 1;
  grid-row: 1;
}

.first-u-cell {
  grid-column: 2;
  grid-row: 1;
}

.first-ri-cell {
  grid-column: 1;
  grid-row: 2;
}

.yellow-cell-content {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  padding: 0;
  border: 1px solid var(--yellow-line);
  border-radius: 0;
  background: var(--card);
  color: #111;
  cursor: default;
  font: 400 clamp(24px, 4.2vw, 42px)/1 "Yu Mincho", "Hiragino Mincho ProN", serif;
}

button.yellow-cell-content {
  cursor: default;
}

.yellow-overlap {
  position: relative;
  display: block;
  width: 74%;
  height: 74%;
}

.yellow-overlap > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.overlap-uri > span:nth-child(1) {
  transform: translate(-4%, 1%) rotate(-4deg);
}

.overlap-uri > span:nth-child(2) {
  transform: translate(4%, 0%) rotate(4deg);
}

.overlap-tari > span:nth-child(1) {
  transform: translate(-5%, 1%);
}

.overlap-tari > span:nth-child(2) {
  transform: translate(5%, 0%);
}

.overlap-riu > span:nth-child(1) {
  transform: translate(-4%, 0%);
}

.overlap-riu > span:nth-child(2) {
  transform: translate(5%, 1%);
}

.overlap-tarii > span:nth-child(1) {
  transform: translate(-6%, 1%);
}

.overlap-tarii > span:nth-child(2) {
  transform: translate(0, -1%);
}

.overlap-tarii > span:nth-child(3) {
  transform: translate(6%, 1%);
}

.yellow-edge {
  position: absolute;
  z-index: 4;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.yellow-edge::after {
  position: absolute;
  background: transparent;
  content: "";
}

.yellow-edge.active::after {
  background: var(--yellow-line-active);
}

.yellow-edge.edge-top,
.yellow-edge.edge-bottom {
  left: 0;
  width: 100%;
  height: 12px;
}

.yellow-edge.edge-top {
  top: -6px;
}

.yellow-edge.edge-bottom {
  bottom: -6px;
}

.yellow-edge.edge-top::after,
.yellow-edge.edge-bottom::after {
  right: 0;
  left: 0;
  height: 6px;
}

.yellow-edge.edge-top::after {
  top: 6px;
}

.yellow-edge.edge-bottom::after {
  bottom: 6px;
}

.yellow-edge.edge-left,
.yellow-edge.edge-right {
  top: 0;
  width: 12px;
  height: 100%;
}

.yellow-edge.edge-left {
  left: -6px;
}

.yellow-edge.edge-right {
  right: -6px;
}

.yellow-edge.edge-left::after,
.yellow-edge.edge-right::after {
  top: 0;
  bottom: 0;
  width: 6px;
}

.yellow-edge.edge-left::after {
  left: 6px;
}

.yellow-edge.edge-right::after {
  right: 6px;
}

.yellow-image-column {
  display: grid;
  width: var(--yellow-cell-size);
  height: calc(var(--yellow-cell-size) * 2);
  align-items: end;
}

.yellow-image-column img {
  display: block;
  width: var(--yellow-cell-size);
  height: var(--yellow-cell-size);
  object-fit: contain;
}

.yellow-instruction {
  margin: 18px 0 4px;
  font-size: clamp(18px, 3vw, 28px);
  text-align: center;
}

.yellow-popup img {
  display: block;
  width: min(100%, 560px);
  max-height: 60vh;
  margin: 0 auto;
  object-fit: contain;
}

.blue-puzzle {
  margin-top: 8px;
}

.blue-expand-toolbar {
  display: none;
}

.blue-expand-button {
  background: #276b9f;
  color: #fff;
}

.blue-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.blue-actions .blue-reset {
  margin: 0;
}

.blue-expanded-open {
  overflow: hidden;
}

.blue-puzzle.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 1100;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background: rgb(20 29 38 / 96%);
}

.blue-puzzle.is-expanded .blue-expand-toolbar {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: block;
  margin: 0;
}

.blue-puzzle.is-expanded .blue-expand-button {
  min-width: 72px;
  min-height: 36px;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 13px;
  box-shadow: 0 3px 12px #0006;
}

.blue-puzzle.is-expanded .blue-rules {
  display: none;
}

.blue-puzzle.is-expanded .blue-reset {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 5;
  display: grid;
  width: 40px;
  min-height: 40px;
  margin: 0;
  place-items: center;
  padding: 0;
  border: 2px solid #fff;
  background: #276b9f;
  color: #fff;
  box-shadow: 0 3px 12px #0006;
}

.blue-puzzle.is-expanded .blue-reset-icon {
  font-size: 25px;
  line-height: 1;
}

.blue-puzzle.is-expanded .blue-reset-label {
  display: none;
}

.blue-puzzle.is-expanded .blue-expanded-content {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(900px, calc(100vw - 24px));
  transform: translate(-50%, -50%);
}

.blue-puzzle.is-expanded .blue-grid {
  width: min(100%, calc((100vh - 78px) * 1.575));
  margin: 0 auto;
}

.blue-puzzle.is-expanded .blue-route-message {
  min-height: 1.3em;
  margin: 4px 0 0;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
}

.blue-puzzle.is-expanded .blue-extraction {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 2px 0 0;
  padding: 0;
  background: transparent;
  color: #fff;
}

.blue-puzzle.is-expanded .blue-extraction p {
  margin: 0;
  color: #ccd6df;
  font-size: 11px;
}

.blue-puzzle.is-expanded .blue-extracted-letters {
  min-height: 0;
  font-size: 14px;
  line-height: 1.3;
}

.blue-rules {
  margin-bottom: 20px;
  padding: 18px 20px;
  border: 1px solid #c9ddef;
  border-radius: 16px;
  background: #f7fbff;
}

.blue-rules h2 {
  margin: 0 0 8px;
  color: #276b9f;
  text-align: center;
}

.blue-rules p {
  margin: 0 0 10px;
}

.blue-rules ul {
  margin: 0;
  padding-left: 1.4em;
}

.blue-rules li + li {
  margin-top: 5px;
}

.blue-rules strong {
  display: inline-block;
  padding: 0 5px;
  border: 2px solid #ee8a45;
  background: #fff;
  color: var(--ink);
}

.blue-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  overflow: hidden;
  border: 7px solid #5b9bd5;
  background: #fff;
}

.blue-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1.05;
  padding: 5px;
  border: 0;
  border-right: 1px solid #8caee5;
  border-bottom: 1px solid #8caee5;
  border-radius: 0;
  background: #fff;
  color: #080808;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(22px, 5vw, 52px);
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.blue-cell:nth-child(9n) {
  border-right: 0;
}

.blue-cell:nth-last-child(-n+9) {
  border-bottom: 0;
}

.blue-cell.blue-special {
  background: #dcecf8;
}

.blue-wall {
  position: absolute;
  z-index: 4;
  display: block;
  background: #5b9bd5;
  pointer-events: none;
}

.blue-wall-right {
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
}

.blue-wall-bottom {
  right: 0;
  bottom: 0;
  width: 100%;
  height: 7px;
}

.blue-cell.selected::after {
  position: absolute;
  inset: 7px;
  z-index: 2;
  border-radius: 2px;
  background: rgb(90 90 90 / 28%);
  content: "";
  pointer-events: none;
}

.blue-cell.selected::before {
  position: absolute;
  top: 3px;
  left: 5px;
  z-index: 3;
  color: #333;
  content: attr(data-order);
  font: 700 11px/1 system-ui, sans-serif;
}

.blue-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.blue-route-message {
  min-height: 1.6em;
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
}

.blue-extraction {
  margin: 12px auto;
  padding: 12px;
  border-radius: 14px;
  background: #eef5fb;
  text-align: center;
}

.blue-extraction p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.blue-extracted-letters {
  min-height: 1.5em;
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 800;
}

.blue-reset {
  display: block;
  margin: 12px auto 0;
}

.blue-reset-icon {
  margin-right: 4px;
  font-size: 18px;
}

@media (max-width: 768px) {
  .yellow-expand-toolbar,
  .blue-expand-toolbar {
    display: block;
  }
}

@media (max-width: 560px) {
  .yellow-board {
    --yellow-cell-size: clamp(36px, 10vw, 48px);
    --yellow-gap: 5px;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 16px 4px;
  }

  .yellow-cell-content {
    font-size: clamp(20px, 7vw, 30px);
  }

  .blue-rules {
    padding: 14px;
    font-size: 14px;
  }

  .blue-grid {
    border-width: 4px;
  }

  .blue-cell {
    padding: 2px;
    font-size: clamp(16px, 7vw, 32px);
  }

  .blue-cell.selected::after {
    inset: 4px;
  }

  .blue-wall-right {
    width: 4px;
  }

  .blue-wall-bottom {
    height: 4px;
  }
}

@media (orientation: portrait) {
  .yellow-puzzle.is-expanded .yellow-expanded-content {
    width: min(calc(100vh - 20px), 730px);
    max-width: none;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .yellow-puzzle.is-expanded .yellow-board {
    --yellow-cell-size: clamp(60px, 10vh, 80px);
  }

  .blue-puzzle.is-expanded .blue-expanded-content {
    width: calc(100vh - 20px);
    max-width: none;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .blue-puzzle.is-expanded .blue-grid {
    width: min(100%, calc((100vw - 66px) * 1.575));
  }
}
