:root {
  --text-color: #22170e;
  --accent-color: #e07b39;
  --surface-color: #fbf3e7;
  --panel-rgb: 242 228 207;
  --panel-opacity: 0.8;
  --page-background-image: url("../assets/images/fallback-parchment.svg");
  --resolved-background-image: var(--page-background-image);
  --line-color: rgba(44, 30, 20, 0.14);
  --soft-shadow: 0 22px 60px rgba(33, 23, 14, 0.16);
  --button-shadow: 0 14px 30px rgba(42, 24, 13, 0.18);
  --button-edge: rgba(255, 243, 224, 0.42);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-top: max(24px, env(safe-area-inset-top));
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-color);
  background:
    radial-gradient(circle at top left, rgba(224, 123, 57, 0.14), transparent 22%),
    linear-gradient(180deg, rgba(28, 19, 12, 0.04), rgba(28, 19, 12, 0.12)),
    #decfb7;
  font-family: Georgia, "Times New Roman", serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(120deg, rgba(16, 10, 6, 0.28), rgba(16, 10, 6, 0.06)),
    var(--page-background-image) center / cover no-repeat;
  filter: saturate(1.05) contrast(1.02);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to bottom, rgba(255, 244, 224, 0.06) 1px, transparent 1px) 0 0 / 100% 40px,
    linear-gradient(to right, rgba(255, 244, 224, 0.04) 1px, transparent 1px) 0 0 / 40px 100%;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

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

a {
  text-decoration: none;
}

button {
  cursor: pointer;
}

input,
select,
button {
  border: 0;
}

.glass-panel,
.dialog-card,
.topbar {
  background: rgba(var(--panel-rgb), var(--panel-opacity));
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 244, 227, 0.38);
  box-shadow: var(--soft-shadow);
}

.section-tag {
  margin: 0 0 12px;
  color: rgba(70, 43, 18, 0.72);
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

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

.support-copy,
.home-description,
.menu-row-copy small,
.page-heading p,
.target-item span,
.field span,
.reveal-row-meta span {
  color: rgba(42, 26, 13, 0.84);
}

.home-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  min-height: 100svh;
}

.home-visual {
  position: relative;
  overflow: hidden;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(16, 10, 6, 0.2), rgba(16, 10, 6, 0.66)),
    var(--page-background-image) center / cover no-repeat;
}

.home-visual-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(16, 10, 6, 0.16) 12%, rgba(16, 10, 6, 0.75) 88%);
}

.home-visual-copy {
  position: absolute;
  left: clamp(28px, 5vw, 72px);
  bottom: clamp(24px, 6vh, 68px);
  z-index: 1;
  width: min(540px, calc(100% - 56px));
  padding-bottom: clamp(72px, 8vw, 110px);
  color: #f8efdf;
}

.home-visual-copy .section-tag {
  margin-bottom: 10px;
  color: rgba(255, 231, 196, 0.76);
}

.home-visual-copy h1 {
  position: absolute;
  left: 0;
  bottom: 0;
  margin: 0;
  font-size: clamp(3.9rem, 8.5vw, 7rem);
  line-height: 0.88;
  letter-spacing: -0.06em;
}

.home-description {
  max-width: 28ch;
  margin-bottom: 0;
  line-height: 1.6;
}

.home-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 100svh;
  padding: clamp(22px, 3vw, 42px);
}

.panel-header,
.pane-header,
.topbar,
.history-summary,
.start-bar,
.reveal-row,
.session-meta {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  align-items: center;
  justify-content: initial;
}

.panel-header h2,
.page-heading h1,
.dialog-card h2 {
  margin-bottom: 0;
  font-size: clamp(2.4rem, 4vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.home-panel-fill {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding-top: 4px;
}

.home-panel-fill span {
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(84, 57, 34, 0.12), rgba(84, 57, 34, 0.04));
}

.home-panel-fill span:nth-child(1) {
  width: 132px;
  height: 10px;
}

.home-panel-fill span:nth-child(2) {
  width: 68px;
  height: 10px;
}

.home-panel-fill span:nth-child(3) {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.ghost-link,
.primary-button,
.topbar-nav a,
.menu-row,
.library-card,
.key-button,
.letter-button,
.field input,
.field select,
.compact-field input,
.field input[type="color"],
.field input[type="file"] {
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.ghost-link,
.primary-button,
.topbar-nav a {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line-color);
  box-shadow: var(--button-shadow);
}

.topbar-back {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  margin-right: 2px;
  border-radius: 999px;
  border: 1px solid rgba(96, 64, 38, 0.16);
  background: linear-gradient(180deg, rgba(255, 249, 239, 0.92), rgba(232, 218, 194, 0.78));
  color: rgba(39, 24, 12, 0.92);
  box-shadow: var(--button-shadow);
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.topbar-back:hover {
  transform: translateY(-2px);
  border-color: rgba(224, 123, 57, 0.28);
}

.topbar-back span {
  position: relative;
  top: -1px;
  font-size: 1.3rem;
  line-height: 1;
}

.ghost-link::before,
.primary-button::before,
.topbar-nav a::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.42), rgba(255, 248, 236, 0.06));
  pointer-events: none;
}

