:root { font-family: system-ui, sans-serif; color: #173435; background: #edf3ed; }
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 760px; padding: 24px; margin: auto; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 900; letter-spacing: -.05em; text-transform: uppercase; }
h2 { font-size: 1.3rem; }
p { line-height: 1.5; }
.eyebrow { color: #527d73; text-transform: uppercase; font-weight: 800; letter-spacing: .12em; font-size: .75rem; }
#setup { background: #dcece0; padding: 18px 22px 22px; border-radius: 18px; margin-top: 20px; }
.size-picker { display: block; margin: 16px 0; }
select, button { font: inherit; border: 1px solid #97bdb1; border-radius: 10px; background: #fff; color: #234b43; padding: 9px 15px; }
button { cursor: pointer; font-weight: 700; }
button:hover { background: #e1f4eb; }
button:focus-visible, select:focus-visible { outline: 3px solid #1b7150; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: default; }
.board { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); width: min(100%, 620px); border: 5px solid #2f5b53; border-radius: 13px; overflow: hidden; background: #cfe5c7; box-shadow: 0 5px 0 #b5d2bd; }
.tile { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; background: linear-gradient(135deg,#dcefd4,#c8e2be); border: 1px solid #b8d0b7; }
.wall { background: linear-gradient(145deg,#63958c,#315d56 70%,#23443f); border: 2px solid #294e49; border-radius: 18%; box-shadow: inset 1px 2px 0 #92bfb1, inset 0 -4px 0 #21413b; }
.block { background: linear-gradient(135deg,#ffc166,#f39a48 48%,#c76727); border: 2px solid #b75c20; border-radius: 14%; box-shadow: inset 1px 2px 0 #ffdb83, inset 0 -3px 0 #b95f24; }
.block::after { content: ''; position: absolute; inset: 16%; background: linear-gradient(45deg,transparent 43%,#be692d 44% 53%,transparent 54%),linear-gradient(-45deg,transparent 43%,#be692d 44% 53%,transparent 54%); }
.player { --body: #22b9ec; --shade: #087caf; position: relative; z-index: 3; width: 69%; height: 72%; border-radius: 48% 48% 37% 37%; background: radial-gradient(ellipse at 30% 18%,#fff9 0 12%,transparent 13%),linear-gradient(145deg,var(--body) 30%,var(--shade)); border: 2px solid var(--shade); box-shadow: inset 0 -3px 0 #0003,0 2px 2px #153c3a77; }
.player-2 { --body: #f77369; --shade: #b73939; }
.visor { position: absolute; top: 26%; left: 12%; width: 76%; height: 43%; border-radius: 35%; background: #103942; border: 1px solid #16343a; }
.visor::before,.visor::after { content: ''; position: absolute; top: 22%; width: 19%; height: 57%; border-radius: 50%; background: #bcffff; }
.visor::before { left: 20%; } .visor::after { right: 20%; }
.player-label { position: absolute; bottom: -30%; left: 50%; transform: translateX(-50%); color: #183d3a; font: 800 clamp(6px,1.3vw,10px)/1 system-ui; text-shadow: 0 1px #fff; }
.enemy { position: relative; z-index: 2; width: 72%; height: 65%; border-radius: 50% 50% 32% 32%; background: radial-gradient(ellipse at 30% 20%,#e8ffb0 0 12%,transparent 13%),linear-gradient(#a7ec55,#61b936); border: 2px solid #4d9b2e; box-shadow: inset 0 -3px 0 #32812988; }
.enemy::after { content: '••'; position: absolute; inset: 20% 0 0; text-align: center; color: #183c30; font: bold clamp(7px,2vw,16px)/1 system-ui; letter-spacing: 1px; }
.bomb { position: absolute; z-index: 2; width: 65%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 30% 24%,#8ca0a8 0 12%,transparent 13%),linear-gradient(145deg,#596977,#202b37 70%); border: 2px solid #182833; box-shadow: 0 2px 1px #21413b66; }
.bomb::after { content: '✦'; position: absolute; right: -14%; top: -45%; color: #ffb128; font-size: clamp(10px,2vw,18px); text-shadow: 0 0 3px #f45b10; }
.flame { background: radial-gradient(circle,#fffbd7 0 18%,#ffeb63 25% 48%,#ff9b22 68%,#e75b18 85%); border-color: #f48020; }
.status { color: #536e63; font-size: .95rem; }
.controls { text-align: center; width: min(100%, 220px); margin: 16px 0; }
.controls button { min-width: 55px; margin: 2px; font-size: 1.1rem; }
.note { color: #536e63; font-size: .9rem; }
.defeat:not([hidden]), .victory:not([hidden]) { display: flex; flex-direction: column; gap: 4px; width: min(100%, 620px); padding: 14px 16px; border: 1px solid #6b9a73; border-radius: 10px; background: #e5f6e8; color: #23532d; }
.defeat:not([hidden]) { border-color: #c57c65; background: #fff0e9; color: #762d22; }
.defeat strong, .victory strong { font-size: 1.25rem; }
[hidden] { display: none !important; }

.enemy-hunter { border-radius: 30% 30% 40% 40%; background: linear-gradient(#ff9182, #dc4e45); border-color: #a53637; }
.enemy-hunter::after { content: '▼▼'; color: #ffe96e; font-size: clamp(6px,1.4vw,12px); }
.enemy-ambush { border-radius: 50% 50% 20% 20%; background: linear-gradient(#eed5ff,#9f79db); border-color: #7450a3; }
.enemy-ambush::after { color: #302458; }

/* Держим результат и действия рядом с полем на невысоком экране. */
main { padding-top: 12px; padding-bottom: 12px; }
.eyebrow { margin: 0 0 2px; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.1; }
#instructions { margin: 8px 0; }
.status { margin: 5px 0; }
.board { width: min(100%, 620px, calc((100dvh - 290px) * var(--columns) / var(--rows))); min-width: min(100%, 260px); }
.controls { margin: 5px 0; }
.controls button { padding: 4px 12px; line-height: 1.1; }
.note { margin: 7px 0; }
.defeat:not([hidden]), .victory:not([hidden]) { padding: 7px 12px; margin-bottom: 7px; }
@media (max-width: 500px) { main { padding: 12px; } .board { width: 100%; } }

.status { height: 2.5em; display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 650; }
.status.finished { color: #a33b32; }

@keyframes bomb-pulse { 0%, 100% { transform: scale(.88); } 50% { transform: scale(1.05); } }
.bomb { animation: bomb-pulse .7s ease-in-out infinite; }
@keyframes enemy-death { 0% { transform: scale(1); opacity: 1; } 35% { transform: scale(1.2); opacity: 1; filter: brightness(1.8); } 100% { transform: scale(.15) rotate(25deg); opacity: 0; } }
.enemy-dying { animation: enemy-death .5s ease-out forwards; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .bomb { animation: none; } .enemy-dying { animation-duration: .01ms; } }

.editor-board { margin: 12px 0; }
.editor-tile { width: 100%; height: 100%; padding: 0; min-width: 0; border-radius: 0; font-weight: 800; }
.editor-tile.wall, .editor-tile.block { border-radius: 14%; }
.editor-marker { position: relative; z-index: 2; padding: 1px 2px; border-radius: 4px; background: #fffde7; color: #183d3a; font-size: clamp(8px, 1.5vw, 13px); }
#editor-message, #setup-message { color: #9b3f2d; min-height: 1.5em; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; max-width: 620px; margin: 10px 0; }
.palette-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 65px; padding: 6px; font-size: .67rem; line-height: 1.1; }
.palette-tool[aria-pressed="true"] { border-color: #157c70; background: #ccece3; box-shadow: 0 0 0 2px #157c70; }
.palette-icon { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 6px; border: 2px solid #8cae9d; background: #d8eccf; color: #203f38; font-weight: 900; font-size: 15px; }
.icon-wall { background: #3f7169; border-color: #294e49; }
.icon-crate { background: #f39a48; border-color: #b75c20; color: #9b4e20; font-size: 22px; }
.icon-p1,.icon-p2,.icon-random,.icon-hunter,.icon-ambush { border-radius: 50%; }
.icon-p1 { background: #22b9ec; border-color: #087caf; } .icon-p2 { background: #f77369; border-color: #b73939; }
.icon-random { background: #a7ec55; border-color: #4d9b2e; } .icon-hunter { background: #ff9182; border-color: #a53637; } .icon-ambush { background: #d3adf5; border-color: #7450a3; }
.icon-erase { background: #f5f3ee; color: #8a4a38; border-color: #d1bbb0; }
