:root {
  color-scheme: light;
  --ink: #111;
  --soft-ink: #3f3f3f;
  --paper: #ece9df;
  --paper-light: #fffef9;
  --paper-shadow: #c8c3b8;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 960px;
  overflow: hidden;
  color: var(--ink);
  background:
    repeating-linear-gradient(
      2deg,
      rgb(0 0 0 / 0.035) 0,
      rgb(0 0 0 / 0.035) 1px,
      transparent 1px,
      transparent 5px
    ),
    repeating-linear-gradient(
      92deg,
      transparent 0,
      transparent 18px,
      rgb(0 0 0 / 0.018) 18px,
      rgb(0 0 0 / 0.018) 19px
    ),
    var(--paper);
}

body.is-resizing,
body.is-resizing * {
  cursor: row-resize !important;
  user-select: none !important;
}

button,
select {
  color: inherit;
  font: inherit;
}

.level-select-screen {
  width: 100%;
  height: 100%;
  padding: 32px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.level-select-sheet {
  width: min(1080px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: 32px;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(
      -4deg,
      transparent 0,
      transparent 16px,
      rgb(0 0 0 / 0.025) 16px,
      rgb(0 0 0 / 0.025) 17px
    ),
    rgb(255 254 249 / 0.94);
  box-shadow:
    4px 5px 0 rgb(17 17 17 / 0.28),
    inset 0 0 0 2px rgb(17 17 17 / 0.08);
}

.level-select-header {
  margin: 0 0 28px;
  text-align: center;
}

.game-name {
  margin: 0;
  font-family: "Segoe Print", "Bradley Hand ITC", Georgia, serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: 0.025em;
  line-height: 1.15;
}

.level-select-header h1 {
  margin: 12px 0 0;
  font-family: "Segoe Print", "Bradley Hand ITC", Georgia, serif;
  font-size: 26px;
  line-height: 1.25;
}

.level-select-header > p:last-child {
  margin: 10px 0 0;
  color: var(--soft-ink);
  font-size: 15px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
}

.level-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 92px;
  padding: 14px 16px;
  text-align: left;
}

.level-card.is-complete {
  background: #e5e1d7;
}

.level-card-number {
  padding-right: 16px;
  border-right: 1px solid rgb(17 17 17 / 0.35);
  font-family: "Segoe Print", "Bradley Hand ITC", Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.level-card-title {
  min-width: 0;
  font-family: "Segoe Print", "Bradley Hand ITC", "Trebuchet MS", sans-serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.level-card-status {
  justify-self: end;
  color: var(--soft-ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.level-card.is-complete .level-card-status {
  color: var(--ink);
}

.game-shell {
  --objects-panel-height: 148px;
  --object-card-width: 104px;
  --object-icon-size: 64px;
  --object-name-font-size: 14px;
  --object-name-height: 34px;
  position: relative;
  display: grid;
  grid-template-rows:
    64px
    minmax(320px, 1fr)
    10px
    var(--objects-panel-height);
  width: 100%;
  height: 100%;
  padding: 10px;
}

.game-shell::before,
.game-shell::after {
  position: absolute;
  inset: 6px;
  z-index: -1;
  border: 1.5px solid rgb(17 17 17 / 0.62);
  content: "";
  pointer-events: none;
}

.game-shell::after {
  inset: 10px 7px 5px 12px;
  border-color: rgb(17 17 17 / 0.25);
}

.game-toolbar {
  display: grid;
  grid-template-columns:
    minmax(170px, 0.8fr)
    minmax(300px, 1.25fr)
    minmax(330px, 1fr);
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 6px 17px 7px;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(
      -5deg,
      transparent 0,
      transparent 12px,
      rgb(0 0 0 / 0.025) 12px,
      rgb(0 0 0 / 0.025) 13px
    ),
    rgb(255 254 249 / 0.94);
  box-shadow:
    2px 2px 0 rgb(17 17 17 / 0.28),
    inset 0 -1px 0 rgb(17 17 17 / 0.18);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-group label {
  color: var(--soft-ink);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.view-controls {
  justify-content: flex-end;
}

.level-title {
  min-width: 0;
  margin: 0;
  padding: 3px 7px 6px;
  overflow: visible;
  font-family: "Segoe Print", "Bradley Hand ITC", Georgia, serif;
  font-size: clamp(20px, 1.7vw, 27px);
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

select,
button {
  min-height: 34px;
  border: 2px solid var(--ink);
  border-radius: 1px;
  background: var(--paper-light);
  box-shadow: 2px 2px 0 rgb(17 17 17 / 0.3);
}

select {
  padding: 4px 29px 4px 8px;
}

button {
  padding: 4px 12px;
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover:not(:disabled) {
  background: #f1eee5;
}

button:active:not(:disabled) {
  box-shadow: 1px 1px 0 rgb(17 17 17 / 0.36);
  transform: translate(1px, 1px);
}

button:focus-visible,
select:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 3px;
}

button:disabled,
select:disabled {
  color: #737373;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.62;
}

.puzzle-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 10px 12px 8px;
  border-right: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  background:
    repeating-linear-gradient(
      4deg,
      transparent 0,
      transparent 16px,
      rgb(0 0 0 / 0.028) 16px,
      rgb(0 0 0 / 0.028) 17px
    ),
    rgb(255 254 249 / 0.72);
}

.puzzle-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  border: 1.5px solid rgb(17 17 17 / 0.7);
  background:
    linear-gradient(rgb(255 255 255 / 0.7), rgb(255 255 255 / 0.7)),
    repeating-linear-gradient(
      -5deg,
      transparent 0,
      transparent 7px,
      rgb(0 0 0 / 0.055) 7px,
      rgb(0 0 0 / 0.055) 8px
    );
  box-shadow:
    inset 0 0 22px rgb(17 17 17 / 0.12),
    1px 1px 0 rgb(17 17 17 / 0.22);
  touch-action: none;
}

.puzzle-viewport.is-pannable {
  cursor: grab;
}

.puzzle-viewport.is-dragging {
  cursor: grabbing;
}

.puzzle-scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  outline: 1px solid var(--ink);
  background: white;
  box-shadow:
    2px 3px 0 rgb(17 17 17 / 0.25),
    7px 9px 16px rgb(17 17 17 / 0.16);
  transform-origin: 0 0;
  will-change: transform;
}

.puzzle-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.reveal-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.load-status {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  max-width: min(520px, 72%);
  padding: 12px 18px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 4px 5px 0 rgb(17 17 17 / 0.28);
  font-family: "Segoe Print", "Bradley Hand ITC", sans-serif;
  font-weight: 650;
  text-align: center;
  transform: translate(-50%, -50%);
}

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

.load-status.is-error {
  border-style: dashed;
  color: #202020;
}

.layout-splitter {
  position: relative;
  min-width: 0;
  border: 2px solid var(--ink);
  border-top-width: 1px;
  border-bottom-width: 1px;
  background:
    repeating-linear-gradient(
      -45deg,
      #171717 0,
      #171717 1px,
      #f7f5ee 1px,
      #f7f5ee 5px
    );
  cursor: row-resize;
  touch-action: none;
}

.splitter-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 78px;
  height: 3px;
  background: var(--ink);
  box-shadow:
    -6px -2px 0 rgb(255 254 249 / 0.95),
    6px 2px 0 rgb(255 254 249 / 0.95);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.objects-panel {
  min-width: 0;
  min-height: 0;
  padding: 6px 8px 5px;
  border: 2px solid var(--ink);
  border-top-width: 1px;
  background:
    repeating-linear-gradient(
      5deg,
      transparent 0,
      transparent 14px,
      rgb(0 0 0 / 0.035) 14px,
      rgb(0 0 0 / 0.035) 15px
    ),
    rgb(255 254 249 / 0.94);
  box-shadow: 2px 2px 0 rgb(17 17 17 / 0.25);
}

.objects-scroller {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-color: var(--soft-ink) var(--paper-shadow);
  scrollbar-width: auto;
}

.objects-scroller::-webkit-scrollbar {
  height: 13px;
}

.objects-scroller::-webkit-scrollbar-track {
  border: 1px solid rgb(17 17 17 / 0.55);
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 5px,
      rgb(0 0 0 / 0.12) 5px,
      rgb(0 0 0 / 0.12) 6px
    ),
    var(--paper-shadow);
}

.objects-scroller::-webkit-scrollbar-thumb {
  border: 2px solid var(--paper-shadow);
  border-radius: 0;
  background: var(--soft-ink);
}

.objects-list {
  display: flex;
  align-items: stretch;
  gap: 9px;
  width: max-content;
  min-width: 100%;
  height: calc(100% - 13px);
  margin: 0;
  padding: 0 2px 1px;
  list-style: none;
}

.object-card {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--object-name-height);
  flex: 0 0 var(--object-card-width);
  min-width: 0;
  overflow: hidden;
  padding: 3px 6px;
  border: 1.5px solid var(--ink);
  background:
    repeating-linear-gradient(
      -4deg,
      transparent 0,
      transparent 17px,
      rgb(0 0 0 / 0.025) 17px,
      rgb(0 0 0 / 0.025) 18px
    ),
    var(--paper-light);
  box-shadow: 2px 2px 0 rgb(17 17 17 / 0.24);
}

.object-check {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-light);
  box-shadow: 1px 1px 0 rgb(17 17 17 / 0.32);
  font-family: "Segoe Print", "Bradley Hand ITC", sans-serif;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-8deg) scale(0.72);
}

.object-card.is-found {
  background: #e5e1d7;
}

.object-card.is-found .object-check {
  opacity: 1;
  transform: rotate(-8deg) scale(1);
}

.object-card.is-found .object-icon {
  opacity: 0.42;
}

.object-icon {
  display: block;
  align-self: center;
  justify-self: center;
  width: var(--object-icon-size);
  height: var(--object-icon-size);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.object-name {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--object-name-height);
  min-width: 0;
  padding: 2px 2px 1px;
  border-top: 1px solid rgb(17 17 17 / 0.35);
  overflow: hidden;
  font-family: "Segoe Print", "Bradley Hand ITC", "Trebuchet MS", sans-serif;
  font-size: var(--object-name-font-size);
  font-weight: 700;
  line-height: 1.14;
  text-align: center;
  overflow-wrap: anywhere;
}

.object-card.is-found .object-name {
  color: #555;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.completion-dialog {
  width: min(420px, calc(100vw - 48px));
  max-width: none;
  padding: 0;
  border: 3px solid var(--ink);
  color: var(--ink);
  background: var(--paper-light);
  box-shadow:
    6px 7px 0 rgb(17 17 17 / 0.34),
    inset 0 0 0 2px rgb(17 17 17 / 0.1);
  font: inherit;
}

.completion-dialog::backdrop {
  background: rgb(17 17 17 / 0.48);
}

.completion-card {
  padding: 28px 30px 26px;
  text-align: center;
}

.completion-card h2 {
  margin: 0;
  font-family: "Segoe Print", "Bradley Hand ITC", Georgia, serif;
  font-size: 30px;
  line-height: 1.25;
}

.completion-card p {
  margin: 14px 0 0;
  color: var(--soft-ink);
  font-size: 16px;
}

.completion-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 24px 0 0;
}

.completion-card button {
  min-width: 128px;
  font-weight: 700;
}

@media (max-height: 760px) {
  .game-shell {
    grid-template-rows:
      60px
      minmax(320px, 1fr)
      10px
      var(--objects-panel-height);
  }

  .game-toolbar {
    padding-top: 4px;
    padding-bottom: 5px;
  }

  .level-title {
    font-size: clamp(19px, 1.65vw, 25px);
  }
}
