:root {
  --ink: #101721;
  --ink-soft: #1b2734;
  --paper: #f3efe5;
  --paper-deep: #e7dfce;
  --gold: #cda968;
  --gold-bright: #e5c987;
  --sage: #859b89;
  --red: #b95e50;
  --white: #fffdf8;
  --shadow: 0 24px 70px rgba(3, 8, 14, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #0b1119;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -20%, #283b4d 0, #101721 48%, #080d13 100%); }
button { font: inherit; }
.app-shell, dialog { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, .piece-image { -webkit-user-drag: none; }
.app-shell { width: min(100%, 560px); min-height: calc(100vh - 44px); margin: 0 auto; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.masthead { height: 72px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: var(--white); border-bottom: 1px solid rgba(229,201,135,.35); }
.brand { border: 0; background: transparent; color: inherit; display: flex; align-items: center; gap: 10px; padding: 8px 0; letter-spacing: .07em; font-size: .87rem; cursor: pointer; }
.brand b { color: var(--gold-bright); font-weight: 750; }
.brand-mark { width: 26px; height: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; transform: rotate(2deg); }
.brand-mark i { display: block; background: var(--gold); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: #688377; }
.header-actions { display: flex; gap: 8px; }
.icon-button { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; color: var(--white); background: transparent; cursor: pointer; font-weight: 700; }
.screen { display: none; min-height: calc(100vh - 116px); padding: 34px 24px 28px; animation: appear .32s ease both; }
.screen.active { display: flex; flex-direction: column; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.edition-label { color: #765f36; font-size: .74rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; margin: 14px 0; line-height: 1.02; }
h1 { font-size: clamp(2.7rem, 11vw, 4.35rem); letter-spacing: -.045em; }
h1 em { color: #7a5631; font-weight: 400; }
h2 { font-size: clamp(2rem, 8vw, 3.2rem); }
.lead { margin: 0 0 28px; color: #52606a; line-height: 1.55; font-size: 1.02rem; }
.start-screen { padding-top: 26px; }
.start-screen h1 { font-size: clamp(2.45rem, 9.5vw, 3.8rem); margin: 10px 0; }
.start-screen .lead { margin-bottom: 18px; }
.start-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.text-button { min-height: 36px; border: 0; background: transparent; color: #765f36; padding: 4px 0; font-size: .76rem; font-weight: 800; text-decoration: underline; cursor: pointer; }
.difficulty-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 2px 0 18px; }
.difficulty-card { min-height: 108px; border: 1px solid #cfc5b2; border-radius: 3px; background: rgba(255,255,255,.48); color: var(--ink); text-align: left; padding: 12px; display: grid; grid-template-columns: auto 1fr; align-items: end; cursor: pointer; transition: .18s ease; }
.difficulty-card:hover { transform: translateY(-2px); border-color: #9e8354; }
.difficulty-card.selected { background: var(--ink-soft); color: var(--white); border-color: var(--ink-soft); box-shadow: 0 8px 22px rgba(16,23,33,.18); }
.difficulty-name { grid-column: 1 / -1; align-self: start; font-weight: 750; }
.difficulty-card strong { font-family: Georgia, serif; font-size: 2.15rem; font-weight: 500; color: #8b6538; }
.difficulty-card.selected strong { color: var(--gold-bright); }
.difficulty-card > span:not(.difficulty-name) { color: inherit; opacity: .62; font-size: .78rem; padding-bottom: 5px; }
.difficulty-card .track-status { grid-column: 1 / -1; margin-top: 5px; color: #776e61; font-size: .65rem; font-weight: 800; }
.difficulty-card.selected .track-status { color: #e7dac0; }
.difficulty-card .track-status.complete { color: #52715d; }
.difficulty-card.selected .track-status.complete { color: #b8dfc3; }
.primary-button, .secondary-button { min-height: 52px; border-radius: 2px; padding: 0 19px; font-weight: 800; letter-spacing: .015em; cursor: pointer; transition: .15s ease; }
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; box-shadow: 0 8px 18px rgba(16,23,33,.16); }
.primary-button:hover { background: #253442; }
.secondary-button { border: 1px solid #9e927e; background: transparent; color: var(--ink); }
.secondary-button:disabled { opacity: .35; cursor: not-allowed; }
.ritual-note { display: flex; justify-content: center; gap: 20px; margin-top: 18px; font-size: .73rem; color: #746e64; }
.ritual-note span + span::before { content: "·"; margin-right: 20px; }
.clue-screen { text-align: center; justify-content: center; align-items: center; }
.clue-ornament { width: 64px; height: 64px; display: grid; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: #8c6b37; font-size: 1.7rem; margin-bottom: 25px; }
.clue-screen h2 { max-width: 460px; font-size: clamp(2rem, 8vw, 3.45rem); line-height: 1.08; }
.clue-rule { color: #716a60; margin: 12px 0 28px; }
.clue-screen .primary-button { min-width: 230px; }
.fine-print { font-size: .78rem; color: #7b7468; }
.tutorial-screen { text-align: center; align-items: center; }
.tutorial-screen h2 { margin-bottom: 8px; }
.tutorial-screen .lead { max-width: 430px; margin-bottom: 18px; }
.chosen-challenge { width: min(100%, 430px); display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: center; margin: -6px 0 18px; padding: 10px 12px; border: 1px solid #d1c5af; background: rgba(255,255,255,.46); text-align: left; }
.chosen-challenge > span { grid-column: 1; color: #765f36; font-size: .62rem; font-weight: 800; letter-spacing: .13em; }
.chosen-challenge strong { grid-column: 1; font-size: .79rem; color: #313c44; }
.chosen-challenge button { grid-column: 2; grid-row: 1 / 3; border: 0; background: transparent; color: #765f36; padding: 8px 0; font-size: .75rem; font-weight: 800; text-decoration: underline; cursor: pointer; }
.tutorial-workspace { width: min(100%, 275px); display: grid; justify-items: center; gap: 10px; }
.tutorial-board { width: 92px; aspect-ratio: 808 / 1200; display: grid; grid-template-rows: repeat(3, 1fr); background: #15212b; border: 5px solid #17222c; outline: 1px solid #a88d5f; box-shadow: 0 10px 25px rgba(19,27,35,.2); }
.tutorial-slot { position: relative; border: 1px solid rgba(229,201,135,.18); overflow: hidden; padding: 0; background: rgba(255,255,255,.025); }
.tutorial-slot.target { background: rgba(205,169,104,.24); box-shadow: inset 0 0 0 2px var(--gold); }
.tutorial-arrow { color: #846b43; font-size: 1.35rem; }
.tutorial-tray { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tutorial-piece { position: relative; aspect-ratio: 808 / 400; overflow: hidden; border: 2px solid transparent; background: #18242e; padding: 0; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.16); }
.tutorial-piece.selected { border-color: var(--gold-bright); box-shadow: 0 0 0 2px #18242e, 0 0 0 4px var(--gold-bright); transform: translateY(-3px); }
.tutorial-message { min-height: 24px; color: #655c4e; font-weight: 700; margin: 16px 0 12px; }
.tutorial-message.success { color: #54705d; }
.tutorial-continue { width: 100%; margin-top: auto; }
.game-screen { padding: 18px 16px 22px; background: linear-gradient(#eae3d5, var(--paper)); }
.game-status { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 96px 1fr 72px; align-items: center; gap: 12px; margin: -5px -5px 13px; padding: 5px; background: rgba(234,227,213,.96); backdrop-filter: blur(7px); }
.game-status > div { display: flex; flex-direction: column; }
.game-status strong { font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.timer-block { position: relative; min-height: 55px; display: grid !important; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 7px; padding: 6px 9px; color: var(--white); background: var(--ink); border: 1px solid var(--gold); border-radius: 3px; box-shadow: 0 5px 14px rgba(16,23,33,.2); }
.timer-block .status-label { grid-column: 1; grid-row: 1 / 3; color: var(--gold-bright); writing-mode: vertical-rl; transform: rotate(180deg); font-size: .55rem; }
#timer { grid-column: 2; grid-row: 1 / 3; color: var(--white); font-size: 1.75rem; line-height: 1; letter-spacing: .02em; }
#timer.urgent { color: #ff9585; animation: urgentPulse .85s ease-in-out infinite alternate; }
@keyframes urgentPulse { from { opacity: 1; } to { opacity: .68; } }
.status-label { font-size: .61rem; font-weight: 800; letter-spacing: .12em; color: #786e60; }
.status-right { text-align: right; }
.status-right strong { font-family: Georgia, serif; font-size: 1.55rem; color: #313c44; transition: color .2s ease, transform .2s ease; }
.status-right.final-stretch strong { color: #a44736; animation: piecesPulse .75s ease-in-out infinite alternate; }
@keyframes piecesPulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.progress-wrap { height: 4px; background: #d0c7b6; overflow: hidden; }
.progress-wrap span { display: block; width: 0; height: 100%; background: #9b713d; transition: width .22s ease; }
.board-wrap { position: relative; margin: 0 auto; width: min(100%, 310px); }
.puzzle-board { width: 100%; aspect-ratio: 808 / 1200; display: grid; background: #15212b; border: 7px solid #17222c; outline: 1px solid #a88d5f; box-shadow: 0 14px 35px rgba(19,27,35,.24); }
.board-slot { border: 1px solid rgba(229,201,135,.16); background: radial-gradient(circle, rgba(255,255,255,.035), transparent 60%); position: relative; padding: 0; min-width: 0; overflow: hidden; }
.board-slot.target { background: rgba(205,169,104,.24); box-shadow: inset 0 0 0 2px var(--gold); }
.piece-image { position: absolute; inset: 0; background-image: url("./assets/mona-lisa-game.jpg"); background-repeat: no-repeat; }
.board-message { position: absolute; inset: 42% 12% auto; background: rgba(11,17,25,.92); color: white; text-align: center; padding: 12px; border: 1px solid var(--gold); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.board-message.show { opacity: 1; }
.art-preview-overlay[hidden] { display: none; }
.art-preview-overlay { position: fixed; z-index: 250; inset: 0; display: grid; place-items: center; padding: calc(22px + env(safe-area-inset-top, 0px)) 22px calc(22px + env(safe-area-inset-bottom, 0px)); background: #101721; color: var(--white); }
.preview-countdown { font-family: Georgia, "Times New Roman", serif; color: var(--gold-bright); font-size: clamp(7rem, 34vw, 12rem); line-height: 1; font-variant-numeric: tabular-nums; animation: previewPulse .65s ease both; }
.preview-art-frame { display: none; width: min(88vw, 430px); max-height: 82svh; text-align: center; }
.preview-art-frame .edition-label { margin-bottom: 15px; color: var(--gold-bright); }
.preview-art-frame img { display: block; max-width: 100%; max-height: calc(82svh - 44px); margin: 0 auto; object-fit: contain; border: 7px solid #17222c; outline: 1px solid var(--gold); box-shadow: 0 22px 55px rgba(0,0,0,.5); }
.art-preview-overlay.show-art .preview-countdown { display: none; }
.art-preview-overlay.show-art .preview-art-frame { display: block; animation: artworkFlash .16s ease both; }
@keyframes previewPulse { from { opacity: .25; transform: scale(.78); } to { opacity: 1; transform: scale(1); } }
@keyframes artworkFlash { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.piece-inspector { position: fixed; z-index: 100; top: 50%; left: 50%; width: min(43vw, 170px); aspect-ratio: var(--piece-aspect, .673); overflow: hidden; pointer-events: none; background: #18242e; border: 2px solid var(--gold-bright); box-shadow: 0 18px 42px rgba(8,14,20,.5), 0 0 0 4px rgba(246,239,225,.8); opacity: 0; transform: translate(-50%, -50%) scale(.84); transition: opacity .09s ease, transform .09s ease; }
.piece-inspector.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.piece-dock { position: relative; margin-top: 17px; }
.dock-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.dock-heading span, .hold-label { font-size: .68rem; font-weight: 800; letter-spacing: .12em; color: #6b6256; }
.hold-label b { color: #a36b2c; margin-left: .25rem; }
.dock-heading small { color: #797267; font-size: .69rem; }
.piece-tray { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; min-height: 80px; }
.tray-piece, .hold-slots button { border: 2px solid transparent; background: #18242e; position: relative; min-width: 0; aspect-ratio: var(--piece-aspect, .673); overflow: hidden; cursor: pointer; padding: 0; box-shadow: 0 3px 8px rgba(0,0,0,.15); }
.tray-piece, .hold-slots button, .tutorial-piece, .board-slot, .tutorial-slot { touch-action: manipulation; }
.tray-piece.selected, .hold-slots button.selected { border-color: #e8c974; box-shadow: 0 0 0 2px #18242e, 0 0 0 4px #e8c974; transform: translateY(-3px); }
.hold-row { margin-top: 13px; display: grid; grid-template-columns: minmax(124px, auto) minmax(140px, 1fr) auto; gap: 11px; align-items: center; }
.hold-copy { display: grid; gap: 3px; }
.hold-copy small { color: #817668; font-size: .72rem; line-height: 1.2; }
.hold-slots { display: grid; grid-template-columns: repeat(var(--hold-count, 2), minmax(32px, 1fr)); gap: 7px; }
.hold-slots button { border: 1px dashed #9f9484; background: rgba(255,255,255,.34); }
.hold-slots button.available { border-color: #b4853e; background: rgba(232,201,116,.22); animation: hold-ready 1.15s ease-in-out infinite alternate; }
.hold-row .secondary-button { min-height: 44px; font-size: .76rem; padding: 0 10px; }
@keyframes hold-ready { from { box-shadow: 0 0 0 0 rgba(180,133,62,0); } to { box-shadow: 0 0 0 3px rgba(180,133,62,.18); } }
.result-screen { align-items: center; text-align: center; padding-top: 25px; }
.result-art-frame { width: 175px; margin-top: 17px; padding: 7px; background: #151e27; border: 1px solid var(--gold); box-shadow: 0 14px 28px rgba(16,23,33,.22); }
.result-art-frame img { display: block; width: 100%; }
.result-screen h2 { margin-bottom: 3px; }
.artist { margin: 0; color: #6b655d; }
.result-metrics { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); margin: 22px 0 15px; border-top: 1px solid #ccc2b2; border-bottom: 1px solid #ccc2b2; }
.result-metrics div { padding: 13px 7px; display: flex; flex-direction: column; gap: 4px; }
.result-metrics div + div { border-left: 1px solid #ccc2b2; }
.result-metrics span { font-size: .67rem; color: #776f63; text-transform: uppercase; letter-spacing: .11em; font-weight: 800; }
.result-metrics strong { font-family: Georgia, serif; font-size: 1.3rem; }
.result-streak { margin: -2px 0 16px; color: #76591f; font-weight: 850; }
.result-badge { margin: 0 0 18px; padding: 8px 14px; border: 1px solid #9c7b42; color: #76591f; background: #f6e9c5; font-size: .75rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.art-note { max-width: 460px; margin: 0 auto 20px; color: #4e5961; line-height: 1.55; }
.result-actions { width: 100%; display: grid; gap: 9px; }
.share-status { min-height: 20px; color: #54705d; font-weight: 750; }
.beta-feedback { width: 100%; margin: 2px 0 18px; padding: 15px; border: 1px solid #d1c5af; background: rgba(255,255,255,.46); text-align: left; }
.feedback-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.feedback-heading small { color: #746e64; font-size: .74rem; }
.beta-feedback fieldset { min-width: 0; margin: 0 0 13px; padding: 0; border: 0; }
.beta-feedback legend { margin-bottom: 7px; color: #3d4850; font-size: .84rem; font-weight: 750; }
.feedback-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.feedback-options button { min-height: 40px; border: 1px solid #a99e8a; border-radius: 2px; background: var(--white); color: var(--ink); font-size: .76rem; font-weight: 750; cursor: pointer; }
.feedback-options button.selected { border-color: var(--ink); background: var(--ink); color: var(--white); box-shadow: 0 4px 12px rgba(16,23,33,.16); }
.feedback-status { min-height: 18px; margin: 0; color: #54705d; font-size: .78rem; font-weight: 750; }
.image-credit { color: #847d72; font-size: .67rem; }
.metrics-screen { text-align: center; }
.metrics-screen h2 { margin-bottom: 7px; }
.metrics-screen .lead { margin-bottom: 20px; }
.metrics-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin: 4px 0 24px; }
.metric-card { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 14px 5px; background: white; border: 1px solid #d4cbbb; text-align: center; }
.metric-card span { color: #6d675e; font-size: .68rem; font-weight: 800; line-height: 1.2; text-transform: uppercase; letter-spacing: .04em; }
.metric-card strong { font-family: Georgia, serif; font-size: 1.45rem; }
dialog { width: min(calc(100% - 32px), 500px); border: 1px solid #a88d5f; border-radius: 3px; padding: 32px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5,9,13,.76); backdrop-filter: blur(3px); }
dialog h2 { font-size: 2.2rem; }
dialog li, dialog p { line-height: 1.5; margin-bottom: 10px; }
.dialog-close { position: absolute; right: 12px; top: 10px; border: 0; background: transparent; font-size: 1.9rem; cursor: pointer; }
footer { width: min(100%, 560px); margin: 0 auto; min-height: 44px; padding: 0 14px; color: #aab3ba; font-size: .67rem; display: flex; align-items: center; justify-content: space-between; }
footer button { color: #aab3ba; border: 0; background: transparent; font-size: inherit; text-decoration: underline; cursor: pointer; }

@media (max-height: 760px) {
  .masthead { height: 60px; }
  .screen { min-height: calc(100vh - 104px); }
  .game-screen { padding-top: 10px; }
  .board-wrap { width: min(100%, 244px); }
  .piece-tray { min-height: 60px; }
  .piece-dock { margin-top: 10px; }
  .hold-row { margin-top: 9px; }
  .hold-row { grid-template-columns: 1fr auto; }
  .hold-copy { grid-column: 1 / -1; }
}

@media (max-width: 390px) {
  .start-screen { padding-inline: 18px; }
  .difficulty-card { padding: 10px 8px; }
  .difficulty-card strong { font-size: 1.8rem; }
  .difficulty-card > span:not(.difficulty-name) { font-size: .68rem; }
}

@media (max-height: 820px) {
  .start-screen { padding-top: 18px; padding-bottom: 18px; }
  .start-screen h1 { font-size: clamp(2.15rem, 8.5vw, 3rem); }
  .start-screen .lead { margin-bottom: 12px; }
  .start-screen .difficulty-grid { margin-bottom: 14px; }
  .start-screen .difficulty-card { min-height: 92px; }
  .start-screen .ritual-note { margin-top: 12px; }
}

@media (max-width: 520px) {
  .hold-row { grid-template-columns: minmax(0, 1fr) auto; }
  .hold-copy { grid-column: 1 / -1; }
  .hold-slots { min-width: 0; }
}

@media (min-width: 720px) {
  body { padding-top: 22px; }
  .app-shell { min-height: calc(100vh - 66px); border: 1px solid rgba(229,201,135,.25); }
}

/* Keep the active puzzle inside the browser's usable viewport and device safe areas. */
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
body.playing .app-shell { height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 0; display: flex; flex-direction: column; }
body.playing .masthead { height: 48px; flex: 0 0 48px; }
body.playing > footer { display: none; }
body.playing .game-screen.active { flex: 1; min-height: 0; padding: 8px 12px 12px; gap: 10px; overflow-y: auto; animation: none; }
body.playing .game-status { flex-shrink: 0; position: static; margin: 0; padding: 0; grid-template-columns: 96px minmax(0, 1fr) 100px; }
body.playing .board-wrap { flex: 1 0 180px; min-height: 180px; width: 100%; display: flex; align-items: flex-start; justify-content: center; }
body.playing .puzzle-board { width: var(--board-width, 120px); flex-shrink: 0; }
body.playing .piece-dock, body.playing .hold-row { flex-shrink: 0; margin: 0; }
body.playing .dock-heading { flex-wrap: wrap; gap: 3px 8px; margin-bottom: 7px; }
body.playing .dock-heading span, body.playing .hold-label { font-size: .875rem; letter-spacing: .04em; }
body.playing .dock-heading small, body.playing .hold-copy small { font-size: .875rem; }
body.playing .piece-tray { min-height: 0; width: min(100%, 440px); margin-inline: auto; gap: 8px; }
body.playing .hold-row { grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
body.playing .hold-copy { grid-column: 1 / -1; }
body.playing .hold-slots { grid-template-columns: repeat(var(--hold-count), minmax(0, 1fr)); width: min(100%, calc(var(--hold-count) * 55px)); gap: 5px; }
body.playing .hold-slots button { min-height: 44px; }
body.playing .hold-row .secondary-button { font-size: .875rem; }
body.playing .status-label { font-size: .75rem; letter-spacing: .04em; }
/* Testing controls stay outside the timed workspace. */
.puzzle-picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.puzzle-picker select { min-height: 44px; font: inherit; padding: 8px 14px; border: 1px solid #9e927e; background: var(--white); color: var(--ink); }
.primary-button:disabled { opacity: .5; cursor: wait; }
.metrics-table { overflow-x: auto; margin-bottom: 20px; }
.metrics-table table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.metrics-table th, .metrics-table td { padding: 9px 6px; border-bottom: 1px solid #ccc2b2; text-align: left; }
.metrics-table th { color: #716a60; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; }
.metrics-table td { white-space: nowrap; }
.metrics-table caption { padding: 10px 0; text-align: left; font-family: Georgia, serif; font-size: 1.1rem; font-weight: 700; }
.history-table td:not(:first-child) { font-size: .78rem; }
.metrics-screen > .primary-button { width: 100%; margin-top: 8px; }
.ritual-note { flex-wrap: wrap; gap: 6px; }
.ritual-note span + span::before { content: none; }
body.playing { position: fixed; top: 0; left: 0; width: 100%; height: var(--viewport-height, 100svh); min-height: 0; overflow: hidden; }
body.playing .app-shell { height: 100%; min-height: 0; }
body.playing .masthead { height: 40px; flex-basis: 40px; padding-inline: 12px; }
body.playing .icon-button { width: 34px; height: 34px; }
body.playing .game-screen.active { padding: 6px 10px 8px; gap: 8px; }
body.playing .board-wrap { flex-basis: 120px; min-height: 120px; }
body.playing .puzzle-board { aspect-ratio: var(--art-aspect, .673333); border-width: 4px; }
body.playing .hold-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
body.playing .hold-copy small { font-size: .75rem; }
body.playing .hold-row { gap: 4px; }
body.playing .hold-slots { width: min(100%, calc(var(--hold-count) * 48px)); }
body.playing .hold-slots button { min-height: 0; aspect-ratio: var(--piece-aspect); }
body.playing .piece-tray { width: min(100%, 440px); }
body.playing .dock-heading small { font-size: .75rem; }

/* Compact the gallery within embedded iPhone browsers while retaining readable controls. */
@media (max-width: 520px) and (max-height: 930px) {
  .masthead { height: 58px; padding-inline: 16px; }
  .screen { min-height: calc(100dvh - 102px); }
  .start-screen { padding: 15px 18px 16px; }
  .start-screen h1 { margin: 7px 0; font-size: clamp(2.05rem, 8.2vw, 2.8rem); line-height: .98; }
  .start-screen .lead { margin-bottom: 10px; font-size: .92rem; line-height: 1.35; }
  .difficulty-grid { gap: 7px; margin: 0 0 11px; }
  .difficulty-card { min-height: 86px; padding: 9px 8px; }
  .difficulty-card strong { font-size: 1.72rem; }
  .difficulty-card > span:not(.difficulty-name) { font-size: .66rem; }
  .primary-button, .secondary-button { min-height: 48px; }
  .ritual-note { margin-top: 9px; }
}

@media (max-width: 370px) {
  .metrics-cards { grid-template-columns: repeat(2, 1fr); }
  .feedback-options { grid-template-columns: 1fr; }
  .feedback-heading { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.tray-piece.empty { visibility: hidden; pointer-events: none; }