.ghost-link:hover,
.primary-button:hover,
.topbar-nav a:hover,
.menu-row:hover,
.library-card:hover,
.key-button:hover,
.letter-button:hover {
  transform: translateY(-2px);
}

.ghost-link {
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.86), rgba(233, 220, 198, 0.72));
  border-color: rgba(101, 67, 40, 0.18);
}

.primary-button {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-color) 84%, #ffcc92 16%), color-mix(in srgb, var(--accent-color) 88%, #8f4416 12%));
  color: #fff7ed;
  border-color: rgba(126, 63, 27, 0.24);
}

.primary-button::after,
.ghost-link::after,
.topbar-nav a::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.24) 38%, transparent 58%);
  transform: translateX(-120%);
  transition: transform 320ms ease;
}

.primary-button:hover::after,
.ghost-link:hover::after,
.topbar-nav a:hover::after {
  transform: translateX(120%);
}

.primary-button:active,
.ghost-link:active,
.topbar-nav a:active,
.key-button:active,
.letter-button:active,
.menu-row:active,
.library-card:active {
  transform: translateY(0);
}

.ghost-link > *,
.primary-button > *,
.topbar-nav a > * {
  position: relative;
  z-index: 1;
}

.home-menu {
  display: grid;
  gap: 6px;
}

.menu-row {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  border-radius: 22px;
  background: transparent;
  text-align: left;
}

.menu-row::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(224, 123, 57, 0.34), rgba(224, 123, 57, 0.04) 72%);
  opacity: 0;
}

.menu-row:hover::before,
.menu-row:focus-visible::before {
  opacity: 1;
}

.menu-row-indicator {
  position: relative;
  width: 6px;
  border-radius: 999px;
  background: transparent;
  z-index: 1;
}

.menu-row:hover .menu-row-indicator,
.menu-row:focus-visible .menu-row-indicator {
  background: var(--accent-color);
}

.menu-row-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
}

.menu-row-copy strong {
  font-size: 1.16rem;
}

.menu-row-copy small {
  line-height: 1.45;
}

.app-stage {
  min-height: 100vh;
  padding: var(--safe-top) 24px var(--safe-bottom);
}

.topbar {
  width: min(1320px, 100%);
  margin: 0 auto 14px;
  padding: 16px 20px;
  border-radius: 999px;
}

.brand-link {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.topbar-context {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin-left: 10px;
}

.topbar-context .section-tag {
  margin-bottom: 0;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

.topbar-context strong {
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  grid-column: -2 / -1;
  flex-wrap: wrap;
  gap: 12px;
  justify-self: end;
}

.topbar-nav a {
  color: rgba(55, 34, 18, 0.88);
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.82), rgba(238, 227, 205, 0.66));
  border-color: rgba(101, 67, 40, 0.14);
}

.page-shell {
  width: min(1580px, calc(100vw - 72px));
  margin: 0 auto;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  align-items: end;
  margin-bottom: 24px;
}

.page-heading h1 {
  font-size: clamp(2.8rem, 5vw, 5rem);
}

.page-heading p {
  max-width: 44ch;
  margin-bottom: 10px;
  line-height: 1.65;
  color: rgba(40, 24, 12, 0.88);
}

.compact-heading h1 {
  font-size: clamp(2.2rem, 4vw, 3.6rem);
}

.prepare-layout,
.classic-layout,
.frame-layout,
.reveal-layout,
.settings-layout {
  display: grid;
  gap: 20px;
}

.prepare-layout,
.settings-layout {
  grid-template-columns: minmax(0, 1.22fr) minmax(420px, 0.78fr);
}

