:root {
	color-scheme: light;
	--ink: #22352d;
	--muted: #78857c;
	--paper: #fbf8f0;
	--green: #38845f;
	--green-dark: #286a49;
	--green-pale: #e8f3e9;
	--yellow: #f5c84c;
	--coral: #e97661;
	--line: #e8e5d9;
	--shadow: 0 9px 24px rgb(49 63 45 / 8%);
}

* { box-sizing: border-box; }

body {
	min-width: 320px;
	min-height: 100vh;
	margin: 0;
	color: var(--ink);
	background-color: var(--paper);
	background-image: radial-gradient(#d7d5c5 0.7px, transparent 0.7px);
	background-size: 19px 19px;
	font-family: "Nunito", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid #5b9c78; outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 20px 0 18px; }
.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-family: "Baloo 2", sans-serif; font-size: 23px; font-weight: 800; line-height: .78; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: #fff; background: var(--green); border-radius: 13px 13px 13px 4px; font-size: 23px; transform: rotate(-4deg); }
.brand-pop { color: var(--green); }
.brand small { display: block; margin-top: 6px; color: #98a096; font: 800 8px/1 "Nunito", sans-serif; letter-spacing: 1.3px; }
.top-actions, .game-controls { display: flex; align-items: center; gap: 11px; }
.button, .icon-button { border: 0; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease; }
.button:hover, .icon-button:hover { transform: translateY(-2px); }
.button { min-height: 42px; padding: 0 17px; border-radius: 12px; font-weight: 900; }
.button-outline { color: var(--green-dark); background: #fff; border: 1px solid #dce6db; box-shadow: 0 3px 0 #e3e8dc; }
.button-outline:hover { background: #f5fbf4; }
.button-play { color: #fff; background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }
.button-play:hover { background: #44946b; box-shadow: 0 5px 0 var(--green-dark); }
.button-play:active, .button-outline:active { transform: translateY(2px); box-shadow: none; }
.button span { margin-right: 5px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 3px 0 #e8e5d9; font-size: 21px; }

.welcome-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 29px 2px 17px; }
.eyebrow { margin: 0 0 5px; color: #738477; font-size: 10px; font-weight: 900; letter-spacing: 1.65px; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; background: #59b478; border-radius: 50%; box-shadow: 0 0 0 3px #e0f1e1; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 1px; font: 800 38px/1.08 "Baloo 2", sans-serif; letter-spacing: 0; }
h1 span { color: var(--coral); }
.subheading { margin: 5px 0 0; color: var(--muted); font-size: 14px; font-weight: 700; }
.mode-label { color: #768279; font-size: 12px; font-weight: 800; }
.mode-label span { margin-right: 4px; color: var(--green); font-size: 17px; vertical-align: -1px; }
.button-play#start-button { min-width: 133px; }

.score-strip { min-height: 72px; display: flex; align-items: center; gap: 27px; padding: 10px 16px; background: #fff; border: 1px solid #efede4; border-radius: 14px; box-shadow: var(--shadow); }
.stat { min-width: 97px; display: grid; grid-template-columns: 27px auto; grid-template-rows: 17px 22px; align-items: center; column-gap: 4px; }
.stat-icon { grid-row: 1 / 3; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; font-size: 15px; }
.star-icon { color: #a87708; background: #fff1c8; }
.clock-icon { color: #bc6554; background: #ffede8; font-size: 19px; }
.stat-label { color: #89948b; font-size: 9px; font-weight: 900; letter-spacing: 1px; }
.stat strong, .progress-copy strong { font-size: 17px; line-height: 1; font-weight: 900; }
.progress-stat { flex: 1; min-width: 95px; max-width: 310px; }
.progress-copy { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.progress-copy strong { font-size: 13px; }
.progress-track { overflow: hidden; height: 8px; background: #edf0e8; border-radius: 99px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--green); border-radius: inherit; transition: width .3s ease; }
.restart-button { margin-left: auto; color: var(--green-dark); font-size: 26px; }

.playfield { position: relative; display: grid; grid-template-columns: minmax(230px, .82fr) minmax(420px, 1.5fr); grid-template-rows: auto 1fr; column-gap: 34px; row-gap: 12px; min-height: 378px; margin-top: 17px; padding: 20px 22px 22px; overflow: hidden; background: rgb(255 255 255 / 88%); border: 1px solid #efede4; border-radius: 16px; box-shadow: var(--shadow); }
.camera-stage { position: absolute; z-index: 0; inset: 0; overflow: hidden; background: #20322a; opacity: 0; pointer-events: none; transition: opacity .25s ease; }
.camera-stage.active { opacity: 1; }
.camera-stage video, .camera-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.camera-stage video {
    object-fit: fill;
    opacity: .3;
    transform: scaleX(-1);
}

.camera-stage canvas {
    pointer-events: none;
}
.playfield > :not(.camera-stage) { position: relative; z-index: 1; }
.playfield > .hand-cursor, .playfield > .held-item, .playfield > .toast, .playfield > .completion-banner { position: absolute; }
.column-heading { display: flex; align-items: center; gap: 8px; min-height: 25px; }
.column-heading:first-child { grid-column: 1; grid-row: 1; }
.column-heading h2 { margin: 0; font: 800 18px/1.1 "Baloo 2", sans-serif; }
.heading-spark { color: var(--yellow); font-size: 20px; }
.targets-heading { justify-content: space-between; }
.targets-heading { grid-column: 2; grid-row: 1; }
.target-hint { color: #a0a89e; font-size: 9px; font-weight: 900; letter-spacing: 1.4px; }
.fruit-grid { align-content: start; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.fruit-grid { grid-column: 1; grid-row: 2; }
.fruit-card { position: relative; min-width: 0; height: 91px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px; color: var(--ink); background: #fffdf8; border: 1.5px solid #efeadc; border-radius: 13px; box-shadow: 0 3px 0 #eee9dc; cursor: grab; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.fruit-card:hover { transform: translateY(-3px) rotate(-1deg); border-color: #b7d4bb; box-shadow: 0 6px 0 #e3edde; }
.fruit-card:active { cursor: grabbing; }
.fruit-card.is-selected { border-color: var(--green); box-shadow: 0 0 0 3px #dceede; transform: translateY(-2px); }
.fruit-card.is-matched { opacity: .35; filter: grayscale(.75); pointer-events: none; }
.fruit-art { display: grid; place-items: center; width: 47px; height: 47px; font-size: 36px; line-height: 1; }
.fruit-art img, .editor-preview img { width: 100%; height: 100%; object-fit: contain; }
.fruit-name { overflow: hidden; max-width: 100%; color: #6e796f; font-size: 10px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.target-grid { align-content: start; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.target-grid { grid-column: 2; grid-row: 2; }
.target-box { position: relative; min-width: 0; min-height: 91px; display: grid; place-items: center; padding: 9px; color: #4d5c50; background: #f7faf4; border: 1.5px dashed #cbd9c7; border-radius: 13px; cursor: pointer; transition: background .18s ease, transform .18s ease, border-color .18s ease; }
.target-box:hover, .target-box.is-hovered { background: #eef7e9; border-color: var(--green); transform: scale(1.025); }
.target-box span { max-width: 100%; font-size: 14px; font-weight: 900; overflow-wrap: anywhere; text-align: center; }
.target-box.is-matched { color: #31734d; background: #edf7eb; border-style: solid; border-color: #bdd9bd; }
.target-box.is-matched::after { position: absolute; top: 5px; right: 7px; color: var(--green); content: "✓"; font-weight: 900; }
.target-box.wrong { animation: wrong-shake .35s ease; border-color: var(--coral); background: #fff0ec; }
.target-box.correct-pop { animation: correct-pop .45s ease; }

.hand-cursor { position: absolute; z-index: 5; left: 0; top: 0; display: none; place-items: center; width: 29px; height: 29px; border: 3px solid #fff; border-radius: 50%; background: var(--coral); box-shadow: 0 2px 12px rgb(34 53 45 / 35%); pointer-events: none; transform: translate(-50%, -50%); }
.hand-cursor span { width: 7px; height: 7px; background: white; border-radius: 50%; }
.hand-cursor.visible { display: grid; }
.hand-cursor.pinch { background: var(--green); transform: translate(-50%, -50%) scale(.82); }
.held-item { position: absolute; z-index: 6; display: none; width: 62px; height: 62px; place-items: center; background: #fff; border: 2px solid var(--green); border-radius: 18px; box-shadow: 0 5px 18px rgb(34 53 45 / 22%); pointer-events: none; transform: translate(-50%, -50%) rotate(-8deg); font-size: 42px; }
.held-item.visible { display: grid; }
.held-item img { width: 80%; height: 80%; object-fit: contain; }
.toast { position: absolute; z-index: 7; left: 50%; bottom: 14px; padding: 8px 15px; color: #fff; background: #263e31; border-radius: 999px; font-size: 12px; font-weight: 900; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .18s ease, transform .18s ease; white-space: nowrap; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b64d41; }
.completion-banner { position: absolute; z-index: 9; inset: 0; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 22px; background: rgb(250 255 245 / 95%); animation: reveal .35s ease both; }
.completion-spark { color: var(--yellow); font-size: 48px; }
.completion-banner div { display: grid; gap: 3px; }
.completion-banner strong { font: 800 26px/1 "Baloo 2", sans-serif; }
.completion-banner div span { color: var(--muted); font-size: 13px; font-weight: 800; }

.bottom-row { min-height: 53px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.instruction { display: flex; align-items: center; gap: 9px; color: #738077; font-size: 12px; font-weight: 700; }
.instruction-icon { display: grid; place-items: center; width: 30px; height: 30px; color: var(--green); background: #e7f2e5; border-radius: 10px; font-size: 17px; }
.classroom-note { color: #a4aaa0; font-size: 9px; font-weight: 900; letter-spacing: 1.3px; white-space: nowrap; }
.classroom-note span { color: var(--yellow); font-size: 13px; }
.camera-panel { display: flex; align-items: center; gap: 9px; color: #617366; font-size: 10px; font-weight: 900; }
.camera-feed { position: relative; width: 50px; height: 36px; overflow: hidden; background: #1d2b22; border: 2px solid #fff; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.camera-feed video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-feed-dot { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; background: #eb6e5c; border-radius: 50%; box-shadow: 0 0 0 2px rgb(255 255 255 / 55%); }
.camera-close { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #f2eee5; cursor: pointer; font-size: 16px; line-height: 1; }

.settings-dialog { width: min(590px, calc(100% - 28px)); max-height: min(86vh, 820px); padding: 0; overflow: hidden; color: var(--ink); background: var(--paper); border: 1px solid #e5e2d6; border-radius: 18px; box-shadow: 0 24px 90px rgb(35 48 38 / 25%); }
.settings-dialog::backdrop { background: rgb(25 38 30 / 48%); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; padding: 23px 25px 17px; border-bottom: 1px solid var(--line); }
.dialog-head .eyebrow { margin-bottom: 2px; }
.dialog-head h2 { margin: 0; font: 800 27px/1.1 "Baloo 2", sans-serif; }
.dialog-close { width: 34px; height: 34px; font-size: 22px; }
.settings-body { max-height: calc(86vh - 105px); padding: 16px 25px 22px; overflow: auto; }
.settings-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.settings-toolbar p { margin: 0; color: #78857c; font-size: 12px; font-weight: 700; }
.button-small { min-height: 34px; padding: 0 11px; border-radius: 9px; font-size: 11px; white-space: nowrap; }
.item-editor { display: grid; gap: 8px; }
.editor-row { display: grid; grid-template-columns: 48px minmax(90px, 1fr) minmax(100px, 1.25fr) 33px; gap: 8px; align-items: center; padding: 8px; background: #fff; border: 1px solid #edeadd; border-radius: 11px; }
.editor-preview { display: grid; place-items: center; width: 43px; height: 43px; overflow: hidden; background: #f5f7ef; border-radius: 9px; font-size: 27px; }
.editor-row input { width: 100%; min-width: 0; height: 36px; padding: 0 9px; color: var(--ink); background: #fff; border: 1px solid #e5e8dd; border-radius: 8px; font-size: 12px; font-weight: 800; }
.editor-row input::placeholder { color: #a4aca4; font-weight: 600; }
.editor-art-field { position: relative; display: flex; min-width: 0; gap: 4px; }
.editor-art-field input { flex: 1; }
.sticker-picker-button { flex: 0 0 36px; height: 36px; color: var(--green-dark); background: #edf6eb; border: 1px solid #d7e6d4; border-radius: 8px; cursor: pointer; font-size: 19px; font-weight: 900; }
.sticker-picker-button[aria-expanded="true"] { color: #fff; background: var(--green); }
.sticker-tray { position: absolute; z-index: 4; top: calc(100% + 5px); right: 0; display: grid; grid-template-columns: repeat(6, 36px); gap: 4px; width: max-content; max-width: min(260px, calc(100vw - 70px)); padding: 7px; background: #fff; border: 1px solid #e4e7db; border-radius: 10px; box-shadow: 0 8px 22px rgb(34 53 45 / 18%); }
.sticker-tray[hidden] { display: none; }
.sticker-choice { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; background: #f7f9f3; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-size: 22px; }
.sticker-choice:hover { background: #edf6eb; border-color: #cfe2ce; transform: scale(1.05); }
.delete-item { display: grid; place-items: center; width: 31px; height: 31px; color: #b05d50; background: #fff1ed; border: 0; border-radius: 8px; cursor: pointer; font-size: 16px; }
.settings-options { margin-top: 17px; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.field-label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 900; }
.option-line { display: flex; align-items: center; gap: 9px; color: #879187; font-size: 11px; font-weight: 700; }
.option-line input { width: 63px; height: 34px; padding: 0 9px; border: 1px solid #dfe4d9; border-radius: 8px; }
.check-row { position: relative; display: flex; align-items: center; gap: 9px; width: fit-content; margin-top: 13px; color: #5e6e62; font-size: 11px; font-weight: 800; cursor: pointer; }
.check-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.custom-check { width: 17px; height: 17px; display: grid; place-items: center; background: #fff; border: 1.5px solid #cbd5c8; border-radius: 5px; }
.check-row input:checked + .custom-check { color: white; background: var(--green); border-color: var(--green); }
.check-row input:checked + .custom-check::after { content: "✓"; font-size: 12px; font-weight: 900; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.saved-note { color: #879187; font-size: 10px; font-weight: 700; }
.settings-footer .button { min-height: 38px; }

@keyframes correct-pop { 50% { transform: scale(1.08) rotate(2deg); } }
@keyframes wrong-shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes reveal { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }

@media (min-width: 1400px) {
	.app-shell { padding-top: 27px; }
	.playfield { min-height: 440px; }
	.fruit-card, .target-box { height: 105px; }
	.fruit-grid, .target-grid { gap: 15px; }
}

@media (max-width: 760px) {
	.app-shell { width: min(100% - 26px, 560px); padding-top: 13px; }
	.welcome-row { align-items: start; flex-direction: column; padding-top: 22px; }
	h1 { font-size: 34px; }
	.game-controls { width: 100%; justify-content: space-between; }
	.score-strip { gap: 11px; padding: 9px 10px; }
	.stat { min-width: 76px; grid-template-columns: 24px auto; }
	.stat-icon { width: 23px; height: 23px; }
	.restart-button { width: 36px; height: 36px; }
	.playfield { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; gap: 10px; min-height: 0; padding: 16px 14px; }
	.column-heading:first-child { grid-column: 1; grid-row: 1; }
	.fruit-grid { grid-column: 1; grid-row: 2; }
	.targets-heading { grid-column: 1; grid-row: 3; }
	.target-grid { grid-column: 1; grid-row: 4; }
	.fruit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
	.fruit-card { height: 80px; border-radius: 11px; }
	.fruit-art { width: 42px; height: 42px; font-size: 32px; }
	.target-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.target-box { min-height: 58px; }
	.target-box span { font-size: 12px; }
	.targets-heading { margin-top: 6px; }
	.bottom-row { min-height: 54px; }
	.instruction { font-size: 10px; }
	.classroom-note { display: none; }
	.completion-banner { flex-wrap: wrap; gap: 9px; align-content: center; text-align: center; }
	.completion-banner strong { font-size: 23px; }
	.completion-spark { font-size: 36px; }
}

@media (max-width: 430px) {
	.top-actions { gap: 7px; }
	.top-actions .button { min-height: 38px; padding: 0 10px; font-size: 11px; }
	.top-actions .icon-button { width: 38px; height: 38px; }
	.brand { font-size: 20px; }
    /* FULL-SCREEN HAND SKELETON */
#hand-skeleton {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 30 !important;
}

/* Make the hand skeleton visible above the game */
.camera-stage.active + * {
    position: relative;
}

/* Hand cursor above everything */
.hand-cursor {
    z-index: 50 !important;
}

.held-item {
    z-index: 51 !important;
}
	.brand-mark { width: 34px; height: 34px; }
	.score-strip { gap: 7px; }
	.stat { min-width: 69px; }
	.stat-label { font-size: 8px; }
	.stat strong { font-size: 15px; }
	.progress-copy strong { font-size: 11px; }
	.editor-row { grid-template-columns: 39px minmax(0, 1fr) 30px; gap: 5px; padding: 6px; }
	.editor-preview { width: 37px; height: 37px; font-size: 23px; }
	.editor-row > input { grid-column: 2; padding: 0 6px; font-size: 10px; }
	.editor-art-field { grid-column: 1 / -1; }
	.editor-art-field input { padding: 0 7px; font-size: 10px; }
	.delete-item { width: 29px; height: 29px; }
/* 🖼️ Choose picture button */

.upload-picture-button {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;

    display: grid;
    place-items: center;

    padding: 0;

    color: var(--green-dark);
    background: #edf6eb;

    border: 1px solid #d7e6d4;
    border-radius: 8px;

    cursor: pointer;

    font-size: 17px;
    font-weight: 900;
}

.upload-picture-button:hover {
    background: #dff0dc;
    transform: scale(1.04);
}


/* Hide the real computer file input */

.picture-file-input {
    position: absolute;

    width: 1px;
    height: 1px;

    left: -9999px;
    top: -9999px;

    opacity: 0;

    pointer-events: none;
}	.dialog-head, .settings-body { padding-right: 16px; padding-left: 16px; }
}
