body.site-game {
  overflow: hidden;
}

.is-hidden { display: none !important; }
.pc-only { display: block; }
.mobile-only { display: none; }

.game-shell {
  display: grid;
  width: min(1120px, 100vw);
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(8px, 1.6dvh, 16px);
}

.game-panel {
  display: grid;
  grid-template-columns: minmax(238px, 286px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top" "side board";
  gap: clamp(10px, 1.8dvh, 16px);
  min-height: 0;
  padding: clamp(12px, 2dvh, 18px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 82% 16%, rgba(247, 220, 118, 0.24), transparent 34%),
    radial-gradient(circle at 18% 82%, rgba(85, 199, 162, 0.18), transparent 38%),
    rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.08);
  backdrop-filter: blur(var(--panel-blur));
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.back-button span { display: block; transform: translateY(-1px); }

.title-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-right: auto;
}

.game-title-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 12px rgba(247, 220, 118, 0.35);
}

.title-block h1 {
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  padding: 0 16px;
  font-size: 13px;
}

.level-chip {
  display: grid;
  min-width: 80px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(247, 220, 118, 0.45);
  border-radius: var(--radius-pill);
  background: rgba(247, 220, 118, 0.16);
  color: #f7dc76;
  font-size: 13px;
  font-weight: 900;
}

.play-sidebar {
  grid-area: side;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  align-content: start;
  gap: clamp(8px, 1.4dvh, 12px);
  min-height: 0;
  overflow: hidden;
}

.difficulty-row,
.tool-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tool-row { grid-template-columns: repeat(2, 1fr); }

.difficulty-button,
.tool-button,
.button {
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.difficulty-button {
  min-height: 34px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 13px;
}

.tool-button {
  min-height: 38px;
}

.difficulty-button:hover,
.tool-button:hover,
.button:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.11);
  color: var(--ink);
}

.difficulty-button.is-active,
.tool-button.is-active,
.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #55c7a2 0%, #6b7fe8 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(85, 199, 162, 0.3);
}