.classic-layout,
.frame-layout,
.reveal-layout {
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
}

.library-pane,
.stats-pane,
.board-panel,
.keyboard-panel,
.frame-board-panel,
.frame-sidebar,
.reveal-rows-panel,
.reveal-sidebar,
.settings-form,
.preview-panel,
.filter-panel,
.empty-state,
.history-entry {
  padding: 24px;
  border-radius: var(--radius-xl);
}

body[data-page="prepare"] .app-stage {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

body[data-page="prepare"] .page-shell {
  flex: 1;
}

body[data-page="prepare"] .prepare-layout {
  align-items: stretch;
  min-height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 96px);
}

body[data-page="prepare"] .prepare-layout > * {
  min-height: 0;
}

body[data-page="prepare"] .library-pane,
body[data-page="prepare"] .stats-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body[data-page="prepare"] .library-groups {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 8px;
  align-content: start;
  grid-auto-rows: max-content;
}

body[data-page="prepare"] .library-pane {
  overflow: hidden;
}

body[data-page="prepare"] .stats-pane {
  justify-content: start;
}

body[data-page="prepare"] .stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-inline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.mode-inline-head .section-tag {
  margin: 0;
}

.mode-inline-head h2 {
  font-size: 1.55rem;
}

body[data-page="settings"] .app-stage {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

body[data-page="settings"] .page-shell {
  flex: 1;
}

.prepare-history-section {
  display: grid;
  gap: 14px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid rgba(62, 38, 20, 0.12);
}

.prepare-history-header {
  align-items: end;
}

.prepare-history-header h3 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.prepare-history-list {
  display: grid;
  gap: 12px;
  max-height: min(44vh, 480px);
  overflow: auto;
  padding-right: 6px;
}

.prepare-history-entry {
  padding: 18px 18px 16px;
  border-radius: 24px;
  background: rgba(255, 248, 236, 0.5);
  border: 1px solid rgba(62, 38, 20, 0.12);
}

.prepare-history-entry .history-summary {
  align-items: center;
}

.prepare-history-entry .history-body {
  margin-top: 14px;
  padding-top: 14px;
}

.prepare-history-empty {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 248, 236, 0.42);
  border: 1px dashed rgba(96, 64, 38, 0.18);
}

.settings-layout {
  align-items: start;
}

.settings-form {
  min-height: 660px;
}

body[data-page="settings"] .settings-layout {
  min-height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 96px);
}

.preview-panel {
  position: sticky;
  top: calc(var(--safe-top) + 4px);
}

.pane-header h2 {
  margin-bottom: 0;
  font-size: 1.85rem;
}

.library-groups,
.library-group,
.settings-form,
.history-layout,
.history-list,
.target-list,
.rule-copy,
.preview-stage,
.reveal-rows,
.keyboard {
  display: grid;
  gap: 18px;
}

.library-group {
  align-content: start;
}

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

.library-card {
  padding: 20px;
  border-radius: 24px;
  text-align: left;
  border: 1px solid rgba(62, 38, 20, 0.14);
  background: rgba(255, 248, 236, 0.46);
}

.library-card strong,
.target-item strong,
.session-meta strong,
.history-summary strong,
.history-body strong,
.reveal-row-meta strong {
  display: block;
}

.library-card span {
  display: block;
  margin-top: 8px;
  color: rgba(42, 26, 13, 0.82);
}

.library-card.is-selected,
.target-item.is-found,
.reveal-row.is-guessed,
.reveal-row.is-revealed {
  background: rgba(224, 123, 57, 0.18);
  border-color: rgba(224, 123, 57, 0.38);
}

.start-bar {
  position: sticky;
  bottom: 0;
  padding: 18px 20px;
  border-radius: 24px;
  background: rgba(255, 247, 232, 0.78);
  border: 1px solid rgba(62, 38, 20, 0.14);
}

.start-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.compact-field {
  display: grid;
  gap: 8px;
}

