@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&family=Rubik:wght@400;500;600;700&display=swap');
:root{font-family:Rubik,system-ui,sans-serif;color:#fef9eb;background:#102d2e;font-synthesis:none;--ink:#153f40;--cream:#fff4db;--gold:#f8c96e;--orange:#f28c50;--mint:#add7ad}
*{box-sizing:border-box}
html,body{margin:0;min-width:300px;min-height:100%;overscroll-behavior:none}
body{background:radial-gradient(circle at 50% 12%,#4b8474 0,#214c49 40%,#112c30 100%);-webkit-tap-highlight-color:transparent}
button{font:inherit;cursor:pointer;border:0}
button:focus-visible{outline:3px solid #fff3ab;outline-offset:2px}
button:disabled{cursor:default}
.app{min-height:100dvh;display:flex;justify-content:center}
.shell{position:relative;width:min(100%,480px);min-height:100dvh;overflow:hidden;background:#e5d4a8;box-shadow:0 15px 70px #061d2099}
.shell.playing{display:flex;flex-direction:column;background:#174645}
.home{min-height:100dvh;position:relative;display:flex;flex-direction:column;justify-content:flex-end;padding:30px 22px calc(26px + env(safe-area-inset-bottom));background:url('assets/Карта маршрута.png') 22% center/auto 100% no-repeat}
.home::before{content:'';position:absolute;inset:0;background:linear-gradient(180deg,#143b42a8 0%,#17394012 32%,#102e32c9 67%,#102d2df7 100%)}
.home>*{position:relative}
.home-top{position:absolute;top:calc(28px + env(safe-area-inset-top));left:22px;right:22px;text-align:center;text-shadow:0 3px 12px #163635a3}
.chapter-tag{display:inline-block;color:#fff1c9;font-size:11px;font-weight:800;letter-spacing:.22em;text-transform:uppercase}
.home h1{font-family:Nunito,system-ui,sans-serif;font-weight:900;font-size:clamp(36px,11vw,58px);line-height:.98;letter-spacing:-.045em;margin:12px auto;max-width:370px;text-wrap:balance}
.home h1 span{color:#ffe099}
.home-bottom{display:grid;gap:15px}
.home-copy{font-size:14px;line-height:1.5;color:#edf7e6;max-width:340px;margin:0}
.chapter-label{font-size:11px;text-transform:uppercase;letter-spacing:.17em;font-weight:700;color:#f9d18a}
.primary,.secondary,.small-button{min-height:48px;border-radius:13px;font-weight:800;transition:transform .15s,filter .15s}
.primary{background:linear-gradient(#ffd27b,#f6ad4c);color:#53341d;box-shadow:0 4px 0 #ae6b2b,0 8px 18px #0b202466;font-family:Nunito,sans-serif;font-size:17px}
.primary:active,.secondary:active,.small-button:active{transform:translateY(2px);filter:brightness(.95)}
.secondary{background:#f6ead3;color:#27514b;box-shadow:0 3px 0 #a79877}
.home-actions{display:grid;grid-template-columns:1fr auto;gap:10px}
.home-actions .secondary{padding:0 17px}
.topbar{flex:none;padding:calc(8px + env(safe-area-inset-top)) 12px 7px;display:flex;align-items:center;justify-content:space-between;gap:8px;background:#153d3c}
.topbar-title{min-width:0;flex:1;text-align:center}
.topbar-title small{display:block;color:#b8dfca;font-size:10px;font-weight:700;letter-spacing:.1em;text-transform:uppercase}
.topbar-title strong{display:block;font-family:Nunito,sans-serif;font-size:17px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.icon-button{width:40px;height:40px;flex:none;border-radius:11px;background:#315c55;color:#fff6dd;font-size:21px;display:grid;place-items:center}
.game-scene{position:relative;height:clamp(72px,13dvh,120px);flex:none;overflow:hidden;background:url('assets/Карта маршрута.png') 22% 72%/cover}
.game-scene.investigation{background-position:64% 60%;filter:saturate(.88)}
.game-scene::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#123c3b88,transparent 55%),linear-gradient(0deg,#173f3e80,transparent 60%)}
.scene-label{position:absolute;z-index:1;left:14px;bottom:9px;color:white;font-size:11px;letter-spacing:.1em;font-weight:800;text-transform:uppercase;text-shadow:0 2px 6px #163c33}
.scene-bubble{position:absolute;z-index:1;right:12px;bottom:8px;color:#f9edcb;background:#143f3de8;padding:6px 10px;border-radius:9px;font-size:11px;font-weight:700}
.track-progress{position:absolute;z-index:1;left:0;right:0;bottom:0;height:3px;background:#ffffff55}
.track-progress span{height:100%;display:block;background:#ffd27b;transition:width .4s}
.play-area{flex:1;display:flex;flex-direction:column;align-items:center;padding:8px 10px calc(10px + env(safe-area-inset-bottom));gap:7px;background:linear-gradient(#245950,#193f3e)}
.goals{display:flex;align-items:center;gap:6px;width:100%;max-width:424px}
.goal{min-width:0;flex:1;display:flex;align-items:center;gap:6px;background:#103d3bd9;border:1px solid #76ad96;padding:5px 7px;border-radius:10px;min-height:48px}
.goal .mini-item{width:32px;height:32px;flex:none}
.goal-text{font-family:Nunito,sans-serif;font-weight:900;line-height:1.05;font-size:16px}
.goal-text small{display:block;font-family:Rubik,sans-serif;font-size:9px;line-height:1.3;color:#b9d9c2;font-weight:600}
.moves{width:54px;min-width:54px;min-height:48px;display:grid;align-content:center;text-align:center;background:#edbe69;border:2px solid #ffe7b0;color:#49351e;border-radius:10px;box-shadow:inset 0 -3px #c4954f}
.moves strong{font-family:Nunito,sans-serif;font-size:21px;line-height:1}
.moves small{font-size:9px;font-weight:800;text-transform:uppercase}
.board-wrap{width:100%;max-width:424px;position:relative;padding:7px;border:2px solid #d6ab6f;border-radius:14px;background:#9c6c47;box-shadow:0 5px 0 #533f30,0 9px 20px #0c272b80,inset 0 1px #ffdb9d}
.board{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:3px;touch-action:none;user-select:none;-webkit-user-select:none}
.tile{position:relative;aspect-ratio:1;padding:0;min-width:0;border-radius:6px;background:linear-gradient(145deg,#4f8170,#3d6e62);box-shadow:inset 0 1px 2px #b2dac25c,inset 0 -2px 3px #1c4948;transition:transform .15s,filter .15s;touch-action:none}
.tile:nth-child(16n+2),.tile:nth-child(16n+4),.tile:nth-child(16n+6),.tile:nth-child(16n+8),.tile:nth-child(16n+9),.tile:nth-child(16n+11),.tile:nth-child(16n+13),.tile:nth-child(16n+15){background:linear-gradient(145deg,#48796b,#37685d)}
.tile.selected{outline:3px solid #fff4a0;z-index:2;transform:scale(1.06)}
.tile.targeted{outline:3px solid #ffde76;z-index:1}
.tile.hint{animation:hint 1s ease-in-out infinite}
.tile.marked .item{animation:pop .2s ease-in forwards}
.tile.marked{background:#f4d888}
.tile.dropping .item{animation:drop .23s cubic-bezier(.2,.8,.3,1)}
.tile.special-tile{background:radial-gradient(circle,#ffe69f 0,#eaa958 45%,#9f663c 100%);box-shadow:inset 0 0 0 2px #ffdc8a,0 0 8px #ffca5f}
.tile .bonus-symbol{position:absolute;right:1px;bottom:0;z-index:2;color:#fff9db;background:#704a31d9;font-size:clamp(9px,2.5vw,13px);line-height:1;border-radius:5px;padding:1px 3px;font-weight:900}
.item,.mini-item{display:block;width:100%;height:100%;background-image:url('assets/Предметы.png');background-size:300% 200%;background-repeat:no-repeat;filter:drop-shadow(0 2px 2px #1b342b7a)}
.item.water,.mini-item.water{background-position:0% 0%}
.item.valve,.mini-item.valve{background-position:50% 0%}
.item.pipe,.mini-item.pipe{background-position:100% 0%}
.item.spring,.mini-item.spring{background-position:0% 100%}
.item.float,.mini-item.float{background-position:50% 100%}
.item.lamp,.mini-item.lamp{background-position:100% 100%}
.item.loupe,.mini-item.loupe{background-image:url('assets/Лупа.png');background-size:contain;background-position:center}
.hero-strip{width:100%;max-width:424px;display:flex;gap:6px;justify-content:center}
.hero-button{flex:1;max-width:120px;min-width:0;min-height:44px;background:#123d3a;color:#e3f0db;border:1px solid #6ba18b;border-radius:10px;padding:5px 6px;text-align:left}
.hero-button.ready{background:#f3d390;color:#504021;border-color:#ffedb0;box-shadow:0 0 12px #ffdf7a80}
.hero-button:disabled{opacity:.72}
.hero-line{display:flex;align-items:center;justify-content:space-between;gap:3px;font-size:10px;font-weight:800}
.hero-identity{display:flex;min-width:0;align-items:center;gap:3px}
.hero-line .mini-item{width:18px;height:18px;flex:none}
.hero-line span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.meter{height:4px;background:#1d6560;border-radius:4px;margin-top:4px;overflow:hidden}
.meter span{display:block;height:100%;background:#a9e1ab;transition:width .3s}
.ready .meter{background:#ba9960}.ready .meter span{background:#e98048}
.helper{min-height:24px;max-width:420px;width:100%;color:#e5f3dc;text-align:center;font-size:11px;line-height:1.3}
.tools{display:flex;gap:10px;justify-content:center;width:100%}
.tool-button{background:transparent;color:#d6e7d0;font-size:11px;text-decoration:underline;text-underline-offset:3px;padding:4px 10px;min-height:40px}
.overlay{position:absolute;z-index:10;inset:0;display:flex;flex-direction:column;justify-content:flex-end;background:#0a262b99}
.overlay.center{justify-content:center;padding:18px}
.sheet{background:#fff5de;color:#28443c;border-radius:23px 23px 0 0;padding:17px 18px calc(18px + env(safe-area-inset-bottom));box-shadow:0 -10px 40px #092d2c44;max-height:82dvh;overflow:auto}
.center .sheet{border-radius:20px;padding:22px;max-height:80dvh}
.sheet h2{font-family:Nunito,sans-serif;font-size:25px;line-height:1.08;margin:3px 0 9px;color:#174b47}
.sheet p{font-size:14px;line-height:1.5;margin:0 0 14px}
.sheet .primary,.sheet .secondary{width:100%}
.sheet-actions{display:grid;gap:10px;margin-top:16px}
.eyebrow{color:#a66a3c;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.14em}
.dialog-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.portrait{width:55px;height:55px;border-radius:50%;flex:none;background-color:#eedec1;background-image:url('assets/Персонажи.png');background-size:700% auto;background-repeat:no-repeat;border:2px solid #b68454}
.portrait.Мира{background-position:9% 3%}.portrait.Иво{background-position:36% 0%}.portrait.Ряска{background-position:55% 100%}.portrait.Агата{background-position:91% 3%}
.portrait.Холмс{background-image:url('assets/Холмс.png');background-size:300% auto;background-position:center 3%}
.portrait.Дуня,.portrait.Никанор,.portrait.Варя{background-image:url('assets/Горожане.png');background-size:300% 100%}
.portrait.Дуня{background-position:0% 0%}.portrait.Никанор{background-position:50% 0%}.portrait.Варя{background-position:100% 0%}
.speaker-name{font-family:Nunito,sans-serif;font-weight:900;font-size:18px;color:#265449}
.dialog-text{background:white;border:1px solid #e4d2ae;border-radius:4px 16px 16px 16px;padding:14px;min-height:66px;font-size:15px;line-height:1.42;color:#28443c;margin-bottom:12px}
.dialog-controls{display:flex;align-items:center;gap:12px}
.dialog-controls .primary{flex:1}
.dialog-count{font-size:12px;color:#7d8a71;white-space:nowrap}
.level-list{display:grid;gap:6px;margin:12px 0}
.level-entry{min-height:46px;text-align:left;border-radius:9px;background:#f2e6cf;color:#2b5148;padding:9px 11px;display:flex;justify-content:space-between;gap:8px}
.level-entry:disabled{opacity:.45}
.level-entry small{color:#856d50}
.journal-entry{border-top:1px solid #dfd0b4;padding:11px 0}
.journal-entry strong{font-family:Nunito,sans-serif;color:#31554c}
.journal-entry p{margin:4px 0;font-size:13px}
.choice-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.choice{min-height:65px;background:#dfedda;border:1px solid #abc9a8;border-radius:10px;color:#274c42;font-size:11px;font-weight:700;padding:5px}
.choice .mini-item{width:36px;height:36px;margin:auto}
.toast{position:absolute;z-index:9;top:32%;left:50%;transform:translateX(-50%);padding:9px 15px;border-radius:20px;background:#fff5daf2;color:#345447;box-shadow:0 3px 12px #173d3940;white-space:nowrap;font-size:12px;font-weight:800;pointer-events:none;animation:toast 1.6s forwards}
.finish-art{height:170px;margin:-22px -22px 16px;background:url('assets/Карта маршрута.png') 18% 28%/cover}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@keyframes pop{to{transform:scale(.25) rotate(14deg);opacity:0}}
@keyframes drop{from{transform:translateY(-17%) scale(.94);opacity:.6}to{transform:translateY(0) scale(1);opacity:1}}
@keyframes hint{50%{transform:scale(.86);filter:brightness(1.35)}}
@keyframes toast{0%{opacity:0;transform:translate(-50%,8px)}12%,75%{opacity:1;transform:translate(-50%,0)}100%{opacity:0;transform:translate(-50%,-8px)}}
@media(max-height:720px){.game-scene{height:56px}.play-area{gap:4px;padding-top:5px}.goal{min-height:42px}.moves{min-height:42px}.hero-button{padding:4px}.helper{min-height:18px;font-size:10px}.board-wrap{max-width:min(390px,calc(100dvh - 235px))}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important}}
