:root { color-scheme: light; --page: #edf2f1; --ink: #253633; --muted: #61716d; --teal: #25605b; --amber: #d3913d; --line: #d3dfdc; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 18px/1.5 "Yu Gothic", "Meiryo", system-ui, sans-serif; }
button, input, select { font: inherit; }
button { min-height: 52px; padding: 11px 15px; cursor: pointer; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; font-weight: 700; line-height: 1.35; touch-action: manipulation; }
button:disabled { background: #dce5e5; color: #6e7f82; cursor: default; box-shadow: none; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
button svg { width: 24px; height: 24px; vertical-align: middle; flex-shrink: 0; }
button.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
button.primary:disabled { background: #dce5e5; border-color: #dce5e5; color: #6e7f82; }
button.secondary { background: #f2f6f5; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 23px; line-height: 1.35; letter-spacing: -.7px; }
h2 { font-size: 24px; line-height: 1.35; }
h3 { font-size: 23px; line-height: 1.35; }
small, .small { font-size: 15px; line-height: 1.55; color: var(--muted); }
[hidden] { display: none !important; }
.app { width: min(100%, 480px); margin: 16px auto; min-height: calc(100dvh - 32px); background: #fff; border-radius: 16px; box-shadow: 0 4px 24px #2d4f4820; overflow: clip; }
.header { padding: 12px 16px 4px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.icon-button { border: 0; width: 48px; min-height: 48px; padding: 10px; background: transparent; }
.stock { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 4px 12px 10px; }
.stock-item { display: flex; align-items: center; justify-content: center; gap: 4px; background: #edf3f3; border-radius: 8px; padding: 5px 2px; min-width: 0; }
.stock-text { font-size: 15px; line-height: 1.25; }
.stock-text strong { font-size: 21px; display: block; }
.stock .sprite { width: 43px; height: 43px; flex-shrink: 0; }
#main { padding-bottom: 85px; outline: none; }
.navigation { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 480px); background: #fff; border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 8; box-shadow: 0 -3px 10px #2536330c; }
.navigation button { border: 0; border-radius: 5px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 2px; font-size: 16px; }
.navigation button[aria-current="page"] { background: var(--teal); color: #fff; }
.navigation button + button { border-left: 1px solid var(--line); }
.sprite { display: inline-block; background-image: url("assets/game-sprites.png"); background-size: 300% 300%; background-repeat: no-repeat; width: 44px; height: 44px; }
.part-gear { background-position: 0% 0%; }
.part-armor { background-position: 50% 0%; }
.part-battery { background-position: 100% 0%; }
.sprite-crop { background: none; overflow: hidden; }
.obstacle-sprite { background: none; }
.town-art { position: relative; aspect-ratio: 1080 / 971; background-image: url("assets/town-stages-v2.png"); background-size: 300% 200%; background-repeat: no-repeat; background-position: 0% 0%; border-radius: 10px 10px 0 0; }
.town-art[data-stage="1"] { background-position: 50% 0%; }
.town-art[data-stage="2"] { background-position: 100% 0%; }
.town-art[data-stage="3"] { background-position: 0% 100%; }
.town-art[data-stage="4"] { background-position: 50% 100%; }
.town-art[data-stage="5"] { background-position: 100% 100%; }
.robot-sprite { background-image: url("assets/robot-growth-v1.png"); background-size: 300% 200%; background-position: 0% 0%; }
.robot-sprite[data-robot-path="cute"] { background-image: url("assets/robot-path-cute-v1.png"); }
.robot-sprite[data-robot-path="cool"] { background-image: url("assets/robot-path-cool-v1.png"); }
.robot-sprite[data-robot-path="quirky"] { background-image: url("assets/robot-path-quirky-v1.png"); }
.robot-sprite[data-robot-form="1"] { background-position: 50% 0%; }
.robot-sprite[data-robot-form="2"] { background-position: 100% 0%; }
.robot-sprite[data-robot-form="3"] { background-position: 0% 100%; }
.robot-sprite[data-robot-form="4"] { background-position: 50% 100%; }
.robot-sprite[data-robot-form="5"] { background-position: 100% 100%; }
.robot-showcase { position: absolute; inset: auto 0 0; display: flex; align-items: flex-end; gap: 0; padding: 42px 12px 12px; color: #fff; background: linear-gradient(transparent, #142c32df 40%, #142c32f5); }
.robot-showcase .robot-hero { width: 56%; height: auto; aspect-ratio: 1; flex-shrink: 0; filter: drop-shadow(0 5px 5px #0006); }
.robot-growth-info { min-width: 0; flex: 1; padding-bottom: 4px; }
.robot-growth-label { color: #e2e9dd; font-size: 13px; margin-bottom: 4px; }
.robot-path-badge { display: inline-block; padding: 2px 6px; border: 1px solid #f0d7a9; border-radius: 5px; color: #ffe5ad; background: #243f43; font-size: 12px; line-height: 1.5; margin-bottom: 4px; }
.robot-growth-info h2 { font-size: clamp(20px, 5.2vw, 25px); line-height: 1.3; margin-bottom: 10px; }
.robot-completion { font-size: 14px; white-space: nowrap; }
.robot-completion b { color: #ffcc75; font-size: 32px; line-height: 1; }
.robot-growth-info progress { display: block; width: 100%; height: 10px; margin: 7px 0; accent-color: #efb755; }
.robot-growth-next { font-size: 13px; line-height: 1.5; color: #f7e5bd; }
.robot-gallery { margin: 10px 16px 0; font-size: 15px; }
.robot-gallery summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 700; }
.robot-gallery summary span { color: var(--teal); white-space: nowrap; }
.robot-gallery > p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.robot-gallery h3 { font-size: 17px; margin: 10px 0 6px; }
.robot-paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0 0 10px; padding: 0; }
.robot-paths li { min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: #f4f6f3; }
.robot-paths li[aria-current="true"] { border: 2px solid var(--teal); padding: 4px; background: #e3f1e9; }
.robot-paths .robot-sprite { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.robot-paths strong, .robot-paths li > span:not(.sprite) { display: block; font-size: 12px; line-height: 1.5; }
.robot-paths progress { display: block; width: 100%; height: 8px; margin: 4px 0; accent-color: var(--teal); }
.robot-paths p { font-size: 12px; line-height: 1.5; }
.robot-forms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; list-style: none; padding: 0; margin: 0; }
.robot-forms li { min-width: 0; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #edf3f3; }
.robot-forms li[aria-current="step"] { border: 2px solid var(--teal); padding: 5px; background: #e3f1e9; }
.robot-forms .robot-sprite { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.robot-forms strong, .robot-forms li > span:not(.sprite) { display: block; font-size: 13px; line-height: 1.5; }
.robot-forms li > span:not(.sprite) { color: var(--teal); }
.robot-forms li > p { font-size: 12px; line-height: 1.5; margin-top: 5px; }
.robot-locked .robot-sprite { filter: grayscale(1); opacity: .48; }
.town-facilities { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; padding: 10px 12px 0; }
.town-facility { min-width: 0; padding: 4px 3px 5px; display: flex; flex-direction: column; align-items: center; gap: 3px; border: 2px solid transparent; background: #edf3f3; border-radius: 8px; }
.town-facility[aria-pressed="true"] { border-color: var(--teal); background: #e8f4f2; }
.facility-sprite { display: block; width: 52px; max-width: 100%; aspect-ratio: 1; background: url("assets/town-facilities-v1.png") no-repeat 0% 0% / 300% 200%; }
.facility-1 { background-position: 50% 0%; }
.facility-2 { background-position: 100% 0%; }
.facility-3 { background-position: 0% 100%; }
.facility-4 { background-position: 50% 100%; }
.facility-name { font-size: 15px; line-height: 1.25; }
.facility-level { font-size: 12px; font-weight: 700; line-height: 1.4; }
.facility-status { width: 100%; border-radius: 4px; padding: 3px 0; font-size: 13px; line-height: 1.3; background: #dce5e5; }
.town-facility.current .facility-status { background: var(--teal); color: #fff; }
.town-facility.completed .facility-status { background: #d0e5de; color: #234f43; }
.town-guide { display: flex; align-items: center; gap: 12px; padding: 12px 16px 0; }
.town-guide .town-guide-avatar { width: 72px; height: 72px; flex-shrink: 0; border-radius: 9px; background-color: #f3ebe0; animation: robot-breathe 4s ease-in-out infinite; }
.town-guide p { position: relative; flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 17px; line-height: 1.5; }
.town-guide p::before { content: ""; position: absolute; left: -6px; top: 50%; width: 10px; height: 10px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; transform: translateY(-50%) rotate(45deg); }
.mission { padding: 14px 16px 18px; }
.construction-panel { margin: 14px 16px 0; padding: 12px; background: #fbf6eb; border: 1px solid #d7c5a6; border-radius: 10px; }
.construction-panel h3 { font-size: 20px; margin-bottom: 5px; }
.construction-panel p { font-size: 16px; line-height: 1.5; }
.construction-panel progress { display: block; width: 100%; margin: 10px 0; }
.level-guide { margin-top: 14px; font-size: 15px; }
.level-guide summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.level-guide table { width: 100%; border-collapse: collapse; margin: 8px 0; text-align: center; }
.level-guide th, .level-guide td { padding: 6px; border-bottom: 1px solid var(--line); }
.eyeline { font-size: 16px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.mission h2 { font-size: 27px; margin-bottom: 5px; }
.mission-description { font-size: 17px; margin-bottom: 10px; }
.costs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 16px; }
.cost { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.cost .sprite { width: 30px; height: 30px; }
.progress-line { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 16px; font-weight: 700; }
progress { flex: 1; width: 50%; height: 12px; accent-color: var(--teal); }
.two-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tutorial-panel { margin: 12px 0; padding: 12px; border: 1px solid #d7c5a6; border-radius: 10px; background: #fbf6eb; }
.tutorial-panel h3 { font-size: 19px; margin-bottom: 6px; }
.tutorial-panel p { font-size: 16px; margin-bottom: 10px; }
.tutorial-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tutorial-actions button { flex: 1; font-size: 16px; }
.board-column.recommended { outline: 2px solid var(--teal); outline-offset: -3px; background: #25605b12; }
.column-number { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font-size: 15px; color: var(--ink); }
.reward-progress { margin: 10px 0; padding: 10px; border-radius: 8px; background: #fff8ea; color: var(--ink); font-size: 16px; line-height: 1.5; }
.town-services { padding: 0 16px 18px; }
.robot-status { padding: 10px 12px; border: 1px solid #d7c5a6; border-radius: 9px; background: #fbf6eb; font-size: 16px; }
.robot-status svg { width: 22px; height: 22px; vertical-align: middle; margin-right: 5px; }
.town-service, .battle-option { padding: 14px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; background: #f7faf9; }
.town-service h3, .battle-option h3 { font-size: 21px; margin-bottom: 6px; }
.town-service p, .battle-option p { font-size: 16px; margin: 6px 0 10px; }
.town-service > button { width: 100%; }
.service-note { color: var(--muted); line-height: 1.55; }
.request-list { list-style: none; margin: 12px 0 0; padding: 0; }
.request-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.request-list li > div { min-width: 0; flex: 1; font-size: 17px; }
.request-list li p { margin: 4px 0 0; font-size: 15px; }
.request-list button { padding: 10px 8px; font-size: 16px; min-width: 86px; flex-shrink: 0; }
.exchange-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.exchange-fields label { min-width: 0; font-size: 16px; }
.exchange-fields select { display: block; width: 100%; min-height: 52px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; margin-top: 4px; }
.equipment-status { font-size: 15px; padding: 8px 0 0; color: var(--muted); }
.sprite.upgraded { filter: drop-shadow(0 0 3px #e1aa52); }
.mission-list { list-style: none; padding: 0; margin: 14px 0 0; font-size: 17px; }
.mission-list li { padding: 7px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.mission-number { color: #fff; background: #84928f; border-radius: 50%; min-width: 26px; height: 26px; font-size: 16px; line-height: 26px; text-align: center; }
.mission-list .completed { color: var(--teal); }
.mission-list .completed .mission-number { background: var(--teal); }
.need-parts { margin-top: 8px; font-size: 15px; color: var(--muted); }
#town-shortfall { margin: 12px 0; font-size: 18px; font-weight: 650; color: var(--ink); }
.game-panel { padding: 12px 12px 4px; }
.game-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.game-heading h2 { font-size: 23px; }
.rule { font-size: 16px; margin-top: 4px; }
.next-piece { text-align: center; flex: 0 0 70px; border-radius: 8px; background: #f1f5f5; padding: 4px; font-size: 14px; line-height: 1.4; }
.next-piece .sprite { width: 47px; height: 47px; display: block; margin: 2px auto; }
.game-counts { display: flex; justify-content: space-between; gap: 10px; font-size: 17px; margin-bottom: 8px; }
.game-counts b { font-size: 22px; }
.balance-meter { margin: 8px 0 14px; }
.balance-caption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; font-size: 15px; margin-bottom: 8px; }
.balance-caption strong { color: var(--teal); }
.balance-meter[data-level="warning"] strong { color: #875214; }
.balance-meter[data-level="collapse"] strong, .drop-forecast.at-risk { color: #a52b23; }
.balance-track { position: relative; height: 8px; border-radius: 6px; background: linear-gradient(to right, #ae4135 0% 10%, #e5b15e 10% 25%, #82b7ad 25% 75%, #e5b15e 75% 90%, #ae4135 90% 100%); }
.balance-track::after { content: ""; position: absolute; left: 50%; top: -3px; height: 14px; border-left: 1px solid #ffffff; }
.balance-track i { position: absolute; top: -4px; width: 10px; height: 16px; background: var(--ink); border: 1px solid #fff; border-radius: 3px; transform: translateX(-50%); z-index: 1; }
.board { position: relative; height: 350px; overflow: hidden; border: 1px solid #99aeb8; border-radius: 12px; background: linear-gradient(130deg, #cfdee7, #86a1b3); box-shadow: inset 0 0 20px #425b6c25; }
.board-column { position: absolute; width: 14.2857%; top: 18px; bottom: 92px; min-height: 0; border: 0; border-left: 1px dashed #eff6fa72; border-radius: 0; padding: 0; background: transparent; }
.board-column.selected { background: #f9dc9340; border: 2px dashed #ad762a; border-bottom: 0; border-radius: 7px 7px 0 0; }
.board-column:disabled { background: transparent; }
.board-column.selected:disabled { background: #f9dc9340; }
.beam-group { position: absolute; bottom: 92px; left: 4%; width: 92%; height: 1px; transform-origin: center; transition: transform .28s ease-out; pointer-events: none; z-index: 3; }
.beam-group .beam-art { position: absolute; width: 100%; height: 30px; top: 0; left: 0; transform: translateY(-50%); }
.piece { position: absolute; width: 14.2857%; max-width: 48px; height: auto; aspect-ratio: 1; transform: translateX(-50%); }
.piece .sprite { display: block; width: 100%; height: 100%; }
.beam-group.rocking { animation: seesaw-rock .6s ease-out both; }
.rocking .piece .sprite { animation: piece-sway .6s ease-out both; }
.piece.travelling { animation: piece-travel .55s ease-in-out both; }
.piece.overboard { animation: piece-overboard 1s ease-in forwards; z-index: 1; }
.piece.collected { animation: piece-collect .4s ease-out forwards; }
.board.collapsing { border-color: #a52b23; background: linear-gradient(130deg, #e8d0bd, #b67b67); }
.board.collapsing .piece { animation: pile-collapse 1.05s ease-in var(--fall-delay) forwards; }
.pivot { position: absolute; width: 100px; height: 100px; bottom: 9px; left: 50%; transform: translateX(-50%); z-index: 2; }
.board-floor { position: absolute; bottom: 14px; height: 2px; left: 5%; right: 5%; background: #566d76; }
.balance-info { min-height: 46px; text-align: center; font-size: 16px; margin: 8px 0; }
.drop-forecast { display: block; margin-top: 4px; font-weight: 650; }
.drop-controls { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 8px; }
.arrow-control { display: flex; align-items: center; justify-content: center; gap: 4px; }
.hammer-controls { margin-top: 10px; padding: 10px; border: 1px solid #d7c5a6; border-radius: 10px; background: #fbf6eb; }
.hammer-controls button { width: 100%; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 8px; }
.hammer-controls button span { font-size: 16px; }
.hammer-controls p { margin-top: 6px; font-size: 15px; line-height: 1.5; }
.puzzle-bottom { display: flex; align-items: center; gap: 14px; justify-content: space-between; margin-top: 10px; }
.puzzle-bottom button { flex: 1; }
.puzzle-bottom p { font-size: 17px; white-space: nowrap; }
.puzzle-bottom strong { font-size: 22px; }
.puzzle-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.puzzle-tools button { padding: 8px 4px; font-size: 16px; }
.puzzle-tools button span { font-size: 13px; white-space: nowrap; }
.puzzle-tools button svg { width: 18px; height: 18px; }
.puzzle-help { margin-top: 8px; font-size: 14px; color: var(--muted); }
.puzzle-help summary, .puzzle-guide summary { cursor: pointer; padding: 8px 0; font-weight: 700; }
.puzzle-help p { margin: 8px 0; }
.puzzle-guide { padding: 0 8px; }
.puzzle-guide summary { font-size: 14px; }
.puzzle-guide p { margin: 6px 0; }
.puzzle-guide .tutorial-actions { padding-bottom: 8px; }
.facility-rank { display: flex; gap: 2px; width: 80%; }
.facility-rank i { flex: 1; height: 4px; border-radius: 2px; background: #cddbd6; }
.facility-rank i.filled { background: var(--amber); }
.town-facility[data-level="3"] .facility-sprite, .town-facility[data-level="4"] .facility-sprite, .town-facility[data-level="5"] .facility-sprite { filter: drop-shadow(0 1px 3px #d3913d80); }
.upgrade-benefit { margin-top: 10px; padding: 10px; background: #edf7f1; border-left: 3px solid var(--teal); font-size: 16px; }
.battle-risk { color: #913821; }
.arena { position: relative; padding: 12px; min-height: 270px; background: linear-gradient(#172d43cf, #172d43e6), url("assets/town-stages.png") 50% 80% / 300% auto; color: #fff; border-radius: 12px; overflow: hidden; }
.arena h2 { margin-bottom: 10px; }
.health-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.health-label { display: flex; justify-content: space-between; font-size: 16px; }
.health-bar { height: 10px; background: #ffffff38; border: 1px solid #ffffff85; border-radius: 6px; overflow: hidden; margin-top: 4px; }
.health-bar i { display: block; height: 100%; width: 100%; background: #36a569; transition: width .2s; }
.health-bar.enemy i { background: #d3913d; }
.fighters { display: flex; align-items: flex-end; justify-content: space-around; gap: 8px; padding-top: 6px; }
.fighters .sprite { width: 45%; height: auto; aspect-ratio: 1; }
.forecast { padding: 10px 8px; text-align: center; border-radius: 8px; background: #f5e7e1; margin: 10px 0 8px; font-size: 18px; }
.forecast strong { color: #9b3923; }
.commands { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.commands button { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px 4px; }
.commands button svg { width: 21px; height: 21px; }
.battle-hint { font-size: 15px; margin: 10px 0; }
.battle-log { list-style: none; margin: 0 0 12px; padding: 10px 12px; background: #f0f5f5; border-radius: 8px; font-size: 16px; }
.battle-log li + li { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); }
.battle-return { width: 100%; }
.rps-panel h2, .rps-opponent { text-align: center; }
.rps-opponent { font-size: 16px; margin: 4px 0 6px; color: var(--muted); }
.rps-match-rule { font-size: 17px; font-weight: 700; text-align: center; margin: 0 0 10px; color: var(--teal); }
.rps-arena { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr); align-items: center; padding: 10px 8px; border-radius: 12px; color: #fff; background: linear-gradient(#172d43dc, #172d43ef), url("assets/town-stages.png") 50% 80% / 300% auto; }
.rps-player { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.rps-label { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 0 6px; max-width: 100%; }
.rps-player strong { font-size: 18px; }
.rps-score { font-size: 17px; color: #ffcc75; white-space: nowrap; }
.rps-score b { font-size: 24px; margin-right: 2px; }
.rps-player .sprite { width: clamp(108px, 28vw, 128px); height: auto; aspect-ratio: 1; max-width: 100%; }
.rps-hand { display: block; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; line-height: 1.2; }
.rps-played-hand { display: flex; align-items: center; gap: 6px; }
.rps-player .rps-hand { font-size: 24px; margin: 3px 0; }
.rps-played-hand b { font-size: 17px; }
.rps-vs { font-size: 16px; font-weight: 700; text-align: center; color: #ffcc75; }
.rps-result { padding: 12px 8px; margin: 12px 0; min-height: 92px; text-align: center; border: 2px solid var(--line); border-radius: 12px; background: #f2f6f5; }
.rps-result h3 { font-size: 30px; line-height: 1.3; }
.rps-result p { font-size: 17px; margin-top: 4px; }
.rps-result[data-result="win"], .rps-result[data-result="round-win"] { color: var(--teal); background: #e4f3e9; border-color: var(--teal); }
.rps-result[data-result="lose"], .rps-result[data-result="round-lose"] { color: #913821; background: #fff0eb; border-color: #b64c30; }
.rps-result[data-result="draw"] { color: #77501f; background: #fff6df; border-color: var(--amber); }
.commands.rps-commands { gap: 8px; }
.commands.rps-commands button { flex-direction: column; flex-wrap: wrap; min-height: 68px; font-size: 18px; padding: 8px 4px; }
.rps-commands .rps-hand { font-size: 24px; }
.rps-rules { margin: 14px 0 10px; font-size: 17px; text-align: center; }
.rps-reward { margin: 12px 0; font-size: 17px; text-align: center; }
.reward-effect[data-outcome="win"] h2, .reward-effect[data-outcome="lose"] h2, .reward-effect[data-outcome="supply"] h2 { font-size: 30px; }
.idle-screen { padding: 16px; }
.idle-screen p { margin: 10px 0 16px; }
.idle-screen button { width: 100%; }
.warning { margin: 4px 12px 10px; padding: 10px; font-size: 15px; border: 1px solid #bd9355; border-radius: 6px; background: #fff4dc; }
.notice { position: fixed; left: 50%; transform: translateX(-50%); bottom: 78px; z-index: 30; width: min(calc(100% - 28px), 448px); padding: 12px 16px; border-radius: 10px; background: #253633; color: white; font-size: 16px; box-shadow: 0 3px 12px #0003; }
body[data-playing="true"] .header:has(.notice:not([hidden])) h1 { display: none; }
body[data-playing="true"] .notice { position: static; transform: none; width: auto; flex: 1; padding: 4px 8px; border-radius: 6px; font-size: 13px; box-shadow: none; }
.construction-report { margin: 10px 16px; padding: 10px; border-left: 3px solid var(--teal); background: #edf7f1; font-size: 15px; }
.construction-report h3 { font-size: 17px; margin-bottom: 4px; }
dialog { max-width: min(calc(100% - 24px), 440px); width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 18px; color: var(--ink); max-height: 85dvh; overflow: auto; box-shadow: 0 12px 50px #0004; }
dialog::backdrop { background: #14272480; }
.settings-dialog h2 { margin-bottom: 12px; }
.setting-row { min-height: 52px; display: flex; align-items: center; gap: 14px; }
.setting-row input { width: 24px; height: 24px; accent-color: var(--teal); }
.settings-dialog p { margin: 8px 0 14px; }
.settings-dialog button { width: 100%; }
.save-transfer { border-top: 1px solid var(--line); margin: 12px 0; padding-top: 14px; }
.save-transfer h3 { font-size: 19px; }
.save-transfer .two-buttons button { font-size: 16px; padding: 10px 6px; }
#save-import-dialog p { margin: 12px 0; }
.privacy-page { max-width: 720px; margin: 0 auto; padding: 24px 18px; overflow-wrap: anywhere; }
.privacy-page h2 { font-size: 21px; margin: 24px 0 8px; }
.privacy-page p { margin: 12px 0; }
a { color: var(--teal); }
.reward-dialog { padding: 0; border: 3px solid #826c50; background: #372a20; color: #fff9e9; }
.reward-effect { padding: 15px 12px 12px; text-align: center; }
.reward-effect h2 { font-size: 23px; margin-bottom: 7px; }
.lamps { display: flex; justify-content: space-between; margin: 0 15px 8px; border-bottom: 2px solid #846d42; }
.lamps i { width: 12px; height: 12px; border-radius: 50%; background: #776243; margin-bottom: -7px; border: 1px solid #bd9862; transition: background .2s, box-shadow .2s; }
.reward-effect[data-phase="1"] .lamps i:first-child, .reward-effect[data-phase="2"] .lamps i:nth-child(-n+2), .reward-effect[data-phase="3"] .lamps i { background: #ffd281; box-shadow: 0 0 14px #ffc355; }
.reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 10px; }
.reel { border: 2px solid #80603f; border-radius: 8px; padding: 4px; min-width: 0; background: #58412b; }
.reel .sprite { width: 100%; height: auto; aspect-ratio: 1; display: block; }
.reel b { font-size: 20px; display: block; }
.reward-effect[data-phase="3"] .reel { border-color: #efb957; box-shadow: inset 0 0 10px #eba53865, 0 0 8px #eba53860; }
.reward-effect.revealing .reel .sprite { animation: reel-pulse .4s ease-in-out 3; }
.reward-effect[data-phase="1"] .reel:first-child .sprite, .reward-effect[data-phase="2"] .reel:nth-child(-n+2) .sprite, .reward-effect[data-phase="3"] .reel .sprite { animation: none; }
.reward-status { min-height: 36px; font-size: 21px; font-weight: 700; color: #ffcc75; }
.reward-counts { color: #253633; background: #fff9e9; padding: 8px 4px; border-radius: 6px; font-weight: 700; font-size: 16px; margin: 7px 0 12px; }
.reward-dialog .two-buttons button { font-size: 16px; padding: 10px 5px; }
body[data-reduced="true"] *, body[data-reduced="true"] *::before, body[data-reduced="true"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
@keyframes reel-pulse { 0%, 100% { transform: translateY(0); opacity: 1; } 50% { transform: translateY(-7px); opacity: .6; } }
@keyframes robot-breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes seesaw-rock { 0% { transform: rotate(var(--from-angle)); } 55% { transform: rotate(var(--overshoot-angle)); } 100% { transform: rotate(var(--to-angle)); } }
@keyframes piece-sway { 0% { transform: translateX(0); } 35% { transform: translateX(var(--sway)) rotate(-5deg); } 68% { transform: translateX(var(--counter-sway)) rotate(3deg); } 100% { transform: translateX(0); } }
@keyframes piece-travel { from { left: var(--from-left); bottom: var(--from-bottom); transform: translateX(-50%) rotate(-18deg); } to { left: var(--to-left); bottom: var(--to-bottom); transform: translateX(-50%) rotate(0); } }
@keyframes piece-overboard { 0% { left: var(--from-left); bottom: var(--from-bottom); transform: translateX(-50%) rotate(0); } 55% { left: var(--to-left); bottom: 24px; transform: translateX(-50%) rotate(75deg); opacity: 1; } 100% { left: var(--to-left); bottom: -180px; transform: translateX(-50%) rotate(170deg); opacity: 0; } }
@keyframes piece-collect { to { transform: translateX(-50%) translateY(-24px) scale(.3); opacity: 0; } }
@keyframes pile-collapse { 0% { opacity: 1; } 55% { left: var(--fall-left); bottom: 20px; transform: translateX(-50%) rotate(70deg); opacity: 1; } 100% { left: var(--fall-left); bottom: -180px; transform: translateX(-50%) rotate(150deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (max-width: 500px) { .app { margin: 0 auto; min-height: 100dvh; border-radius: 0; box-shadow: none; } }
@media (max-width: 374px) { h1 { font-size: 21px; } .stock .sprite { width: 36px; height: 36px; } .stock-text { font-size: 14px; } .costs { gap: 4px 7px; font-size: 15px; } .board { height: 320px; } .commands { gap: 4px; } .commands button { font-size: 17px; } .commands button svg { width: 18px; } }
/* Keep the playfield and primary actions together at ordinary phone heights. */
@media (max-height: 1000px) {
  body[data-playing="true"] .header { padding: 4px 12px 0; }
  body[data-playing="true"] h1 { font-size: 18px; }
  body[data-playing="true"] .icon-button { min-height: 40px; height: 40px; width: 40px; padding: 8px; }
  body[data-playing="true"] .stock { padding-bottom: 4px; }
  body[data-playing="true"] .stock-item { padding: 2px; }
  body[data-playing="true"] .stock .sprite { width: 26px; height: 26px; }
  body[data-playing="true"] .stock-text { display: flex; align-items: baseline; gap: 4px; font-size: 13px; }
  body[data-playing="true"] .stock-text strong { display: inline; font-size: 17px; }
  body[data-playing="true"] .game-panel { padding-top: 4px; }
  body[data-playing="true"] .navigation button { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
  .puzzle-panel .game-heading { margin-bottom: 4px; align-items: center; }
  .puzzle-panel .game-heading h2 { font-size: 20px; }
  .puzzle-panel .rule { font-size: 14px; margin-top: 2px; }
  .puzzle-panel .next-piece { display: flex; align-items: center; gap: 3px; flex-basis: auto; padding: 2px 4px; font-size: 12px; }
  .puzzle-panel .next-piece .sprite { width: 32px; height: 32px; margin: 0; }
  .puzzle-panel .game-counts { font-size: 14px; margin-bottom: 0; }
  .puzzle-panel .game-counts b { font-size: 18px; }
  .puzzle-panel .balance-meter { margin: 4px 0 8px; }
  .puzzle-panel .balance-caption { font-size: 14px; margin-bottom: 4px; }
  .puzzle-panel .board { height: clamp(220px, calc(100dvh - 385px - env(safe-area-inset-bottom)), 350px); }
  body[data-guide="true"] .puzzle-panel .board { height: clamp(220px, calc(100dvh - 425px - env(safe-area-inset-bottom)), 350px); }
  .puzzle-panel .balance-info { font-size: 14px; line-height: 1.4; min-height: 20px; margin: 6px 0; }
  .puzzle-panel .drop-forecast { margin-top: 0; }
  .puzzle-panel .drop-controls button, .puzzle-panel .puzzle-tools button { min-height: 44px; padding-top: 7px; padding-bottom: 7px; }
  .puzzle-panel .puzzle-tools { margin-top: 6px; }
  .puzzle-panel .puzzle-guide { margin: 4px 0; }
  .rps-panel h2 { font-size: 21px; }
  .rps-panel .rps-opponent { margin: 2px 0; font-size: 14px; }
  .rps-panel .rps-match-rule { font-size: 14px; margin-bottom: 4px; }
  .rps-panel .rps-player .sprite { width: 96px; }
  .rps-panel .rps-result { min-height: 0; padding: 6px; margin: 6px 0; }
  .rps-panel .rps-result h3 { font-size: 24px; }
  .rps-panel .rps-result p { font-size: 14px; }
  .rps-panel .rps-reward { font-size: 14px; margin: 6px 0; }
  .rps-panel .battle-return { min-height: 44px; margin-top: 6px; padding: 7px; }
  .rps-panel .rps-rules { font-size: 14px; margin: 8px 0; text-align: left; }
  .rps-panel .rps-rules summary { cursor: pointer; padding: 6px 0; }
}
@media (max-height: 749px) {
  .puzzle-panel .rule { display: none; }
  .puzzle-panel .balance-meter { margin: 2px 0 6px; }
  .puzzle-panel .balance-info { margin: 4px 0; }
  .puzzle-panel .board { --piece-step: 34px; }
  .puzzle-panel .piece { max-width: 36px; }
  .puzzle-panel .beam-group { bottom: 66px; }
  .puzzle-panel .beam-art { height: 24px; }
  .puzzle-panel .pivot { width: 72px; height: 72px; }
  .puzzle-panel .board-column { bottom: 66px; }
  .rps-panel .rps-arena { padding: 4px; }
  .rps-panel .rps-player .sprite { width: 72px; }
  .rps-panel .rps-player strong, .rps-panel .rps-played-hand b { font-size: 15px; }
  .rps-panel .rps-player .rps-hand { font-size: 20px; margin: 0; }
  .rps-panel .rps-result h3 { font-size: 22px; }
  .rps-panel .rps-commands button { min-height: 44px; padding: 5px 2px; font-size: 15px; }
  .rps-panel .rps-commands .rps-hand { font-size: 20px; }
}
@media (max-height: 600px) {
  .puzzle-panel .board { height: clamp(160px, calc(100dvh - 385px - env(safe-area-inset-bottom)), 220px); --piece-step: 24px; }
  body[data-guide="true"] .puzzle-panel .board { height: clamp(144px, calc(100dvh - 425px - env(safe-area-inset-bottom)), 180px); }
  .puzzle-panel .piece { max-width: 28px; }
  .puzzle-panel .beam-group, .puzzle-panel .board-column { bottom: 48px; }
  .puzzle-panel .pivot { width: 54px; height: 54px; }
  .rps-panel .rps-player .sprite { width: 44px; }
  .rps-panel .rps-score b { font-size: 18px; }
  .rps-panel .rps-opponent { display: inline; font-size: 12px; }
  .rps-panel .rps-match-rule { display: inline; margin-left: 8px; font-size: 12px; }
  .rps-panel .rps-result { padding: 4px; margin: 4px 0; }
  .rps-panel .rps-result h3 { font-size: 20px; }
  .rps-panel .rps-result p { font-size: 13px; line-height: 1.4; }
  .rps-panel .rps-reward { font-size: 13px; margin: 4px 0; }
  .rps-panel .rps-commands button { flex-direction: row; }
}
@media (max-height: 600px) and (max-width: 340px) {
  body[data-playing="true"] .stock-item { gap: 3px; }
  body[data-playing="true"] .stock .sprite { width: 22px; height: 22px; }
  body[data-playing="true"] .stock-text { font-size: 12px; white-space: nowrap; flex-wrap: wrap; gap: 0 3px; }
  body[data-playing="true"] .stock-text strong { font-size: 16px; }
  body[data-playing="true"] .navigation button { font-size: 14px; gap: 4px; }
  body[data-playing="true"] .navigation button svg { width: 20px; height: 20px; }
  .puzzle-panel .game-heading h2 { font-size: 17px; }
  .puzzle-panel .next-piece .sprite { width: 26px; height: 26px; }
  .puzzle-panel .puzzle-tools button { font-size: 14px; padding-left: 2px; padding-right: 2px; }
  body[data-guide="true"] .puzzle-panel .board { min-height: 160px; }
}
@media (max-height: 480px) and (min-width: 560px) {
  body[data-playing="true"] .app { width: min(100%, 800px); margin: 0 auto; display: grid; grid-template-columns: 42% 58%; align-content: start; border-radius: 0; }
  body[data-playing="true"] .header { grid-column: 1; grid-row: 1; }
  body[data-playing="true"] .stock { grid-column: 2; grid-row: 1; align-self: center; padding: 4px 12px 4px 0; }
  body[data-playing="true"] .stock-text { flex-wrap: wrap; gap: 0 4px; }
  body[data-playing="true"] #save-warning, body[data-playing="true"] #main { grid-column: 1 / -1; }
  body[data-playing="true"] .navigation { width: min(100%, 800px); }
  .puzzle-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 12px; }
  .puzzle-panel .game-heading { grid-column: 2; grid-row: 1; margin-bottom: 0; }
  .puzzle-panel .game-heading h2 { font-size: 17px; }
  .puzzle-panel .game-counts { grid-column: 2; grid-row: 2; }
  .puzzle-panel .balance-meter { grid-column: 2; grid-row: 3; margin: 0; }
  .puzzle-panel .board, body[data-guide="true"] .puzzle-panel .board { grid-column: 1; grid-row: 1 / 7; height: calc(100dvh - 113px - env(safe-area-inset-bottom)); --piece-step: 34px; }
  .puzzle-panel .piece { max-width: 36px; }
  .puzzle-panel .beam-group, .puzzle-panel .board-column { bottom: 66px; }
  .puzzle-panel .pivot { width: 72px; height: 72px; }
  .puzzle-panel .balance-info { grid-column: 2; grid-row: 4; margin: 2px 0; }
  .puzzle-panel .drop-controls { grid-column: 2; grid-row: 5; }
  .puzzle-panel .puzzle-tools { grid-column: 2; grid-row: 6; }
  .puzzle-panel .puzzle-guide { grid-column: 1 / -1; grid-row: 7; }
  .puzzle-panel .puzzle-help { grid-column: 1 / -1; grid-row: 8; }
  .rps-panel .rps-player .sprite { width: 72px; }
}
body[data-fast="true"] .beam-group.rocking, body[data-fast="true"] .rocking .piece .sprite { animation-duration: .3s; }
/* Keep actions outside the scrolling field, including when a save warning grows. */
body[data-playing="true"] .app { display: flex; flex-direction: column; height: 100dvh; min-height: 0; margin: 0 auto; border-radius: 0; overflow: hidden; }
body[data-playing="true"] .header, body[data-playing="true"] .stock, body[data-playing="true"] .warning { flex: none; }
body[data-playing="true"] #main { display: flex; flex: 1; min-height: 0; padding-bottom: 0; overflow: hidden; }
body[data-playing="true"] .navigation { position: static; transform: none; flex: none; width: 100%; }
body[data-playing="true"] .game-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; padding: 4px 12px; }
.play-field { flex: 1; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; }
/* Keep magnified battle text readable; let the panel scroll if the controls cannot fit. */
body[data-playing="true"] .rps-panel { overflow: auto; overscroll-behavior: contain; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body[data-playing="true"] .battle-field { flex-shrink: 0; min-height: 44px; }
.puzzle-field { display: flex; flex-direction: column; }
.puzzle-field > :not(.board) { flex: none; }
body[data-playing="true"] .puzzle-field .board { flex: 1 0 140px; height: auto; min-height: 140px; max-height: 350px; container-type: size; --piece-step: clamp(12px, calc((100cqh - 80px) / 4), 34px); }
body[data-playing="true"] .puzzle-field .piece { max-width: clamp(20px, 15cqh, 44px); }
body[data-playing="true"] .puzzle-field .beam-group, body[data-playing="true"] .puzzle-field .board-column { bottom: 48px; }
body[data-playing="true"] .puzzle-field .pivot { width: 54px; height: 54px; }
body[data-playing="true"] .puzzle-field .beam-art { height: 24px; }
.play-controls { flex: none; padding-top: 6px; background: #fff; border-top: 1px solid var(--line); }
.play-controls .battle-return { width: 100%; }
.seesaw-advice { display: block; color: var(--teal); font-size: 13px; }
.rps-mode { color: var(--teal); font-size: 13px; text-align: center; margin: 2px 0 6px; }
.battle-mode-label { display: grid; gap: 4px; margin: 12px 0; font-size: 16px; }
.battle-mode-label select { width: 100%; min-height: 44px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.town-next { padding: 10px 16px; background: #edf7f1; border-bottom: 1px solid var(--line); }
.town-next p { font-size: 15px; line-height: 1.4; margin-bottom: 6px; }
.town-next button { width: 100%; min-height: 44px; font-size: 16px; padding: 8px; }
.robot-detail-note { padding: 8px 16px; font-size: 14px; color: var(--teal); background: #f2f6f5; }
.robot-sprite { position: relative; }
.robot-detail { position: absolute; width: 10%; height: 8%; border: 1px solid #6b4827; border-radius: 30%; background: linear-gradient(135deg, #f7d27c, #ae682c); box-shadow: 0 1px 2px #0008, inset 0 0 2px #fff8; }
.detail-0 { left: 46%; top: 43%; width: 8%; height: 8%; border-radius: 50%; background: #94fff1; box-shadow: 0 0 6px 2px #63e4db; }
.detail-1 { left: 42%; top: 53%; width: 16%; height: 7%; }
.detail-2 { left: 26%; top: 36%; transform: rotate(-15deg); }
.detail-3 { left: 65%; top: 36%; transform: rotate(15deg); }
.detail-4 { left: 21%; top: 54%; height: 12%; }
.detail-5 { left: 70%; top: 54%; height: 12%; }
.detail-6 { left: 33%; top: 73%; height: 12%; }
.detail-7 { left: 57%; top: 73%; height: 12%; }
.detail-8 { left: 66%; top: 23%; width: 8%; height: 12%; }
[data-robot-path="cool"] .robot-detail { border-radius: 0; border-color: #234c66; background: linear-gradient(135deg, #c6f2ff, #537b9c); }
[data-robot-path="cool"] .detail-0 { background: #b9f6ff; }
[data-robot-path="quirky"] .robot-detail { border-radius: 15% 45% 20% 35%; border-style: dashed; border-color: #513950; background: linear-gradient(135deg, #d1c1a1, #8b9e68); }
[data-robot-path="quirky"] .detail-0 { background: #f2e898; }
@media (max-height: 600px) {
  body[data-playing="true"] .warning { font-size: 13px; line-height: 1.4; padding: 6px; margin: 2px 12px 4px; }
  body[data-playing="true"] .puzzle-field .balance-meter { margin: 2px 0 6px; }
  body[data-playing="true"] .play-controls button { min-height: 44px; }
}
@media (max-height: 480px) and (min-width: 560px) {
  body[data-playing="true"] .app { display: grid; grid-template-columns: 42% 58%; grid-template-rows: auto auto minmax(0, 1fr) auto; }
  body[data-playing="true"] .header { grid-column: 1; grid-row: 1; }
  body[data-playing="true"] .stock { grid-column: 2; grid-row: 1; }
  body[data-playing="true"] #save-warning { grid-column: 1 / -1; grid-row: 2; }
  body[data-playing="true"] #main { grid-column: 1 / -1; grid-row: 3; }
  body[data-playing="true"] .navigation { grid-column: 1 / -1; grid-row: 4; }
  body[data-playing="true"] .puzzle-field, body[data-playing="true"] .battle-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 12px; }
  /* Let battle text keep its full height inside the scrolling field. */
  body[data-playing="true"] .battle-field { grid-template-rows: repeat(4, max-content); align-content: start; }
  body[data-playing="true"] .puzzle-field > .board { grid-column: 1; grid-row: 1 / 4; height: 100%; min-height: 120px; max-height: none; }
  .puzzle-context, .battle-context { grid-column: 2; grid-row: 1; }
  body[data-playing="true"] .puzzle-field .balance-info, .battle-field .rps-result { grid-column: 2; grid-row: 2; }
  body[data-playing="true"] .puzzle-field .puzzle-help, .battle-field .rps-reward { grid-column: 2; grid-row: 3; }
  .battle-field .rps-rules { grid-column: 2; grid-row: 4; }
  body[data-playing="true"] .battle-field .rps-arena { grid-column: 1; grid-row: 1 / 5; height: auto; align-self: start; }
  .play-controls .drop-controls, .play-controls .puzzle-tools { grid-column: auto; grid-row: auto; margin: 0; }
  .puzzle-panel .play-controls { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .rps-panel .play-controls { display: flex; gap: 12px; }
  .rps-panel .play-controls .commands { flex: 1; }
  .rps-panel .play-controls .battle-return { width: 40%; margin-top: 0; }
}
body[data-fast="true"] .piece.travelling { animation-duration: .275s; }
body[data-fast="true"] .piece.overboard { animation-duration: .5s; }
body[data-fast="true"] .piece.collected { animation-duration: .2s; }
body[data-fast="true"] .board.collapsing .piece { animation-duration: .525s; animation-delay: 0s; }
