:root { --paper: #213d33; --ink: #f7f0d9; --muted: #bacbb6; --line: #e5eace30; --sans: "Avenir Next", "Helvetica Neue", "PingFang SC", sans-serif; --serif: "Iowan Old Style", "Baskerville", "Songti SC", serif; }
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #172e26; color: var(--ink); font-family: var(--sans); }
button, select, a { color: inherit; font: inherit; }
button, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
[hidden] { display: none !important; }
.fruit-shell { position: relative; width: 100%; height: 100dvh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow: hidden; background: #213d33; }
.fruit-header { min-height: 76px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 10px 28px; border-bottom: 1px solid #d6e0bc17; background: #192f28; }
.back-link { display: inline-flex; align-items: center; justify-self: start; gap: 8px; padding: 10px 14px; min-height: 44px; border: 1px solid var(--line); border-radius: 999px; font-size: .75rem; text-decoration: none; }
.fruit-title { text-align: center; }
.fruit-title p { margin: 0 0 4px; font-size: .5rem; letter-spacing: .2em; color: #d8b86c; }
h1 { margin: 0; font: 400 1.6rem/1.1 var(--serif); letter-spacing: .07em; }
.fruit-header .play-controls { grid-column: 3; grid-row: 1; justify-self: end; margin: 0; gap: 7px; }
.fruit-header .play-controls button { min-width: 46px; min-height: 44px; padding: 5px 10px; color: var(--ink); background: #e3eace08; border-color: var(--line); border-radius: 12px; }
.fruit-header .play-controls button:hover { background: #e3eace18; }
.fruit-header .play-controls button[aria-pressed="true"] { border-color: #d8b86c60; }
.fruit-header .play-controls #soundToggle[aria-pressed="false"] { color: #b5c5ae; }
.fruit-hud { display: flex; justify-content: center; align-items: center; gap: clamp(40px, 10vw, 160px); min-height: 90px; padding: 12px 20px; background: #1c352c; }
.fruit-hud > div { display: grid; gap: 3px; min-width: 85px; text-align: center; }
.fruit-hud span { color: #b5c5ae; font-size: .6rem; letter-spacing: .1em; }
.fruit-hud strong { font: 600 2.1rem/1.15 var(--serif); font-variant-numeric: tabular-nums; }
.fruit-hud .score strong { color: #f4d88e; }
.fruit-hud .remaining strong { min-width: 100px; }
.fruit-hud .remaining small { margin-left: 5px; font: 500 .65rem var(--sans); color: #bacbb6; }
.fruit-hud .remaining.is-low strong { color: #ff9b77; }
.fruit-hud .remaining.is-lives strong { font-family: var(--sans); font-size: 1.1rem; letter-spacing: .12em; line-height: 2; color: #f2aa81; }
.fruit-stage { position: relative; overflow: hidden; min-height: 0; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; outline: none; }
canvas:focus-visible { box-shadow: inset 0 0 0 3px #d8b86c; }
.fruit-preview { width: 100%; height: 105px; margin: 14px 0 -8px; object-fit: contain; pointer-events: none; }
.fruit-footer { display: flex; justify-content: space-between; gap: 12px; padding: 9px 28px; color: #a1b39d; font-size: .62rem; background: #192f28; }
.combo-toast { position: absolute; pointer-events: none; left: 50%; top: 8%; width: max-content; max-width: 90%; padding: 9px 18px; border: 1px solid #f5df9f55; border-radius: 40px; background: #183c32d9; color: #ffe29a; font: 700 clamp(1rem, 2.5vw, 1.6rem)/1.3 var(--sans); text-align: center; box-shadow: 0 6px 24px #061e2850, inset 0 1px #fff4c91c; opacity: 0; transform: translate(-50%, 8px); }
.combo-toast.is-visible { animation: combo-rise .8s ease both; }
.special-panel { position: absolute; inset: 16px 12px auto; display: grid; justify-items: center; gap: 5px; pointer-events: none; text-align: center; text-shadow: 0 2px 8px #091e26; }
.special-panel strong { color: #ffbd9d; font: 600 clamp(1.2rem, 3vw, 1.8rem) var(--serif); }
.special-panel b { color: #ffecd1; font-size: clamp(1.1rem, 3vw, 1.5rem); font-variant-numeric: tabular-nums; }
.special-panel span { color: #edc9bb; font-size: .73rem; }
.power-status { position: absolute; inset: auto 12px 12px; width: fit-content; max-width: calc(100% - 24px); margin-inline: auto; padding: 8px 15px; border: 1px solid #c7e8cd60; border-radius: 20px; background: #123c35e8; color: #c9eff0; font-size: .76rem; text-align: center; pointer-events: none; }
.fruit-guide { margin-top: 10px; color: #b5c7ad; font-size: .68rem; line-height: 1.7; }
.fruit-guide summary { cursor: pointer; padding: 6px 0; color: #e3d299; }
.fruit-guide p { margin: 8px 0; }
.result-stats { flex-wrap: wrap; }
.round-summary { flex-basis: 100%; margin: 0; color: #b7c9ae; font-size: .7rem; line-height: 1.8; }
.fruit-overlay { position: absolute; inset: calc(76px + env(safe-area-inset-top)) 0 0; z-index: 10; display: grid; place-items: center; padding: 20px; overflow: auto; background: #102b2375; backdrop-filter: blur(5px); overscroll-behavior: contain; }
.fruit-overlay { align-items: safe center; }
.overlay-card { display: grid; grid-template-columns: 1fr 1.05fr; align-items: center; gap: clamp(28px, 5vw, 80px); width: min(100%, 860px); padding: clamp(26px, 5vw, 60px); border: 1px solid #e0e7ba25; border-radius: 24px; background: linear-gradient(130deg, #294737f2, #203b30f5); box-shadow: 0 30px 80px #08191250, inset 0 1px #fff1; }
.eyebrow { margin: 0 0 20px; font-size: .55rem; letter-spacing: .16em; color: #d5b86d; font-weight: 700; }
h2 { margin: 0; font: 400 clamp(2.6rem, 5.2vw, 4.5rem)/1.1 var(--serif); letter-spacing: -.04em; }
h2 em { font-style: normal; color: #ecc979; }
#overlayText { margin: 23px 0 0; font-size: .85rem; line-height: 1.8; color: #bfd0b6; }
.overlay-actions { display: grid; gap: 12px; min-width: 0; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mode-picker button { display: grid; gap: 7px; justify-items: start; min-width: 0; padding: 14px 12px; color: #c7d4bf; border: 1px solid #e1e7c834; border-radius: 13px; background: #172f2680; text-align: left; }
.mode-picker button > span { font-size: 1.5rem; line-height: 1; color: #e5c77e; }
.mode-picker b { font-size: .83rem; }
.mode-picker small { font-size: .6rem; line-height: 1.5; }
.mode-picker button[aria-pressed="true"] { color: #fff6de; border-color: #e8cc8a; background: #d0b36e20; box-shadow: inset 0 0 0 1px #e8cc8a55; }
.round-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: #bfd0b6; font-size: .76rem; }
.round-setting select { appearance: none; min-width: 0; min-height: 40px; padding: 8px 26px 8px 8px; border: 1px solid #e1e7c834; border-radius: 8px; background: #193329; background-image: linear-gradient(45deg, transparent 50%, #bfd0b6 50%), linear-gradient(135deg, #bfd0b6 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px; background-repeat: no-repeat; font-size: .75rem; }
.round-setting input { width: 120px; min-width: 0; min-height: 40px; padding: 8px; border: 1px solid #e1e7c834; border-radius: 8px; background: #193329; color: var(--ink); font: inherit; font-size: 16px; }
.round-setting input:focus-visible { outline: 2px solid #e8cc8a; outline-offset: 2px; }
.setting-hint { margin: 7px 0 0; color: #b5c7ad; font-size: .62rem; line-height: 1.6; }
.mode-rules { margin: 13px 0 0; min-height: 3.4em; color: #b5c7ad; font-size: .7rem; line-height: 1.7; }
.primary-action, .secondary-action { min-height: 48px; padding: 12px 18px; border: 0; border-radius: 12px; font-weight: 700; font-size: .85rem; }
.primary-action { display: flex; align-items: center; justify-content: space-between; color: #243629; background: #e7c778; box-shadow: 0 6px 16px #13251c55, inset 0 1px #fff6; }
.primary-action:hover { background: #f3d88f; }
.secondary-action { color: #e0e9ce; border: 1px solid var(--line); background: transparent; }
.control-note { margin: 0; color: #a4b69d; text-align: center; font-size: .6rem; line-height: 1.6; }
.asset-loading { color: #bfd0b6; text-align: center; font-size: .7rem; line-height: 1.6; }
.asset-loading p { margin: 0; }
#assetRecovery { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
#assetRecovery button { min-height: 40px; padding: 6px 10px; border: 1px solid #e1e7c834; border-radius: 8px; background: #193329; font-size: .7rem; }
.result-stats { display: flex; gap: 24px; margin-top: 26px; }
.result-stats > div { display: grid; gap: 7px; }
.result-stats strong { color: #f0d394; font: 600 2rem/1 var(--serif); }
.result-stats span { color: #b7c9ae; font-size: .62rem; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip-path: inset(50%); white-space: nowrap; border: 0; }
@keyframes combo-rise { 0% { opacity: 0; transform: translate(-50%, 8px) scale(.9); } 18%, 65% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -14px); } }
@media (max-width: 640px) {
  .fruit-header { min-height: 66px; padding: 8px 12px; gap: 8px; }
  .back-link { padding: 10px 12px; }
  .back-link span, .fruit-title p, .fruit-header .play-controls b { display: none; }
  .fruit-title h1 { font-size: 1.25rem; white-space: nowrap; }
  .fruit-header .play-controls { gap: 5px; }
  .fruit-header .play-controls button { padding: 0; min-width: 40px; }
  .fruit-hud { min-height: 72px; gap: 20px; padding: 9px 12px; }
  .fruit-hud > div { min-width: 64px; }
  .fruit-hud strong { font-size: 1.8rem; }
  .fruit-hud .remaining strong { min-width: 90px; }
  .fruit-hud span { font-size: .53rem; }
  .fruit-footer { padding: 8px 12px; font-size: .54rem; }
  .fruit-overlay { inset-block-start: calc(66px + env(safe-area-inset-top)); padding: 14px; }
  .overlay-card { grid-template-columns: 1fr; width: min(100%, 420px); gap: 22px; padding: 24px; border-radius: 18px; }
  .eyebrow { margin-bottom: 10px; font-size: .5rem; }
  h2 { font-size: 2.6rem; }
  #overlayText { margin-top: 12px; font-size: .76rem; }
  .mode-picker button { padding: 12px; gap: 5px; }
  .mode-picker small { font-size: .56rem; }
  .result-stats { justify-content: space-between; }
}
@media (max-height: 650px) and (orientation: portrait) {
  .overlay-intro #overlayText { display: none; }
  .fruit-preview { height: 55px; margin: 5px 0 -5px; }
  .overlay-card { gap: 14px; padding: 18px; }
  h2 { font-size: 2.1rem; }
  .eyebrow { margin-bottom: 8px; }
  #overlayText { margin-top: 8px; line-height: 1.5; }
  .mode-picker button { padding: 10px; }
  .mode-picker button > span { display: none; }
  .mode-rules { margin-top: 9px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .special-panel { inset: 22px 12px auto auto; width: 42%; gap: 4px; }
  .special-panel strong { font-size: 1rem; }
  .special-panel b { font-size: .95rem; }
  .special-panel span { font-size: .65rem; }
  .fruit-preview { height: 64px; margin: 4px 0 -5px; }
  .fruit-header { min-height: 56px; padding: 6px 14px; }
  .fruit-title p { display: none; }
  .fruit-title h1 { font-size: 1.3rem; }
  .fruit-header .play-controls button { min-height: 40px; }
  .fruit-hud { min-height: 50px; padding: 4px 16px; gap: 50px; }
  .fruit-hud > div { display: flex; align-items: center; gap: 8px; }
  .fruit-hud strong { font-size: 1.4rem; }
  .fruit-hud .remaining.is-lives strong { line-height: 1; }
  .fruit-footer { padding: 5px 16px; }
  .fruit-overlay { inset-block-start: calc(56px + env(safe-area-inset-top)); padding: 10px 18px; }
  .overlay-card { width: min(100%, 830px); grid-template-columns: .85fr 1.15fr; gap: 22px; padding: 16px 22px; }
  .eyebrow { font-size: .48rem; margin-bottom: 8px; }
  h2 { font-size: 2.2rem; }
  #overlayText { font-size: .72rem; line-height: 1.6; margin-top: 10px; }
  .mode-picker button { padding: 8px 10px; gap: 3px; }
  .mode-picker button > span { display: none; }
  .mode-picker b { font-size: .73rem; }
  .mode-picker small { font-size: .52rem; }
  .round-setting { margin-top: 7px; }
  .round-setting select { min-height: 34px; padding: 5px; }
  .mode-rules { font-size: .62rem; margin-top: 7px; min-height: 0; }
  .overlay-actions { gap: 8px; }
  .primary-action, .secondary-action { min-height: 42px; padding: 9px 13px; }
  .control-note { display: none; }
  .result-stats { margin-top: 16px; gap: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .combo-toast.is-visible { opacity: 1; transform: translateX(-50%); } }

/* In landscape, the cutting surface gets the full available height. */
@media (orientation: landscape) and (max-height: 600px) {
  .fruit-shell { --fruit-rail: clamp(136px, 19vw, 176px); grid-template-columns: minmax(0, 1fr) var(--fruit-rail); grid-template-rows: auto minmax(0, 1fr); }
  .fruit-stage { grid-column: 1; grid-row: 1 / 3; }
  .fruit-header { grid-column: 2; grid-row: 1; min-height: 0; display: grid; grid-template-columns: 44px 1fr; gap: 6px; padding: 6px 8px; border: 0; border-left: 1px solid var(--line); }
  .fruit-header .back-link { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .fruit-header .back-link span, .fruit-title p { display: none; }
  .fruit-title h1 { font-size: 1rem; white-space: nowrap; }
  .fruit-header .play-controls { display: grid; grid-column: 1 / -1; grid-row: 2; grid-template-columns: 1fr 1fr; width: 100%; gap: 5px; }
  .fruit-header .play-controls button { min-height: 44px; padding: 0; }
  .fruit-header .play-controls b { display: inline; font-size: .62rem; }
  .fruit-hud { grid-column: 2; grid-row: 2; display: flex; flex-direction: column; justify-content: space-evenly; align-items: stretch; gap: 4px; min-height: 0; padding: 6px 10px; border-left: 1px solid var(--line); }
  .fruit-hud > div { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: 5px; }
  .fruit-hud span { font-size: .54rem; letter-spacing: 0; }
  .fruit-hud strong { font-size: 1.35rem; }
  .fruit-hud .remaining strong { min-width: 0; }
  .fruit-hud .remaining.is-lives strong { font-size: .78rem; letter-spacing: 0; }
  .fruit-footer { display: none; }
  .fruit-overlay { inset: env(safe-area-inset-top) calc(var(--fruit-rail) + env(safe-area-inset-right)) env(safe-area-inset-bottom) env(safe-area-inset-left); padding: 10px; overflow: hidden; }
  .overlay-card { width: 100%; height: 100%; min-height: 0; grid-template-columns: .8fr 1.2fr; gap: 18px; padding: 16px; border-radius: 18px; }
  .overlay-intro { min-height: 0; max-height: 100%; overflow: auto; }
  .overlay-intro h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
  .overlay-actions { display: flex; flex-direction: column; min-height: 0; height: 100%; gap: 8px; justify-content: center; }
  #modeSettings { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px; }
  .overlay-actions > button, .asset-loading { flex: 0 0 auto; }
  .overlay-actions > button { min-height: 44px; }
  .control-note { display: none; }
  .mode-picker button { min-height: 54px; padding: 8px; }
  .mode-picker button > span { display: none; }
  .round-setting select { min-height: 40px; padding-right: 26px; }
  .special-panel { inset: 12px 10px auto auto; width: 42%; }
  .special-panel strong { font-size: 1rem; }
  .special-panel span { font-size: .62rem; }
}
@media (orientation: landscape) and (max-height: 600px) and (max-width: 740px) {
  .overlay-card:has(#modeSettings:not([hidden])) { grid-template-columns: 1fr; }
  .overlay-card:has(#modeSettings:not([hidden])) .overlay-intro { display: none; }
  .overlay-card { gap: 12px; padding: 12px; }
  .fruit-preview { display: none; }
  #overlayText { font-size: .68rem; line-height: 1.5; }
  .result-stats { gap: 10px; margin-top: 12px; }
  .result-stats strong { font-size: 1.3rem; }
}
@media (max-width: 380px) and (orientation: portrait) {
  .fruit-title { display: none; }
  .fruit-header { grid-template-columns: auto 1fr; }
  .fruit-header .play-controls { grid-column: 2; }
}

/* Fullscreen keeps only the canvas, live score and the two essential controls. */
.fruit-shell.is-immersive { display: block; padding: 0; }
.fruit-shell.is-immersive .fruit-stage { position: absolute; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.fruit-shell.is-immersive .fruit-header { position: absolute; z-index: 12; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: block; min-height: 0; padding: 0; border: 0; background: transparent; }
.fruit-shell.is-immersive .fruit-header .back-link, .fruit-shell.is-immersive .fruit-title, .fruit-shell.is-immersive #landscapeButton, .fruit-shell.is-immersive .fruit-footer { display: none; }
.fruit-shell.is-immersive .fruit-header .play-controls { display: flex; width: auto; gap: 6px; }
.fruit-shell.is-immersive .fruit-header button { flex: 0 0 auto; min-width: 44px; min-height: 44px; background: #192f28d9; border-color: #d6e0bc30; padding: 6px 10px; white-space: nowrap; }
.fruit-shell.is-immersive[data-phase="playing"] #soundToggle, .fruit-shell.is-immersive #pauseButton:disabled { display: none; }
.fruit-shell.is-immersive .fruit-hud { position: absolute; z-index: 2; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); display: flex; flex-direction: row; gap: 24px; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 12px; background: #192f28b3; pointer-events: none; }
.fruit-shell.is-immersive .fruit-hud > div { display: grid; min-width: 0; gap: 2px; text-align: left; }
.fruit-shell.is-immersive .fruit-hud > div:last-child { display: none; }
.fruit-shell.is-immersive .fruit-hud strong { font-size: 1.4rem; line-height: 1; }
.fruit-shell.is-immersive .fruit-hud .remaining strong { min-width: 0; }
.fruit-shell.is-immersive .fruit-hud .remaining.is-lives strong { font-size: 1rem; line-height: 1.4; }
.fruit-shell.is-immersive .fruit-hud span { font-size: .5rem; }
.fruit-shell.is-immersive .fruit-overlay { inset: calc(66px + env(safe-area-inset-top)) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
@media (max-width: 480px) {
  .fruit-shell.is-immersive .fruit-header .play-controls b { display: none; }
}