.button.danger {
  color: #ff9aaa;
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.status-strip > div,
.sidebar-records {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
}

.label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-strip strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.info-row {
  display: grid;
  gap: 6px;
}

.message {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.message.success { color: var(--green); }
.message.error { color: #ff9aaa; }

.seed {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
}

.sidebar-records {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.sidebar-records-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

.sidebar-records-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn-clear-inline {
  padding: 2px 8px;
  border: 1px solid rgba(224,115,153,0.25);
  border-radius: var(--radius-pill);
  background: transparent;
  color: #ff9aaa;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.btn-clear-inline:hover {
  background: rgba(224,115,153,0.1);
  border-color: rgba(224,115,153,0.45);
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-items: stretch;
}

.record-card {
  height: 100%;
  padding: clamp(10px, 1.8dvh, 14px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
}

.record-card strong,
.record-card span,
.record-card small {
  display: block;
}

.record-card strong {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.record-card span {
  color: #55c7a2;
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.record-card small {
  margin-top: 5px;
  color: var(--subtle);
  font-size: 12px;
}

.sidebar-records .record-grid {
  grid-template-columns: 1fr;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(5px, 0.9dvh, 8px);
}

.board-wrap {
  grid-area: board;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
}

.nonogram-board {
  --cell: min(7.2dvh, 52px);
  --clue: calc(var(--cell) * 1.75);
  display: grid;
  grid-template-columns: var(--clue) repeat(var(--size), var(--cell));
  grid-template-rows: var(--clue) repeat(var(--size), var(--cell));
  gap: 3px;
  max-width: 100%;
  max-height: 100%;
  padding: clamp(8px, 1.5dvh, 16px);
  border: 2px solid #9b7431;
  border-radius: 18px;
  background: linear-gradient(145deg, #fff8d9, #f7dc76);
  box-shadow: 0 22px 60px rgba(0,0,0,0.32);
}

.clue-corner,
.clue,
.nonogram-cell {
  border-radius: 9px;
}

.clue-corner,
.clue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.62);
  color: #6f5226;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.12;
}

.clue-corner {
  color: #9b7431;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.clue-col {
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}

.clue-col span,
.clue-row span {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  line-height: 1.12;
}

.clue-row {
  justify-content: center;
  text-align: center;
}

.nonogram-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(111, 82, 38, 0.28);
  background: #fffdf0;
  color: #8a6833;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 120ms ease, background 160ms ease, box-shadow 160ms ease;
}

.nonogram-cell:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(85, 199, 162, 0.28);
}

.nonogram-cell.fill {
  background: linear-gradient(145deg, #55c7a2, #3aa7d9);
  border-color: rgba(255,255,255,0.4);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.12);
}

.nonogram-cell.cross {
  background: #fff6d1;
}

.nonogram-cell.cross::before,
.nonogram-cell.cross::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(58%, 24px);
  height: 5px;
  border-radius: 999px;
  background: #8a6833;
  transform-origin: center;
}

.nonogram-cell.cross::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.nonogram-cell.cross::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.nonogram-cell.conflict {
  background: #ff8fa0;
  color: #fff;
}

.nonogram-cell.hint {
  outline: 4px solid #fff16a;
  outline-offset: -2px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,0.58);
  z-index: 10;
}

.modal-card {
  width: min(440px, 100%);
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: #171b30;
  box-shadow: var(--shadow);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-heading h2 {
  font-size: 22px;
}

.modal-card p {
  color: var(--muted);
}

.full-button {
  width: 100%;
  margin-top: 12px;
}

.victory-card.is-celebration,
.modal.is-celebration .modal-card {
  box-shadow: 0 0 0 1px rgba(247, 220, 118, 0.4), 0 0 40px rgba(247, 220, 118, 0.22), var(--shadow);
}

@media (max-width: 760px) {
  body.site-game {
    overflow: hidden;
  }

  .pc-only { display: none; }
  .mobile-only { display: block; }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    padding: 6px;
  }

  .game-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "top"
      "difficulty"
      "status"
      "board"
      "info"
      "tools"
      "controls";
    gap: 0;
    min-width: 0;
    min-height: 0;
    padding: 9px;
  }

  .topbar {
    align-items: center;
    min-width: 0;
    margin-bottom: 6px;
    padding-bottom: 8px;
  }

  .title-block h1 {
    font-size: 18px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }

  .game-title-logo {
    width: 32px;
    height: 32px;
  }

  .top-actions {
    gap: 5px;
  }

  .level-chip {
    min-width: 76px;
    height: 32px;
    font-size: 12px;
  }

  .small-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }

  .play-sidebar {
    display: contents;
  }

  .difficulty-row {
    grid-area: difficulty;
    grid-template-columns: repeat(3, 1fr);
    min-width: 0;
    margin-bottom: 6px;
  }

  .difficulty-button {
    min-height: 30px;
    font-size: 12px;
  }

  .status-strip {
    grid-area: status;
    grid-template-columns: repeat(3, 1fr);
    min-width: 0;
    gap: 5px;
    margin-bottom: 6px;
  }

  .status-strip > div {
    padding: 6px 9px;
    border-radius: 8px;
  }

  .label {
    margin-bottom: 1px;
    font-size: 9px;
  }

  .status-strip strong {
    font-size: 20px;
  }

  .board-wrap {
    grid-area: board;
    place-items: center;
    min-width: 0;
    min-height: 0;
    margin-bottom: 5px;
    padding-top: 0;
  }

  .nonogram-board {
    --cell: min(7.6vw, calc((100vw - 72px) / (var(--size) + 2.2)), calc((100dvh - 322px) / 12.2), 40px);
    --clue: calc(var(--cell) * 2.2);
    justify-self: center;
    margin-inline: auto;
    gap: 2px;
    padding: 7px;
  }

  .clue,
  .clue-corner {
    padding: 3px;
    font-size: clamp(9px, calc(var(--cell) * 0.34), 12px);
    line-height: 1.08;
  }

  .clue-col {
    gap: 1px;
  }

  .clue-col span,
  .clue-row span {
    line-height: 1.08;
  }

  .nonogram-cell {
    font-size: clamp(18px, 6vw, 26px);
  }

  .info-row {
    grid-area: info;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    margin: 1px 2px 6px;
  }

  .message,
  .seed {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .message {
    font-size: 12px;
  }

  .tool-row {
    grid-area: tools;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    min-width: 0;
    margin-bottom: 5px;
  }

  .tool-button {
    min-height: 34px;
    border-radius: 8px;
    font-size: 13px;
  }

  .controls {
    grid-area: controls;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    min-width: 0;
  }

  .controls .button {
    min-height: 34px;
    border-radius: 8px;
    font-size: 13px;
  }

  .record-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (max-width: 460px) {
  .topbar {
    gap: 6px;
  }

  .title-block {
    gap: 6px;
  }

  .title-block h1 {
    display: none;
  }

  .top-actions {
    gap: 4px;
  }
}

@media (max-width: 380px) {
  .game-shell {
    padding: 4px;
  }

  .game-panel {
    padding: 6px;
  }

  .nonogram-board {
    --cell: min(7.4vw, calc((100vw - 60px) / (var(--size) + 2.2)), calc((100dvh - 310px) / 12.2), 37px);
    --clue: calc(var(--cell) * 2.2);
    padding: 6px;
  }
}

@media (max-height: 700px) {
  .seed {
    display: none;
  }

  .status-strip > div {
    padding: 5px 8px;
  }

  .message {
    font-size: 12px;
  }
}

@media (max-width: 760px) and (max-height: 700px) {
  .nonogram-board {
    --cell: min(7.4vw, calc((100vw - 60px) / (var(--size) + 2.2)), calc((100dvh - 276px) / 12.2), 37px);
    --clue: calc(var(--cell) * 2.2);
  }
}