.compact-field input,
.field input,
.field select,
.classic-input-row input {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.86), rgba(236, 226, 209, 0.78));
  border: 1px solid rgba(62, 38, 20, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(180deg, rgba(255, 248, 236, 0.86), rgba(236, 226, 209, 0.78)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 5.5 8 10l4.5-4.5' stroke='%23503A27' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, calc(100% - 16px) 50%;
  background-size: auto, 14px;
  padding-right: 42px;
}

.field input[type="color"] {
  width: 100%;
  min-height: 64px;
  padding: 8px;
}

.field input[type="file"] {
  padding: 14px 16px;
  line-height: 1.4;
}

.field input[type="file"]::file-selector-button {
  margin-right: 14px;
  padding: 10px 16px;
  border: 1px solid rgba(101, 67, 40, 0.16);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.92), rgba(235, 223, 201, 0.72));
  color: rgba(55, 34, 18, 0.92);
  box-shadow: var(--button-shadow);
  cursor: pointer;
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(101, 67, 40, 0.16);
  border-radius: 12px;
}

.stats-grid,
.metric-grid,
.compact-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stats-grid article,
.compact-stats article {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 248, 236, 0.52);
  border: 1px solid rgba(62, 38, 20, 0.12);
}

.stats-grid article strong,
.compact-stats article strong {
  display: block;
  margin-top: 12px;
  font-size: 1.9rem;
}

.game-shell {
  padding-bottom: 20px;
}

.session-meta {
  align-items: center;
}

.session-meta span {
  color: rgba(42, 26, 13, 0.82);
}

.classic-board {
  --classic-columns: 5;
  display: grid;
  grid-template-columns: repeat(var(--classic-columns), minmax(0, 74px));
  justify-content: center;
  gap: 10px;
  margin: 30px 0 24px;
}

.board-cell,
.mini-cell,
.reveal-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid rgba(62, 38, 20, 0.14);
  background: rgba(255, 248, 236, 0.56);
  font-size: 1.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.board-cell.is-correct,
.mini-cell.is-correct,
.key-button.is-correct {
  background: #45684a;
  color: #fff7ed;
}

.board-cell.is-present,
.mini-cell.is-present,
.key-button.is-present {
  background: #ad7b2b;
  color: #fff7ed;
}

.board-cell.is-absent,
.mini-cell.is-absent,
.key-button.is-absent {
  background: #6f6259;
  color: #f4ecdf;
}

.classic-input-row,
.reveal-guess-form,
.field,
.form-section {
  display: grid;
  gap: 10px;
}

.guess-inline {
  display: flex;
  gap: 10px;
}

.guess-inline input {
  flex: 1;
}

.keyboard-row,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.key-button,
.letter-button {
  min-height: 46px;
  min-width: 46px;
  padding: 0 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 248, 236, 0.88), rgba(235, 223, 201, 0.7));
  border: 1px solid rgba(62, 38, 20, 0.14);
  box-shadow: var(--button-shadow);
}

.key-button.is-wide {
  min-width: 84px;
}

.frame-grid {
  --frame-size: 10;
  display: grid;
  grid-template-columns: repeat(var(--frame-size), minmax(0, 1fr));
  gap: 6px;
  margin: 24px 0;
}

.frame-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: rgba(255, 248, 236, 0.5);
  border: 1px solid rgba(62, 38, 20, 0.14);
  font-size: 1rem;
  font-weight: 700;
}

.frame-cell.is-active {
  background: rgba(224, 123, 57, 0.28);
}

.frame-cell.is-found-path {
  background: #45684a;
  color: #fff7ed;
}

.target-list {
  gap: 10px;
}

.target-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 248, 236, 0.46);
  border: 1px solid rgba(62, 38, 20, 0.12);
}

.reveal-rows {
  margin: 18px 0;
}

.reveal-row {
  padding: 16px 18px;
  border-radius: 24px;
  background: rgba(255, 248, 236, 0.46);
  border: 1px solid rgba(62, 38, 20, 0.12);
  align-items: center;
}

.reveal-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reveal-cell {
  width: 48px;
  background: rgba(88, 68, 51, 0.12);
}

.reveal-cell.is-open {
  background: rgba(224, 123, 57, 0.22);
}

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

.letter-button.is-used {
  opacity: 0.45;
}

.history-layout {
  gap: 18px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.history-entry summary {
  cursor: pointer;
  list-style: none;
}

.history-entry summary::-webkit-details-marker {
  display: none;
}

.history-summary span {
  display: block;
  margin-top: 6px;
  color: rgba(42, 26, 13, 0.82);
}

.history-body {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(62, 38, 20, 0.12);
}

.history-details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.history-word-list,
.history-feedback-stack {
  margin: 16px 0 0;
  padding: 0;
}

.history-word-list {
  padding-left: 18px;
}

.history-guess-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.mini-cell {
  width: 34px;
  font-size: 0.92rem;
}

.preview-stage {
  --preview-image: var(--resolved-background-image);
  position: relative;
  min-height: 640px;
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(120deg, rgba(16, 10, 6, 0.24), rgba(16, 10, 6, 0.06)),
    var(--preview-image) center / cover no-repeat;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 10, 6, 0.08), rgba(16, 10, 6, 0.46));
}

