/* Love Stitch: a tiny embroidery studio. */
:root {
    --base: #fbf0f3;
    --card: #fff9fb;
    --ink: #4e2c3f;
    --muted: #937384;
    --line: #ecd1dd;
    --violet: #a65c96;
    --pink: #e06f99;
    --mend: #d44b79;
    --red-color: #dc3849;
    --body-font: 'Avenir Next', Avenir, 'Trebuchet MS', sans-serif;
    --serif-font: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100svh;
    color: var(--ink);
    background-color: var(--base);
    background-image: repeating-linear-gradient(0deg, transparent 0 3px, #ad557c04 3px 4px), repeating-linear-gradient(90deg, transparent 0 3px, #ad557c04 3px 4px);
    font-family: var(--body-font);
    -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button, a { touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--violet); outline-offset: 5px; }
button { cursor: pointer; }
a { color: inherit; }
.studio-header { height: 82px; max-width: 1360px; margin: auto; padding: 0 44px; display: flex; align-items: center; }
.studio-brand { display: block; line-height: 0; text-decoration: none; }
.studio-brand img { width: 26px; height: 26px; }
.studio-layout { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(340px, 460px) minmax(190px, 1fr); gap: 54px; width: min(1130px, calc(100% - 88px)); margin: 24px auto 0; align-items: start; }
.story { padding-top: 42px; }
.eyebrow { text-transform: uppercase; font-size: 9px; letter-spacing: 1.7px; font-weight: 600; line-height: 1.6; margin: 0; }
.story > .eyebrow { letter-spacing: 1.25px; font-size: 8px; white-space: nowrap; }
.tiny-stitch { color: var(--mend); font-size: 17px; vertical-align: -2px; margin-right: 5px; }
h1 { font-family: var(--serif-font); font-weight: 400; font-size: clamp(68px, 6.2vw, 88px); line-height: .91; letter-spacing: -5px; margin: 26px 0 22px; }
h1 em { font-weight: 400; color: #ae527f; }
.title-dot { color: #e581a9; }
.story-thread { display: block; width: 206px; height: 60px; color: #d59ab9; margin: 12px 0 17px -8px; }
.story-footnote { font-family: var(--serif-font); font-style: italic; color: #ac8196; margin: 18px 0 0; font-size: 14px; }
.game-wrapper { min-width: 0; }
.board-topline { height: 40px; display: flex; align-items: flex-start; justify-content: space-between; padding: 0 9px; }
.round-label { font-size: 9px; letter-spacing: 1.6px; padding-top: 4px; }
.round-label strong { font-weight: 600; padding-left: 5px; }
.round-total { color: #b18b9e; }
.timer { font-family: var(--serif-font); font-size: 23px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 65px; text-align: right; }
.round-marks { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.round-marks i { width: 16px; height: 3px; background: #ead0dc; border-radius: 2px; }
.round-marks i.active { background: var(--violet); }
.round-marks i.complete { background: var(--pink); }
.fabric-frame { position: relative; padding: 13px; background: #f2dce5; border: 1px solid #e3bbce; border-radius: 9px; box-shadow: 0 3px 4px #80304f0a, 0 17px 28px -18px #95476640, inset 0 1px 0 #ffffffe0; }
.fabric-frame::before { content: ''; position: absolute; inset: 6px; border: 1px dashed #c99db4; border-radius: 5px; pointer-events: none; }
.game-container { width: 100%; height: clamp(310px, calc(100svh - 400px), 530px); overflow: hidden; background: var(--card); border: 1px solid #e8c8d6; border-radius: 3px; box-shadow: inset 0 1px 6px #a34d7919; }
#gameCanvas { display: block; width: 100%; height: 100%; }
.fabric-tab { position: absolute; right: -23px; top: 72%; width: 36px; height: 72px; background: #efcfdf; color: #925675; border: 1px solid #d9a9c0; border-left: 0; border-radius: 0 3px 3px 0; writing-mode: vertical-rl; font-family: var(--serif-font); font-style: italic; font-size: 12px; padding: 9px 7px; z-index: -1; transform: rotate(2deg); }
.fabric-corner { position: absolute; bottom: -10px; left: 24px; background: var(--base); color: #b77796; font-size: 22px; padding: 0 5px; }
.controls-outer { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 15px 7px 0; }
.thread-control { flex: 1; }
.control-buttons { display: flex; gap: 8px; }
.thread-button { position: relative; flex: 1; height: 56px; border-radius: 7px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 1px solid; box-shadow: 0 3px 0 #d3acc7; transition: transform 100ms, box-shadow 100ms, background 100ms; user-select: none; -webkit-user-select: none; touch-action: none; }
.thread-button::after { content: ''; position: absolute; inset: 4px; border: 1px dashed currentColor; opacity: .23; border-radius: 4px; pointer-events: none; }
.thread-button > span { font-size: 27px; line-height: 1; font-family: Georgia, serif; }
.thread-button kbd { font: 10px var(--body-font); opacity: .7; }
.purple-btn { color: #874577; background: #f0ddec; border-color: #dab4cf; }
.yellow-btn { color: #b34c76; background: #f9dfe9; border-color: #eeb7cc; box-shadow: 0 3px 0 #e6aac2; }
.thread-button:hover { filter: brightness(1.025); }
.thread-button:active, .thread-button.pressed { transform: translateY(3px); box-shadow: 0 0 0 transparent; filter: brightness(.97); }
.control-divider { color: #c49aae; font-size: 22px; transform: rotate(-25deg); }
.control-note { font-family: var(--serif-font); font-style: italic; font-size: 13px; text-align: center; color: #ac7d94; margin: 17px 0 0; }
.mobile-instructions { display: none; }
.sewing-notes { padding-top: 87px; }
.pattern-card { position: relative; border: 1px solid #e9c5d4; background: #fff5f8; padding: 37px 21px 0; transform: rotate(2deg); box-shadow: 2px 6px 14px #994a730c; }
.pattern-card::before { content: ''; width: 44px; height: 43px; border-left: 1px solid #c591ac; border-radius: 50%; position: absolute; top: -26px; left: calc(50% - 5px); transform: rotate(12deg); }
.card-hole { position: absolute; top: 13px; left: calc(50% - 3px); width: 7px; height: 7px; border: 1px solid #d6adc0; border-radius: 50%; background: var(--base); }
.pattern-card > .eyebrow { font-size: 8px; color: #a76d89; letter-spacing: 1.7px; }
.pattern-card h2 { font: italic 26px/1.15 var(--serif-font); letter-spacing: -.7px; margin: 13px 0 27px; }
.progress-row { display: flex; justify-content: space-between; gap: 4px; font-size: 9px; color: #976b80; }
.progress-row strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.stitch-progress { display: flex; gap: 5px; margin: 10px 0; }
.stitch-progress span { height: 5px; flex: 1; border-radius: 1px; background: #efd8e2; }
.stitch-progress span[data-side="left"] { background: var(--violet); }
.stitch-progress span[data-side="right"] { background: var(--pink); }
.round-caption { font-family: var(--serif-font); font-size: 11px; font-style: italic; color: #b17b92; margin: 0 0 24px; }
.sewing-stats { margin: 0; padding: 17px 0; border-top: 1px dashed #e5bbcd; }
.sewing-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.sewing-stats > div:last-child { margin: 0; }
.sewing-stats dt { font-size: 10px; color: #9a6e83; }
.sewing-stats dd { font-family: var(--serif-font); font-size: 18px; margin: 0; font-variant-numeric: tabular-nums; }
.thread-spools { height: 116px; position: relative; margin: 16px 0 0; width: 164px; }
.spool { position: absolute; width: 44px; height: 75px; border-radius: 5px; background: #d7ba86; box-shadow: inset 0 0 0 1px #aa8c5540, 3px 7px 8px #7052321a; }
.spool::before, .spool::after { content: ''; position: absolute; height: 8px; left: -3px; right: -3px; background: #e0c898; border: 1px solid #c5aa75; border-radius: 3px; z-index: 1; }
.spool::before { top: 0; }
.spool::after { bottom: 0; }
.spool i { position: absolute; inset: 8px -1px; background: repeating-linear-gradient(0deg, #ffffff25 0 1px, #0000000a 1px 2px, transparent 2px 3px), #b376a7; border-radius: 8px; box-shadow: inset 6px 0 8px #ffffff30, inset -7px 0 8px #3b214020; }
.spool span { position: absolute; z-index: 2; font: 9px var(--serif-font); top: 32px; left: 12px; color: #726348; background: #eee4cd; padding: 3px 4px; }
.spool-violet { left: 25px; top: 5px; transform: rotate(-18deg); }
.spool-rose { left: 92px; top: 16px; transform: rotate(21deg); }
.spool-rose i { background-color: #e595b4; }
.loose-thread { position: absolute; border: 1px solid #bd82a6; border-left-color: transparent; border-radius: 50%; width: 109px; height: 34px; top: 76px; left: 8px; transform: rotate(12deg); }
.desk-note { font: 18px/1.45 var(--serif-font); color: #b07792; text-align: left; transform: rotate(-5deg); transform-origin: left center; margin: 8px 0 0; }
.modal { position: fixed; inset: 0; z-index: 1000; padding: 20px; align-items: center; justify-content: center; background: #f7e6eecc; backdrop-filter: blur(9px); overflow-y: auto; }
.modal-content { position: relative; margin: auto; max-height: calc(100svh - 40px); overflow-y: auto; width: min(100%, 400px); padding: 32px; text-align: center; border: 1px solid #e2b9cc; background: var(--card); box-shadow: 0 24px 90px #82335422; }
.modal-content::before { content: ''; position: absolute; inset: 8px; border: 1px dashed #e7bed0; pointer-events: none; }
.result-heart { display: block; font: 61px/1 var(--serif-font); color: var(--mend); text-shadow: 0 3px 0 #a4436c30; margin-bottom: 14px; }
.modal-content h2 { font: italic 49px/1 var(--serif-font); letter-spacing: -2px; margin: 13px 0 10px; }
.result-copy { font: 15px var(--serif-font); color: var(--muted); margin: 0 0 20px; }
.new-best { font-size: 10px; padding: 6px 12px; color: #a44b71; background: #f8dce9; display: inline-block; margin: 0 0 16px; }
.new-best[hidden] { display: none; }
.score-display { padding: 16px 0; border-block: 1px solid var(--line); }
.final-score { display: block; font: 51px/1.2 var(--serif-font); font-variant-numeric: tabular-nums; }
.score-display p { font-size: 11px; margin: 7px 0 0; color: var(--muted); }
.score-display p span { color: var(--ink); margin-left: 10px; }
.stat-row { display: flex; justify-content: center; gap: 55px; margin: 18px 0; }
.stat-row span { display: block; font-size: 10px; color: var(--muted); }
.stat-row strong { display: block; margin-top: 4px; font: 23px var(--serif-font); }
.restart-btn { position: relative; width: 100%; padding: 16px; background: #b25484; border: 1px solid #a14473; color: #fff8fb; font-size: 12px; border-radius: 3px; }
.restart-btn:hover { background: #9d416f; }
.restart-btn span { margin-left: 15px; }
.result-home { display: inline-block; margin-top: 17px; color: var(--muted); font-size: 10px; text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.dev-panel { position: fixed; right: 15px; bottom: 15px; z-index: 20; display: grid; gap: 8px; padding: 16px; background: var(--card); border: 1px solid var(--line); font-size: 11px; }
.dev-color { display: flex; align-items: center; gap: 10px; }
.dev-color input { width: 26px; height: 22px; }
.dev-actions { display: flex; gap: 6px; }
@media (max-width: 1250px) {
    .studio-layout { gap: 34px; grid-template-columns: minmax(175px, 1fr) minmax(320px, 440px) minmax(175px, 1fr); }
    .pattern-card { padding-inline: 16px; }
    .story > .eyebrow { font-size: 7px; letter-spacing: .8px; }
}
@media (max-width: 1000px) and (min-width: 761px) {
    .studio-layout { grid-template-columns: 210px minmax(320px, 440px); width: min(760px, calc(100% - 64px)); gap: 40px; }
    .sewing-notes { display: none; }
    .story { padding-top: 90px; }
    h1 { font-size: 86px; }
}
@media (max-width: 760px) {
    .studio-header { height: 54px; padding: 0 21px; }
    .studio-brand img { height: 23px; width: 23px; }
    .studio-layout { display: flex; flex-direction: column; gap: 0; margin: 9px auto 0; width: min(460px, calc(100% - 36px)); }
    .story { padding: 0 3px; width: 100%; display: flex; align-items: center; justify-content: space-between; margin: 0 0 19px; }
    .story > .eyebrow, .story-thread, .story .thread-spools, .desk-note, .story-footnote { display: none; }
    h1 { font-size: 39px; letter-spacing: -2px; line-height: 1; margin: 0; }
    h1 br { display: none; }
    h1 em { margin-left: 6px; }
    .game-wrapper { width: 100%; }
    .board-topline { height: 32px; padding-inline: 4px; }
    .round-label { font-size: 8px; letter-spacing: 1.1px; }
    .timer { font-size: 21px; }
    .game-container { height: clamp(265px, 54svh, 530px); }
    .fabric-frame { padding: 10px; }
    .fabric-frame::before { inset: 4px; }
    .fabric-tab { right: -15px; width: 24px; padding: 9px 3px; }
    .controls-outer { margin: 12px 2px 0; gap: 12px; }
    .thread-button { height: 53px; gap: 10px; }
    .control-divider { font-size: 18px; }
    .control-note { margin-top: 15px; font-size: 12px; }
    .mobile-instructions { display: block; font-size: 9px; color: #9d7185; text-align: center; margin: 8px 0 0; }
    .sewing-notes { display: none; }
}
@media (max-width: 760px) and (max-height: 700px) {
    .studio-header { height: 44px; }
    .studio-layout { margin-top: 3px; }
    .story { margin-bottom: 12px; }
    h1 { font-size: 33px; }
    .game-container { height: 48svh; min-height: 245px; }
    .thread-button { height: 46px; }
    .controls-outer { margin-top: 12px; }
    .control-note { margin-top: 12px; }
}
@media (pointer: coarse) { .thread-button kbd { display: none; } }
@media (max-height: 500px) and (min-width: 600px) {
    .studio-header { height: 44px; }
    .studio-layout { display: grid; grid-template-columns: 170px minmax(280px, 430px); gap: 28px; width: min(710px, calc(100% - 48px)); margin-top: 8px; }
    .story { display: block; padding-top: 25px; }
    h1 { font-size: 55px; }
    h1 br { display: block; }
    h1 em { margin: 0; }
    .story > .eyebrow, .story-thread, .story .thread-spools, .desk-note, .story-footnote, .sewing-notes, .control-note, .mobile-instructions { display: none; }
    .game-container { height: max(160px, calc(100svh - 205px)); min-height: 160px; }
    .board-topline { height: 27px; }
    .controls-outer { margin-top: 12px; }
    .thread-button { height: 42px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

@media (min-width: 1001px) and (max-height: 820px) {
    .story { padding-top: 28px; }
    h1 { font-size: 76px; margin-top: 18px; margin-bottom: 17px; }
    .story-thread { height: 44px; margin-block: 6px 10px; }
    .sewing-notes { padding-top: 60px; }
    .thread-spools { margin-top: 16px; height: 105px; }
}

.mobile-stitches { display: none; }
@media (max-width: 1000px) {
    .mobile-stitches { display: block; font-size: 9px; color: #a07186; padding-top: 5px; }
    .round-marks { display: none; }
}
@media (max-width: 480px) { .thread-button kbd { display: none; } }

@media (max-width: 480px) {
    .modal-content { padding: 23px 22px; }
    .modal-content h2 { font-size: 38px; letter-spacing: -1.5px; }
    .modal-content > .eyebrow { font-size: 8px; letter-spacing: 1.1px; }
    .result-heart { font-size: 44px; margin-bottom: 10px; }
    .result-copy { font-size: 13px; margin-bottom: 14px; }
    .new-best { margin-bottom: 10px; }
    .score-display { padding-block: 12px; }
    .final-score { font-size: 42px; }
    .stat-row { margin-block: 14px; }
    .result-home { margin-top: 14px; }
}
