:root {
  color-scheme: light;
  --ui-scale: .9;
  --cream: #fff8e7; --paper: #fffdf8; --ink: #49443e; --muted: #766e63; --line: #e6ddce;
  --coral: #de7f66; --coral-dark: #a44732; --pink: #f7a6b9; --orange: #f9c784; --yellow: #ffe66d; --mint: #a8e6cf;
  --canvas: var(--cream); --surface: var(--paper); --accent: var(--coral); --accent-text: var(--coral-dark);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px; --space-12: 48px;
  --radius-sm: 10px; --radius-md: 16px; --radius-lg: 24px; --radius-dialog: 28px;
  --shadow: 0 2px 4px #65533806, 0 12px 36px #65533808;
  font-family: ui-rounded, 'Hiragino Maru Gothic ProN', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink); background: var(--canvas); font-synthesis: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; min-width: 320px; }
button, a { touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button, a { -webkit-user-select: none; user-select: none; }
button { border: 0; background: none; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 4px; }
button:active:not(:disabled) { transform: translateY(2px); }
a { color: var(--accent-text); }
.icon { width: 23px; height: 23px; flex-shrink: 0; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 20; background: white; padding: 16px; }
.skip-link:focus { top: 16px; }
.app-shell { zoom: var(--ui-scale); width: min(100vw, 480px); min-height: 100svh; margin: auto; padding: max(24px, env(safe-area-inset-top)) 28px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.app-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 20px; }
.brand { display: flex; gap: 10px; align-items: center; min-width: 0; text-decoration: none; color: var(--ink); }
.brand > span { min-width: 0; white-space: nowrap; font-size: 18px; font-weight: 750; letter-spacing: .03em; }
.brand img { width: 40px; height: 40px; flex-shrink: 0; }
.brand small { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 10px; letter-spacing: .07em; margin-top: 3px; font-weight: 400; }
.header-actions { display: flex; align-items: center; flex-shrink: 0; gap: 6px; }
.icon-button { display: grid; place-items: center; border: 1px solid var(--line); width: 44px; height: 44px; border-radius: 50%; background: #fffdf877; }
.icon-button[aria-pressed="true"] { color: var(--accent-text); background: #fce9df; }
main { width: 100%; }
.level-button { display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0; padding: 0; min-width: 52px; min-height: 44px; }
.level-button span { font-size: 12px; padding: 6px 9px; border: 1px solid #ddcfb7; border-radius: 7px; font-variant-numeric: tabular-nums; }
.theme-switch { display: flex; justify-content: center; width: 230px; margin: 16px auto 20px; padding: 4px; background: #eee8db; border-radius: 14px; }
.theme-switch button { display: flex; justify-content: center; align-items: center; gap: 7px; width: 50%; min-height: 40px; font-size: 14px; border-radius: 10px; color: var(--muted); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px #65533810; color: var(--ink); font-weight: 650; }
.mode-number { font-size: 17px; font-weight: 700; letter-spacing: -.06em; }
#fruit-mode-icon { display: flex; }
#fruit-mode-icon .fruit { width: 25px; height: 25px; }
.board-frame { background: var(--surface); border: 1px solid var(--line); padding: 12px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.board { display: grid; aspect-ratio: 1; grid-template-columns: 1fr 1fr 2px 1fr 1fr; grid-template-rows: 1fr 1fr 2px 1fr 1fr; gap: 5px; }
.cell { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; background: white; border: 1.5px solid #d9cbb6; border-bottom-width: 3px; border-radius: var(--radius-sm); font-size: clamp(30px, 9vw, 40px); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; transition: background-color 120ms, border-color 120ms; }
.cell.given { color: #716b60; background: #f0ede5; border-color: #f0ede5; border-bottom-color: #e8e3d9; }
.cell:not(.given) { color: var(--accent-text); }
.cell.empty::after { content: ''; width: 12px; height: 12px; border: 1.5px dashed #d6c9b8; border-radius: 50%; }
.cell.selected { outline: 3px solid var(--accent); outline-offset: -3px; background: #fff1e8; border-color: var(--accent); }
.cell.selected.empty::after { border-color: var(--accent); }
.cell.placed { animation: place 180ms ease-out; }
.fruit { width: 72%; height: 72%; overflow: visible; }
.guide { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.number-pad { margin-top: 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0 8px; }
.piece { position: relative; display: grid; place-items: center; min-height: 64px; aspect-ratio: 1.15; border: 1px solid var(--edge); border-bottom-width: 5px; border-radius: var(--radius-md); background: var(--fill); color: var(--piece-ink); font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.piece[data-value="1"] { --fill: var(--pink); --edge: #dc869b; --piece-ink: #773247; }
.piece[data-value="2"] { --fill: var(--orange); --edge: #d7a45e; --piece-ink: #6d4516; }
.piece[data-value="3"] { --fill: var(--yellow); --edge: #d4bc4a; --piece-ink: #65510a; }
.piece[data-value="4"] { --fill: var(--mint); --edge: #7fbaa3; --piece-ink: #285a44; }
.piece.active { outline: 3px solid var(--accent-text); outline-offset: 3px; }
.piece.active::after { content: ''; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); bottom: -14px; }
.piece .fruit { width: 70%; height: 70%; }
.new-game { margin: 16px auto 0; width: 100%; min-height: 48px; display: flex; justify-content: center; align-items: center; gap: 9px; border: 1px solid #cdbfa8; border-bottom-width: 3px; border-radius: 14px; background: #fffdf877; font-size: 14px; font-weight: 600; }
.new-game .icon { width: 18px; height: 18px; }
dialog { zoom: var(--ui-scale); position: fixed; inset: auto 0 0; margin: auto auto 0; padding: 0; width: min(100vw, 480px); max-height: 90dvh; border: 1px solid var(--line); border-radius: var(--radius-dialog) var(--radius-dialog) 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -8px 70px #49443e18; overscroll-behavior: contain; }
dialog::backdrop { background: #40382e55; backdrop-filter: blur(3px); }
body:has(dialog[open]) { overflow: hidden; }
.dialog-content { padding: 28px 24px max(24px, env(safe-area-inset-bottom)); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
.dialog-content p { font-size: 14px; line-height: 1.9; color: var(--muted); }
.dialog-content .dialog-intro { margin: 0 0 24px; }
.level-options { display: grid; gap: 8px; }
.level-option { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; min-height: 52px; font-size: 16px; text-align: left; }
.level-option[aria-pressed="true"] { border-color: var(--accent); background: #fff1e8; }
.level-option .option-check { display: flex; color: var(--accent-text); }
.dialog-actions { display: flex; gap: 12px; margin-top: 24px; }
.primary-button, .secondary-button { min-height: 52px; display: flex; gap: 8px; align-items: center; justify-content: center; border-radius: 14px; padding: 12px 20px; font-size: 15px; }
.primary-button { background: var(--accent); color: #39251e; border-bottom: 3px solid #bb6350; font-weight: 650; flex: 1; }
.game-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.game-actions > button { width: 100%; min-height: 52px; margin: 0; white-space: nowrap; padding: 12px 8px; }
.submit-game { width: 100%; }
.submit-game:disabled { background: #e6ddce; border-color: #cdbfa8; color: var(--muted); }
.secondary-button { border: 1px solid var(--line); background: white; }
.tutorial-example { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 24px 0; padding: 12px; border-radius: 16px; background: #f0ede5; }
.tutorial-example span { display: grid; place-items: center; height: 56px; background: white; border-radius: 9px; font-size: 26px; }
.tutorial-example span:last-child { outline: 2px dashed var(--accent); color: var(--accent-text); background: #fff1e8; }
.tutorial-steps { padding: 0; margin: 20px 0; list-style: none; }
.tutorial-steps li { display: flex; align-items: center; gap: 14px; padding: 10px 0; font-size: 14px; line-height: 1.7; }
.step-dot { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #f3eada; color: #796446; flex-shrink: 0; font-size: 12px; }
.storage-notice { font-size: 12px; color: var(--accent-text); text-align: center; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes place { from { transform: scale(.92); } to { transform: scale(1); } }
@media (hover: hover) and (pointer: fine) {
  .icon-button:hover { background: #f1e8d5; }
  .cell:hover:not(.given) { border-color: var(--accent); }
  .new-game:hover { background: var(--surface); border-color: var(--accent); }
  .primary-button:hover { background: #e58c75; }
}
@media (min-width: 600px) {
  .app-shell { margin: 32px auto; padding: 28px 32px 16px; min-height: min(850px, calc(100svh - 64px)); border: 1px solid var(--line); border-radius: 32px; background: #fffaf0; box-shadow: var(--shadow); }
  body { background-image: radial-gradient(#e9dfcc 1px, transparent 1px); background-size: 20px 20px; }
  dialog { inset: 0; margin: auto; border-radius: var(--radius-dialog); }
}
@media (max-width: 374px) {
  .app-shell { padding-left: 20px; padding-right: 20px; }
  .brand { gap: 6px; }
  .brand img { width: 32px; height: 32px; }
  .brand > span { font-size: 16px; }
  .brand small { font-size: 9px; }
  .header-actions { gap: 2px; }
  .icon-button { width: 44px; height: 44px; }
  .board-frame { padding: 9px; border-radius: 20px; }
  .board { gap: 4px; }
  .number-pad { padding: 0; gap: 8px; }
  .piece { min-height: 58px; }
}
@media (max-height: 800px) and (max-width: 599px) {
  .app-shell { padding-top: max(16px, env(safe-area-inset-top)); }
  .app-header { margin-bottom: 20px; }
  .theme-switch { margin: 18px auto 20px; }
  .new-game { margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
