* {
  box-sizing: border-box;
}

:root {
  color: #13245c;
  background: #f7faff;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Helvetica Neue",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;
}

body {
  min-height: 100vh;
  margin: 0;
  background-color: #f7faff;
  background-image:
    linear-gradient(rgba(74, 118, 220, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 118, 220, 0.1) 1px, transparent 1px);
  background-size: 32px 32px;
}

a {
  color: inherit;
}

button {
  font: inherit;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 16px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(19, 36, 92, 0.18);
  background: rgba(247, 250, 255, 0.9);
  backdrop-filter: blur(12px);
}

.site-header__logo {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.site-header__navigation {
  display: flex;
  gap: 24px;
}

.site-header__navigation a {
  font-size: 0.875rem;
  text-decoration: none;
}

.work-page {
  width: min(1180px, calc(100% - 40px));
  min-height: calc(100vh - 145px);
  margin: 0 auto;
  padding: 48px 0 120px;
}

.work-page__navigation {
  margin-bottom: 56px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-decoration: none;
}

.work-heading {
  margin-bottom: 56px;
}

.section-label {
  margin: 0 0 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.work-heading h1 {
  max-width: 1000px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 6rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.game-panel {
  padding: clamp(20px, 4vw, 48px);
  border: 1px solid rgba(19, 36, 92, 0.22);
  background: rgba(247, 250, 255, 0.76);
  box-shadow: 12px 12px 0 rgba(19, 36, 92, 0.08);
}

.game-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(19, 36, 92, 0.18);
}

.game-panel__header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 500;
}

.game-panel__level {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.game-panel__introduction {
  margin: 24px 0 0;
  font-size: 0.95rem;
  line-height: 1.8;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
  margin-top: 40px;
}

.puzzle-stage {
  min-width: 0;
}

.puzzle {
  display: grid;
  width: min(100%, 600px);
  aspect-ratio: 1;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(19, 36, 92, 0.4);
  background: #13245c;
}

.puzzle__tile {
  min-width: 0;
  padding: 0;
  border: 0;
  background-color: #ffffff;
  background-repeat: no-repeat;
  cursor: pointer;
}

.puzzle__tile:hover {
  outline: 2px solid #13245c;
  outline-offset: -2px;
}

.puzzle__tile--empty {
  background-color: #e9eef9;
  background-image: none !important;
  cursor: default;
}

.puzzle-status {
  margin: 14px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.game-controls {
  position: sticky;
  top: 104px;
}

.command-button {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid #13245c;
  background: transparent;
  color: #13245c;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  cursor: pointer;
}

.command-button:hover,
.command-button:focus-visible {
  background: #13245c;
  color: #ffffff;
}

.sample {
  margin-top: 24px;
}

.sample__label {
  margin: 0 0 8px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.sample__image {
  width: 100%;
  border: 1px solid rgba(19, 36, 92, 0.25);
  filter: grayscale(100%);
  opacity: 0.82;
}

.work-information {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  column-gap: clamp(32px, 6vw, 80px);
  row-gap: 32px;
  align-items: start;
}

.game-panel + .work-information {
  margin-top: 80px;
}

.work-information--locked {
  display: none;
}

.work-information__figure {
  margin: 0;
}

.work-information__image {
  width: 100%;
  height: auto;
  border: 1px solid rgba(19, 36, 92, 0.2);
  background: #ffffff;
}

.work-information__text {
  position: static;
  padding-top: 4px;
}

.work-information__metadata {
  margin: 0;
  color: rgba(19, 36, 92, 0.7);
  font-size: 0.78rem;
  line-height: 1.8;
}

.work-information__description {
  margin: 24px 0 0;
  font-size: 0.95rem;
  line-height: 2;
  white-space: pre-wrap;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 32px clamp(20px, 4vw, 64px);
  border-top: 1px solid rgba(19, 36, 92, 0.18);
  font-size: 0.75rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 800px) {
  .game-layout,
  .work-information {
    grid-template-columns: 1fr;
  }

  .game-controls,
  .work-information__text {
    position: static;
  }

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

  .game-controls .section-label,
  .sample {
    grid-column: 1 / -1;
  }

  .command-button {
    margin-top: 0;
  }

  .sample__image {
    width: min(280px, 100%);
  }
}

@media (max-width: 600px) {
  body {
    background-size: 24px 24px;
  }

  .site-header {
    min-height: 60px;
    padding: 14px 20px;
  }

  .work-page {
    width: min(100% - 32px, 1180px);
    padding: 32px 0 80px;
  }

  .work-page__navigation {
    margin-bottom: 40px;
  }

  .work-heading {
    margin-bottom: 40px;
  }

  .game-panel {
    padding: 18px;
    box-shadow: 6px 6px 0 rgba(19, 36, 92, 0.08);
  }

  .game-panel__header {
    display: block;
  }

  .game-panel__level {
    margin-top: 18px;
  }

  .game-layout {
    margin-top: 28px;
  }

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

  .game-controls .section-label,
  .sample {
    grid-column: auto;
  }

  .site-footer {
    padding: 24px 20px;
  }
}

.command-button--cheat {
  border-style: dashed;
}

.command-button--cheat:hover,
.command-button--cheat:focus-visible {
  background: #51458f;
  border-color: #51458f;
  color: #ffffff;
}

.cheat-confirmation {
  margin-top: 24px;
  padding: 18px;
  border: 1px dashed rgba(81, 69, 143, 0.7);
  background: rgba(81, 69, 143, 0.06);
}

.cheat-confirmation__description {
  margin: 12px 0 0;
  font-size: 0.8rem;
  line-height: 1.8;
}

.cheat-confirmation__actions {
  margin-top: 18px;
}


/* =========================================================
   PLAYER PROGRESS STATUS
   ========================================================= */

.work-status-panel {
  width: min(100%, 420px);
  margin: 24px 0 0;
  border-top: 1px solid rgba(19, 36, 92, 0.32);
  border-bottom: 1px solid rgba(19, 36, 92, 0.32);
}

.work-status-panel__row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(0, 1fr);
  gap: 24px;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(19, 36, 92, 0.22);
}

.work-status-panel__row:last-child {
  border-bottom: 0;
}

.work-status-panel__row[hidden] {
  display: none;
}

.work-status-panel dt,
.work-status-panel dd {
  margin: 0;
}

.work-status-panel dt {
  color: rgba(19, 36, 92, 0.68);
  font-family: monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.work-status-panel dd {
  color: #13245c;
  font-family: monospace;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: right;
}

.work-status-panel__value-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.clear-record-update {
  padding: 3px 6px;
  border: 1px solid currentColor;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.clear-record-update[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .work-status-panel {
    width: 100%;
  }

  .work-status-panel__row {
    grid-template-columns: minmax(96px, 1fr) minmax(0, 1fr);
    gap: 16px;
  }

  .work-status-panel__value-group {
    flex-wrap: wrap;
  }
}


/* =========================================================
   ACCESS RECORD
   ========================================================= */

.access-record {
  grid-column: 1 / -1;
  margin-top: 0;
  padding: 28px;
  border: 1px solid rgba(19, 36, 92, 0.48);
  background: rgba(255, 255, 255, 0.52);
  position: relative;
  scroll-margin: 96px 0;
  outline: none;
  transition:
    border-color 240ms ease,
    background-color 240ms ease,
    box-shadow 240ms ease;
}

.access-record::before,
.access-record::after {
  position: absolute;
  width: 14px;
  height: 14px;
  content: "";
  pointer-events: none;
}

.access-record::before {
  top: -1px;
  right: -1px;
  border-top: 3px solid #ffffff;
  border-right: 3px solid #ffffff;
}

.access-record::after {
  bottom: -1px;
  left: -1px;
  border-bottom: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
}

.access-record__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

.access-record__subtitle {
  margin: 0;
  color: rgba(19, 36, 92, 0.58);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.access-record .work-status-panel {
  width: 100%;
  margin-top: 20px;
}

.access-record__note {
  width: min(100%, 720px);
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px dashed rgba(19, 36, 92, 0.24);
  color: rgba(19, 36, 92, 0.78);
  font-size: 0.8rem;
  line-height: 1.9;
}

.access-record__note[hidden] {
  display: none;
}

.access-record__retry {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed rgba(19, 36, 92, 0.24);
}

.retry-puzzle-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 18px;
  border: 1px solid #13245c;
  background: transparent;
  color: #13245c;
  text-align: left;
  cursor: pointer;
}

.retry-puzzle-button:hover,
.retry-puzzle-button:focus-visible {
  background: #13245c;
  color: #ffffff;
}

.retry-puzzle-button__label {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.retry-puzzle-button__description {
  color: rgba(19, 36, 92, 0.68);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: right;
}

.retry-puzzle-button:hover
  .retry-puzzle-button__description,
.retry-puzzle-button:focus-visible
  .retry-puzzle-button__description {
  color: rgba(255, 255, 255, 0.82);
}

@media (max-width: 600px) {
  .access-record {
    margin-top: 0;
    padding: 20px;
    scroll-margin: 76px 0;
  }

  .access-record__heading {
    display: block;
  }

  .access-record__subtitle {
    margin-top: 8px;
  }

  .retry-puzzle-button {
    display: block;
  }

  .retry-puzzle-button__description {
    display: block;
    margin-top: 8px;
    text-align: left;
  }
}


.access-record--updated {
  border-color: rgba(19, 36, 92, 0.92);
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 0 0 4px rgba(19, 36, 92, 0.08),
    8px 8px 0 rgba(19, 36, 92, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .access-record {
    transition: none;
  }

  .access-record--updated {
    box-shadow: 0 0 0 4px rgba(19, 36, 92, 0.08);
  }
}

/* TURN ON */

.turn-on-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line, #c7d1e4);
  background: #fff;
}

.turn-on-board__cell {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  appearance: none;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line, #c7d1e4);
  border-bottom: 1px solid var(--line, #c7d1e4);
  background-repeat: no-repeat;
  cursor: pointer;
}

.turn-on-board__cell:nth-child(3n) {
  border-right: 0;
}

.turn-on-board__cell:nth-child(n + 7) {
  border-bottom: 0;
}

.turn-on-record {
  margin: 16px 0 0;
  border-top: 1px solid var(--line, #c7d1e4);
}

.turn-on-record__row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line, #c7d1e4);
}

.turn-on-record__row dt,
.turn-on-record__row dd {
  margin: 0;
}

/* TURN ON presentation tuning */

.work-detail--turn-on .work-page {
  padding-top: 32px;
}

.work-detail--turn-on .work-page__navigation {
  margin-bottom: 32px;
}

.work-detail--turn-on .work-heading {
  margin-bottom: 32px;
}

.work-detail--turn-on .work-heading h1 {
  max-width: 920px;
  font-size: clamp(2.25rem, 4.8vw, 4.5rem);
  line-height: 0.96;
}

.work-detail--turn-on .game-panel {
  padding: clamp(20px, 3vw, 36px);
}

.work-detail--turn-on .game-panel__header {
  padding-bottom: 18px;
}

.work-detail--turn-on .game-panel__introduction {
  margin-top: 18px;
}

.work-detail--turn-on .game-layout {
  gap: clamp(28px, 4vw, 56px);
  margin-top: 28px;
}

.turn-on-board {
  max-width: 100%;
}

.turn-on-board__cell.is-gray {
  filter:
    grayscale(1)
    brightness(0.60)
    contrast(1.10);
}

@media (max-width: 800px) {
  .work-detail--turn-on .work-heading h1 {
    font-size: clamp(2.25rem, 10vw, 4rem);
  }

  .work-detail--turn-on .game-layout {
    margin-top: 24px;
  }

  .turn-on-board {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .work-heading h1 {
    overflow-wrap: break-word;
  }

  .work-detail--turn-on .work-page {
    padding-top: 24px;
  }

  .work-detail--turn-on .work-page__navigation {
    margin-bottom: 28px;
  }

  .work-detail--turn-on .work-heading {
    margin-bottom: 28px;
  }
}