.preview-card {
  position: absolute;
  left: 50%;
  bottom: 30px;
  z-index: 1;
  width: min(390px, calc(100% - 64px));
  padding: 28px;
  border-radius: 26px;
  transform: translateX(-4%);
  background: rgba(var(--panel-rgb), var(--panel-opacity));
  backdrop-filter: blur(16px);
  box-shadow: var(--soft-shadow);
}

.preview-card h3 {
  margin-bottom: 12px;
  font-size: 2rem;
}

.preview-card .section-tag,
.preview-card p,
.preview-card h3 {
  position: relative;
  z-index: 1;
  color: rgba(255, 245, 232, 0.96);
}

.preview-card .section-tag {
  color: rgba(255, 214, 167, 0.82);
}

.preview-card p {
  line-height: 1.55;
  color: rgba(247, 232, 210, 0.88);
}

.rule-dialog,
.result-dialog {
  padding: 0;
  border: 0;
  background: transparent;
}

.dialog-card {
  width: min(560px, calc(100vw - 32px));
  margin: auto;
  padding: 28px;
  border-radius: 30px;
}

.rule-copy p:last-child,
.dialog-card p:last-of-type {
  margin-bottom: 0;
}

.save-state {
  color: rgba(42, 26, 13, 0.84);
  font-weight: 600;
}

.empty-state {
  text-align: center;
}

.error-state {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.menu-row {
  border: 1px solid transparent;
}

.menu-row:hover,
.menu-row:focus-visible {
  border-color: rgba(224, 123, 57, 0.18);
}

.ghost-link:focus-visible,
.primary-button:focus-visible,
.topbar-back:focus-visible,
.topbar-nav a:focus-visible,
.menu-row:focus-visible,
.library-card:focus-visible,
.key-button:focus-visible,
.letter-button:focus-visible,
.field input:focus-visible,
.field select:focus-visible,
.compact-field input:focus-visible {
  outline: 2px solid rgba(224, 123, 57, 0.48);
  outline-offset: 2px;
}

@media (min-width: 1400px) {
  .topbar,
  .page-shell {
    width: min(1700px, calc(100vw - 80px));
  }

  .settings-layout {
    grid-template-columns: minmax(860px, 1.16fr) minmax(520px, 0.84fr);
    gap: 24px;
  }

  .page-heading {
    margin-bottom: 30px;
  }

  .page-heading p {
    max-width: 36ch;
    font-size: 1.08rem;
  }

  .panel-header h2,
  .page-heading h1 {
    letter-spacing: -0.06em;
  }

  body[data-page="prepare"] .prepare-layout {
    min-height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 104px);
  }
}

@media (max-width: 1180px) {
  .home-shell,
  .prepare-layout,
  .classic-layout,
  .frame-layout,
  .reveal-layout,
  .settings-layout,
  .page-heading,
  .history-details-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: start;
  }

  .preview-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .home-shell {
    min-height: auto;
  }

  .home-visual {
    min-height: 52vh;
  }

  .topbar {
    grid-template-columns: auto 1fr;
    border-radius: 28px;
    padding: 16px;
  }

  .brand-link {
    order: 2;
  }

  .topbar-context {
    grid-column: 1 / -1;
    order: 4;
    margin-left: 0;
    padding-top: 4px;
  }

  .topbar-nav {
    grid-column: 1 / -1;
    order: 5;
    justify-self: start;
  }

  .panel-header h2,
  .page-heading h1,
  .dialog-card h2 {
    font-size: 2.3rem;
  }

  .library-grid,
  .field-grid,
  .stats-grid,
  .compact-stats,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  body[data-page="prepare"] .stats-grid {
    grid-template-columns: 1fr;
  }

  .classic-board {
    grid-template-columns: repeat(var(--classic-columns), minmax(0, 1fr));
  }

  .guess-inline,
  .dialog-actions,
  .start-controls {
    flex-direction: column;
  }

  .letter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
