* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; background: #020604; color: #effff1; font: 14px "Segoe UI", Arial, sans-serif; }
button, output { font-family: inherit; }
body { display: grid; place-items: center; }
.game-splash {
  position: relative;
  width: min(978px, 100vw, calc(100dvh * 978 / 584));
  aspect-ratio: 978 / 584;
}
.game-splash-poster { display: block; width: 100%; height: 100%; }
.game-splash .game-loading-start {
  bottom: 11.4%;
  width: 18%;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.game-splash .game-loading-start img { display: block; width: 100%; height: auto; }
.game-splash .game-loading-start:focus-visible { outline: 2px solid #e7ff99; outline-offset: 4px; }
.game-container[hidden] { display: none; }
.game-container { min-height: 100dvh; display: grid; place-items: center; }
.stage {
  width: min(978px, 100vw, calc(100dvh * 978 / 584));
  aspect-ratio: 978 / 584;
  display: grid;
  grid-template-columns: 197fr 584fr 197fr;
  overflow: hidden;
  container-type: inline-size;
}
.side-panel, .board-shell { position: relative; min-width: 0; background-size: 100% 100%; }
.left-panel { background-image: url("../assets/images/backgrounds/nexus-hud-left.webp"); }
.mine-radar {
  position: absolute;
  top: 19.6%;
  left: 52.7%;
  width: 61%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
}
.mine-radar::before, .mine-radar::after, .mine-radar span {
  content: "";
  position: absolute;
  inset: 0;
}
.mine-radar::before {
  border-radius: 50%;
  background: conic-gradient(transparent 0 75%, #82ff3300 77%, #8dff3955 98%, #caff97b0 99.5%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, transparent 74%, #000 78% 95%, transparent 99%);
  animation: radar-rotate 7s linear infinite;
}
.mine-radar::after {
  background: radial-gradient(circle, #bfff664d, #83ff2422 30%, transparent 53%);
  mix-blend-mode: screen;
  opacity: .4;
}
.mine-radar span {
  inset: 0 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c2ff80b3, transparent);
  box-shadow: 0 0 7px #8dff38b3;
  animation: radar-scan 4.8s linear infinite;
}
@keyframes radar-rotate { to { transform: rotate(1turn); } }
@keyframes radar-scan {
  from { top: 10%; }
  to { top: 90%; }
}
@media (prefers-reduced-motion: reduce) {
  .mine-radar::before, .mine-radar::after, .mine-radar span { display: none; }
}
.right-panel { background-image: url("../assets/images/backgrounds/nexus-hud-right.webp"); }
.flag-scanner {
  position: absolute;
  inset: 0 0 auto;
  height: 32%;
  overflow: hidden;
  pointer-events: none;
}
.flag-scanner::before, .flag-scanner::after {
  content: "";
  position: absolute;
  left: 17%;
  top: 57%;
  width: 65%;
  height: 13%;
  border: 1px solid #b9ff53a8;
  border-radius: 50%;
  box-shadow: inset 0 0 .35cqw #9aff37a6;
  animation: flag-scan-ring 4.8s ease-out infinite;
}
.flag-scanner::after { animation-delay: -2.4s; }
.flag-scanner i {
  position: absolute;
  left: 49%;
  top: 89%;
  width: .27cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d8ff86;
  box-shadow: 0 0 .45cqw #9bff28;
  animation: flag-scan-particle 4.2s ease-out infinite;
}
.flag-scanner i:nth-child(2) { left: 42%; animation-delay: -1.4s; }
.flag-scanner i:nth-child(3) { left: 57%; animation-delay: -2.8s; }
@keyframes flag-scan-ring {
  0% { transform: scale(.4); opacity: 0; }
  20% { opacity: .65; }
  82%, 100% { transform: scale(1.14); opacity: 0; }
}
@keyframes flag-scan-particle {
  0% { transform: translateY(0); opacity: 0; }
  24% { opacity: .65; }
  80%, 100% { transform: translateY(-4.2cqw); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .flag-scanner { display: none; }
}
.board-shell { background-image: url("../assets/images/backgrounds/nexus-minefield.webp"); }
.board { position: absolute; inset: 0; display: grid; grid-template: repeat(12, 1fr) / repeat(12, 1fr); gap: .48%; }
.digital-readout {
  position: absolute; left: 30%; width: 56%; height: 7.4%;
  display: grid; place-items: center;
  border-radius: 5px; background: #081009; color: #b6ff31;
  font: bold 3.45cqw/1 "Courier New", monospace;
  text-shadow: 0 0 .65cqw #70ff17;
}
.display-glyphs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .28cqw;
  width: 100%;
  height: 88%;
  filter: drop-shadow(0 0 .24cqw #87ff33);
}
.display-digit {
  position: relative;
  height: 100%;
  max-width: 17%;
  aspect-ratio: 4 / 7;
}
.segment { position: absolute; background: #9ee81919; }
.segment.lit { background: linear-gradient(135deg, #edff8b, #a3ff20 55%, #83db19); }
.segment-a, .segment-d, .segment-g {
  left: 15%; width: 70%; height: 11%;
  clip-path: polygon(14% 0, 86% 0, 100% 50%, 86% 100%, 14% 100%, 0 50%);
}
.segment-a { top: 0; }
.segment-g { top: 44.5%; }
.segment-d { bottom: 0; }
.segment-b, .segment-c, .segment-e, .segment-f {
  width: 19%; height: 41%;
  clip-path: polygon(50% 0, 100% 17%, 100% 83%, 50% 100%, 0 83%, 0 17%);
}
.segment-b, .segment-f { top: 5%; }
.segment-c, .segment-e { bottom: 5%; }
.segment-b, .segment-c { right: 0; }
.segment-e, .segment-f { left: 0; }
.display-colon {
  width: .48cqw; height: 60%;
  display: flex; flex-direction: column; justify-content: space-around;
}
.display-colon::before, .display-colon::after {
  content: ""; width: 100%; aspect-ratio: 1; background: #b9ff39;
}
#timer { top: 44.1%; }
#mine-count { top: 64%; height: 7.1%; }
.terrain-scanner {
  position: absolute;
  top: 76%;
  left: 10%;
  right: 8%;
  height: 12%;
  pointer-events: none;
  overflow: hidden;
  mask-image: radial-gradient(ellipse, #000 28%, transparent 78%);
}
.terrain-scanner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 27%, #92ff3228 47%, #c4ff6978 51%, #92ff3230 57%, transparent 72%);
  mix-blend-mode: screen;
  animation: terrain-scan 6s linear infinite;
}
@keyframes terrain-scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .terrain-scanner { display: none; }
}
.board-status {
  position: absolute;
  top: 87%;
  left: 9%;
  right: 9%;
  text-align: center;
  white-space: nowrap;
  color: #dcffb2;
  font: 750 1.16cqw/1.2 "Courier New", monospace;
  letter-spacing: .06em;
  text-shadow: 0 1px 3px #000, 0 0 .3cqw #76a33d;
  pointer-events: none;
}
.art-button {
  position: absolute; left: 9.45%; width: 81.1%; height: 6.7%;
  background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: .8cqw;
}
button:focus-visible { outline: .2cqw solid #fff; outline-offset: -.2cqw; }
/* Cover the wider controls printed on the panel behind the replacement buttons. */
.main-actions::before {
  content: "";
  position: absolute;
  inset: 38% 6.5% 28.8%;
  background: radial-gradient(ellipse at 50% 45%, #101c12 0%, #08120b 70%, #071009 100%);
  border-radius: .85cqw;
  pointer-events: none;
}
#new-game, #settings, #statistics {
  left: 50%;
  translate: -50% 0;
  width: calc(100cqw * 135 / 978);
  height: calc(100cqw * 40 / 978);
  background: #071009 var(--menu-image) center / var(--menu-image-scale, 104%) 108% no-repeat;
  clip-path: polygon(6% 0, 94% 0, 100% 23%, 100% 77%, 94% 100%, 6% 100%, 0 77%, 0 23%);
}
#settings, #statistics { --menu-image-scale: 107%; }
#new-game { top: 39.75%; --menu-image: url("../assets/images/ui/menu-new-game.webp"); }
#settings { top: 47.93%; --menu-image: url("../assets/images/ui/menu-settings.webp"); }
#statistics { top: 55.82%; --menu-image: url("../assets/images/ui/menu-stats.webp"); }
#mode-toggle, #flag-toggle, #sound-toggle {
  top: 77.27%;
  width: 22.8%;
  height: 8.26%;
  background: #060f08 var(--control-image) center / 100% 100% no-repeat;
}
#mode-toggle { left: 12%; --control-image: url("../assets/images/ui/control-reveal.webp"); }
#flag-toggle { left: 38%; --control-image: url("../assets/images/ui/control-flag.webp"); }
#sound-toggle { left: 64.2%; --control-image: url("../assets/images/ui/control-sound.webp"); }
.art-button[aria-pressed="false"] { filter: grayscale(1) brightness(.58); }
@media (hover: hover) {
  .art-button[aria-pressed="false"]:hover { filter: grayscale(.45) brightness(.83); }
}
.secondary-actions { position: absolute; top: 87%; left: 7%; right: 7%; display: flex; gap: .3cqw; }
.secondary-actions button {
  flex: 1; min-width: 0; padding: .4cqw 0; color: #ddffc9; border: 1px solid #547558;
  background: #15231b; cursor: pointer; border-radius: .25cqw; font-size: .95cqw;
}
@media (hover: hover) {
  #new-game:hover, #settings:hover, #statistics:hover { filter: brightness(1.15); }
  .art-button:hover, .secondary-actions button:hover {
    box-shadow: inset 0 0 0 .15cqw #b7ff3a, 0 0 .9cqw #82ff3f;
    background-color: #9cff2224;
  }
}
.board.shaking { animation:shake .34s linear 2; }
.board.win-ripple::after { content:""; position:absolute; z-index:20; inset:-5%; border:2px solid #77ff55; border-radius:50%; animation:ripple 1.1s ease-out forwards; pointer-events:none; }

.cell {
  position:relative;
  min-width:0;
  min-height:0;
  padding:0;
  border:1px solid #45b72e;
  border-radius:2px;
  color:#dfffe0;
  background:
    linear-gradient(135deg, rgba(95,255,66,.09), transparent 45%),
    linear-gradient(145deg,#1d3022,#07110b 72%);
  box-shadow:inset 0 0 4px rgba(117,255,88,.22),0 0 3px rgba(88,255,56,.25);
  cursor:pointer;
  font-family:"Courier New", monospace;
  font-weight:900;
  font-size:clamp(7px,1.35vw,17px);
  transition:border-color .12s, background .15s, filter .15s, transform .12s;
  overflow:hidden;
}
.cell:hover { border-color:#9fff75; filter:brightness(1.22); }
.cell:active { transform:scale(.94); }
.cell.flagged { background:radial-gradient(circle at 50% 45%,rgba(96,255,63,.3),transparent 38%),linear-gradient(145deg,#18371f,#07110b); }
.cell.flagged:not(.mine, .wrong)::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: url("../assets/images/tiles/placed-flag.webp") center 44% / 108% 118% no-repeat;
  clip-path: polygon(13% 0, 87% 0, 100% 14%, 100% 86%, 87% 100%, 13% 100%, 0 86%, 0 14%);
  animation: flag-in .22s ease-out;
}
#board { --mine-image: url("../assets/images/tiles/mine.webp"); --triggered-mine-image: url("../assets/images/tiles/mine-triggered.webp"); }
.cell.mine { background: #142219; border-color: #82b66e; }
.cell.mine::before {
  content: "";
  position: absolute;
  inset: 5%;
  background: var(--mine-image) center / contain no-repeat;
  animation: none;
}
.cell.mine.triggered::before {
  background-image: var(--triggered-mine-image);
  border-radius: 12%;
}
.cell.triggered { background:radial-gradient(circle,#fff 0 5%,#ffb24a 8%,#ff3a35 20%,#77151d 48%,#090909 72%); border-color:#ff6969; box-shadow:0 0 13px #ff3434; animation:explode .5s ease-out; }
.cell.mine:not(.flagged)::after, .cell.mine.triggered::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 16%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 16%, #d5ff91 36%, #9bff39 58%, transparent 75%);
  box-shadow: 0 0 .45cqw #8eff40;
  pointer-events: none;
  animation: mine-beacon 1.5s linear infinite;
}
.cell.mine.triggered::after {
  background: radial-gradient(circle, #fff 0 16%, #ffb5a5 36%, #ff422b 58%, transparent 75%);
  box-shadow: 0 0 .5cqw #ff3923;
}
@keyframes mine-beacon {
  0%, 12% { opacity: 1; }
  20%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .cell.mine:not(.flagged)::after, .cell.mine.triggered::after { animation: none; }
}
.cell.wrong { background:#43272a; border-color:#ff4c58; }
.cell.wrong::before { content:"×"; color:#ff626b; font-size:clamp(11px,1.7vw,21px); text-shadow:0 0 8px #ff2d38; }
.n1 { color:#73eaff; } .n2 { color:#76ff73; } .n3 { color:#ffd85a; } .n4 { color:#a894ff; }
.n5 { color:#ff925d; } .n6 { color:#58ffd1; } .n7 { color:#f6efff; } .n8 { color:#ff7a91; }


/* The artwork supplies closed tiles. Game states are drawn over their original hit targets. */
.cell { background: transparent; border: 1px solid transparent; box-shadow: none; font-size: 2.2cqw; }
.cell:hover { background-color: #bbff3a27; }
.cell.revealed { background: #fff; border-color: #cbd7ce; color: #26342b; }
.cell.revealed.n1 { color: #00578a; } .cell.revealed.n2 { color: #21642e; }
.cell.revealed.n3 { color: #9b3821; } .cell.revealed.n4 { color: #53388c; }
.cell.revealed.n5 { color: #8d430a; } .cell.revealed.n6 { color: #00645e; }
.cell.revealed.n7 { color: #292e34; } .cell.revealed.n8 { color: #922d58; }
.cell.flagged { background: #61a82435; }
.cell.wrong::before { font-size: 2.1cqw; }
.modal { width:min(460px,90vw); max-height:80vh; padding:0; border:1px solid #72cf60; border-radius:7px; color:#efffee; background:#09110d; box-shadow:0 0 35px rgba(74,255,57,.28); }
.modal::backdrop { background:rgba(0,5,2,.78); backdrop-filter:blur(3px); }
.modal-card { margin:0; }
.modal-header { height:48px; display:flex; align-items:center; justify-content:space-between; padding:0 16px; border-bottom:1px solid #53615a; background:linear-gradient(90deg,#17261d,#0a100d); }
.modal-header strong { letter-spacing:3px; }
.modal-close { margin-left:auto; width:28px; height:28px; border:1px solid #65736b; border-radius:3px; color:#cfffd1; background:#111915; cursor:pointer; }
.modal-content { padding:16px; font-size:13px; line-height:1.55; max-height:60vh; overflow:auto; }
.stage-options {
  position: absolute;
  top: 63.64%;
  left: 50%;
  translate: -50% 0;
  width: calc(100cqw * 135 / 978);
  height: calc(100cqw * 40 / 978);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .32cqw;
}
.stage-options button {
  min-width: 0;
  padding: 0;
  border: 1px solid #587657;
  border-radius: .35cqw;
  color: #efffee;
  background: linear-gradient(#263d28, #0c170f);
  cursor: pointer;
  font: bold 1.5cqw "Courier New", monospace;
}
.stage-options button[aria-current="true"] { border-color: #b7ff55; color: #d9ff9b; }
.stage-options button:hover { background: #2c4529; border-color: #b7ff55; }
.setting-row { display:flex; justify-content:space-between; align-items:center; margin:10px 0; }
.setting-row input { accent-color:#70ff56; }
.stat-row { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px solid rgba(180,220,190,.12); }

.toast { position:fixed; z-index:100; left:50%; bottom:5%; transform:translate(-50%,20px); padding:8px 14px; border:1px solid #76ff58; border-radius:4px; background:#0b1710; color:#dffff0; opacity:0; pointer-events:none; transition:.2s; }
.toast.visible { opacity:1; transform:translate(-50%,0); }

@keyframes spin { to { transform:rotate(360deg); } }
@keyframes flag-in { from { opacity:0; transform:translateY(-10px) scale(.6); } }
@keyframes explode { 35% { transform:scale(1.18); } }
@keyframes shake { 25% { transform:translateX(-3px); } 50% { transform:translateX(3px); } 75% { transform:translateX(-2px); } }
@keyframes ripple { from { transform:scale(.15); opacity:1; } to { transform:scale(1.3); opacity:0; } }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
