:root {
  --bg: #07061a;
  --bg2: #2b1560;
  --panel: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.14);
  --frame: #3b2a7a;
  --text: #fff7e6;
  --muted: #a99cd6;
  --yellow: #ffe600;
  --yellow-dark: #b08900;
  --pink: #ff2d95;
  --cyan: #2de2ff;
  --red: #ff3b3b;
  --red-dark: #8a0a1c;
  --grass: #46a546;
  --grass-dark: #2b7a2b;
  --dirt: #3a2315;
  --dirt-light: #7a5233;
  --arcade: 'Press Start 2P', Impact, 'Arial Black', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(rgba(255, 255, 255, .06) 1px, transparent 1.6px) 0 0 / 22px 22px,
    radial-gradient(ellipse at 50% -20%, var(--bg2), var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* CRT feel: faint scanlines + vignette. Never blocks input. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .55) 100%);
}
#app { height: 100%; }

.screen {
  display: none;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
}
.screen.active { display: flex; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--arcade);
  font-size: .8rem;
  line-height: 1;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-block;
  border: 0;
  border-radius: 14px;
  padding: 16px 30px;
  color: #fff;
  background: linear-gradient(#ff7a7a, var(--red) 45%, #d0102a);
  box-shadow: 0 7px 0 var(--red-dark), 0 0 24px rgba(255, 59, 59, .45), inset 0 2px 0 rgba(255, 255, 255, .45);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .55);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.btn:active {
  transform: translateY(6px);
  box-shadow: 0 1px 0 var(--red-dark), 0 0 24px rgba(255, 59, 59, .45), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.btn-big { font-size: clamp(.9rem, 3.4vw, 1.25rem); padding: 20px 44px; }
.btn[hidden] { display: none; }
.btn-link {
  font-family: var(--arcade);
  font-size: .6rem;
  line-height: 1.4;
  color: var(--cyan);
  text-decoration: none;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 2px solid transparent;
  border-radius: 10px;
}
.btn-link:hover, .btn-link:focus-visible { border-color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
.btn-icon {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 80;
  font: inherit;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, .5);
  border: 2px solid var(--frame);
  border-radius: 10px;
  color: var(--text);
  padding: 4px 8px;
  cursor: pointer;
}
.error { color: var(--red); margin: 0; min-height: 1.2em; }
.links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* ---------- Arcade typography ---------- */
.title {
  font-family: var(--arcade);
  font-size: clamp(1.3rem, 6.4vw, 3.4rem);
  line-height: 1.3;
  margin: 0;
  color: var(--yellow);
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow: .08em .08em 0 var(--pink), .16em .16em 0 #1b0f3d, 0 0 .6em rgba(255, 230, 0, .45);
  animation: glow 1.4s ease-in-out infinite alternate;
}
.title-small { font-size: clamp(1rem, 5vw, 2.2rem); }
.tagline {
  margin: 0;
  font-family: var(--arcade);
  font-size: clamp(.5rem, 2.1vw, .75rem);
  line-height: 1.6;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(45, 226, 255, .6);
}
.blink { animation: blink 1.1s steps(2, start) infinite; }

/* ---------- Start screen ---------- */
.rules { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rule {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}
.rule .pts { font-family: var(--arcade); font-size: .9rem; color: var(--yellow); text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }
.rule.boss { border-color: rgba(255, 45, 149, .5); }
.rule.boss .pts { color: var(--pink); }
.boss-preview { display: flex; gap: 16px; align-items: flex-end; min-height: 20px; }
.boss-preview img {
  height: 120px;
  width: auto;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5));
  animation: wiggle .25s infinite alternate;
}
.boss-preview img:nth-child(2) { animation-delay: .12s; }

#start-form { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(100%, 440px); }
#start-form label { font-family: var(--arcade); font-size: .6rem; color: var(--yellow); }
#player-name {
  font: inherit;
  font-size: 1.3rem;
  text-align: center;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--frame);
  background: rgba(0, 0, 0, .45);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .6);
}
#player-name:focus { border-color: var(--cyan); box-shadow: inset 0 2px 8px rgba(0, 0, 0, .6), 0 0 14px rgba(45, 226, 255, .4); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-height: 22vh; overflow-y: auto; }
.chip {
  font: inherit;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.chip:hover, .chip:focus-visible { border-color: var(--cyan); background: rgba(45, 226, 255, .1); }
.chip-best { font-family: var(--arcade); font-size: .5rem; color: var(--yellow); }
.chips-empty { color: var(--muted); font-size: .9rem; }

/* ---------- Game screen ---------- */
#screen-game { justify-content: flex-start; gap: 12px; padding: 10px; }
.hud {
  width: min(100%, 1000px);
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 8px 14px 10px;
  border-radius: 14px;
  background: linear-gradient(#141033, #0b0a22);
  border: 2px solid var(--frame);
  box-shadow: 0 0 0 2px #0b0a22, 0 0 18px rgba(45, 226, 255, .15);
  font-family: var(--arcade);
}
.hud-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hud-label { font-size: clamp(.4rem, 1.8vw, .55rem); color: var(--cyan); text-transform: uppercase; }
.hud-value { font-size: clamp(.75rem, 3.2vw, 1.1rem); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-player { text-align: left; }
.hud-score, .hud-hi { text-align: center; }
.hud-score .hud-value {
  font-size: clamp(1.1rem, 4.6vw, 1.7rem);
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--yellow-dark), 0 0 12px rgba(255, 230, 0, .6);
}
.hud-hi .hud-value { color: var(--pink); text-shadow: 0 0 10px rgba(255, 45, 149, .5); }
.hud-hi.beaten .hud-value { animation: blink .6s steps(2, start) infinite; }
.hud-time { text-align: right; }
.hud-time .hud-value { font-variant-numeric: tabular-nums; }
.hud-time.urgent .hud-value { color: var(--red); animation: blink .5s steps(2, start) infinite; }

/* The "cabinet": dark frame with chasing marquee lights around the board */
.cabinet {
  --cols: 4;
  --rows: 3;
  position: relative;
  width: min(100%, calc((100vh - 160px) * var(--cols) / var(--rows)));
  width: min(100%, calc((100dvh - 160px) * var(--cols) / var(--rows)));
  padding: 18px;
  border-radius: 30px;
  background: linear-gradient(#22164d, #130d30);
  box-shadow: 0 0 0 3px var(--frame), 0 0 40px rgba(255, 45, 149, .18), 0 24px 50px rgba(0, 0, 0, .6);
}
@media (orientation: portrait) {
  .cabinet { --cols: 3; --rows: 4; }
}
.cabinet.shake { animation: shake .18s; }
.lights { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lights rect { fill: none; stroke-width: 5px; stroke-linecap: round; stroke-dasharray: 0 18; }
.lights .l1 { stroke: var(--yellow); animation: chase .5s steps(2, jump-none) infinite; }
.lights .l2 { stroke: var(--pink); animation: chase2 .5s steps(2, jump-none) infinite; }
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: 2%;
  padding: 3%;
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .12), transparent 50%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, .06) 0 10px, transparent 10px 20px),
    linear-gradient(#4db34d, var(--grass-dark));
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, .35), inset 0 0 60px rgba(0, 0, 0, .35);
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'><g transform='rotate(-35 20 20)'><rect x='18' y='14' width='6' height='24' rx='2.5' fill='%23b8783a' stroke='%23222' stroke-width='2'/><rect x='8' y='3' width='26' height='13' rx='3' fill='%238a8a8a' stroke='%23222' stroke-width='2'/></g></svg>") 10 10, pointer;
  touch-action: none;
}
.hole { position: relative; aspect-ratio: 1; }
.pit {
  position: absolute;
  left: 6%; right: 6%; bottom: 8%;
  height: 26%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 30%, #120904, var(--dirt) 70%);
  box-shadow: inset 0 8px 14px rgba(0, 0, 0, .75), 0 2px 0 rgba(255, 255, 255, .08);
  z-index: 1;
}
.mask { position: absolute; left: 4%; right: 4%; top: 0; bottom: 21%; overflow: hidden; z-index: 2; }
.rim {
  position: absolute;
  left: 6%; right: 6%; bottom: 8%;
  height: 26%;
  border-radius: 50%;
  background: linear-gradient(var(--dirt-light), var(--dirt));
  clip-path: inset(50% 0 0 0);
  z-index: 3;
  pointer-events: none;
}
.mole {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;          /* only the picture itself can be whacked */
  transform: translateY(104%);
  transition: transform .14s cubic-bezier(.2, .8, .3, 1.15);
  will-change: transform;
}
.mole.up { transform: translateY(0); }
.mole.hit { transform: translateY(18%) scale(1.15, .55); transition: transform .1s ease-in; }
.mole img {
  display: block;
  max-width: 100%;
  max-height: 100%;              /* actual size is set by game.js to match the picture */
  pointer-events: auto;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .45));
}
.mole.boss.up img { animation: wiggle .16s infinite alternate; }
.mole.hit img { filter: drop-shadow(0 0 12px rgba(255, 230, 0, .9)); }

.countdown {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--arcade);
  font-size: clamp(4rem, 22vw, 12rem);
  color: var(--yellow);
  text-shadow: .06em .06em 0 var(--pink), .12em .12em 0 #1b0f3d, 0 0 .4em rgba(255, 230, 0, .5);
  pointer-events: none;
  z-index: 40;
}
.countdown[hidden] { display: none; }
.countdown.go { color: var(--pink); text-shadow: .06em .06em 0 var(--yellow), .12em .12em 0 #1b0f3d, 0 0 .4em rgba(255, 45, 149, .6); }
.countdown.pop { animation: pop .7s ease-out; }

/* ---------- Summary ---------- */
#screen-summary { justify-content: flex-start; overflow-y: auto; gap: 10px; }
.summary-name { margin: 0; color: var(--muted); }
.summary-total {
  font-family: var(--arcade);
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  line-height: 1.2;
  color: var(--yellow);
  text-shadow: .08em .08em 0 var(--pink), .16em .16em 0 #1b0f3d, 0 0 .5em rgba(255, 230, 0, .45);
}
.new-hi {
  margin: 0;
  font-family: var(--arcade);
  font-size: clamp(.7rem, 2.6vw, 1rem);
  color: var(--pink);
  text-shadow: 0 0 12px rgba(255, 45, 149, .8);
  animation: blink .7s steps(2, start) infinite;
}
.summary-hits { margin: 0; color: var(--muted); }
.summary-list { width: min(100%, 520px); display: flex; flex-direction: column; gap: 6px; }
.srow {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px 6px 6px;
  text-align: left;
}
.srow.boss { border-color: rgba(255, 45, 149, .5); }
.srow.zero { opacity: .5; }
.sthumb { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 8px; }
.slabel { font-weight: 700; }
.srow.boss .slabel { color: var(--pink); }
.shits { color: var(--muted); }
.spts { font-family: var(--arcade); font-size: .65rem; color: var(--yellow); min-width: 70px; text-align: right; }
.save-status { margin: 0; color: var(--muted); font-size: .9rem; min-height: 1.2em; }

/* ---------- Hall of Fame ---------- */
#screen-hall { justify-content: flex-start; overflow-y: auto; gap: 16px; }
.hall-title { margin: 8px 0 0; font-family: var(--arcade); font-size: clamp(.7rem, 2.6vw, .9rem); color: var(--cyan); }
.hall-list { list-style: none; margin: 0; padding: 0; width: min(100%, 560px); display: flex; flex-direction: column; gap: 8px; }
.hall-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
}
.hall-row.top { border-color: var(--yellow); background: rgba(255, 230, 0, .07); box-shadow: 0 0 18px rgba(255, 230, 0, .25); }
.hall-rank { font-family: var(--arcade); font-size: .8rem; color: var(--cyan); text-align: center; }
.hall-row:nth-child(-n+3) .hall-rank { font-family: inherit; font-size: 1.5rem; }
.hall-who { display: flex; flex-direction: column; min-width: 0; }
.hall-name { font-weight: 700; font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hall-meta { color: var(--muted); font-size: .8rem; }
.hall-best { font-family: var(--arcade); font-size: clamp(.8rem, 3vw, 1.1rem); color: var(--yellow); text-shadow: 2px 2px 0 rgba(0, 0, 0, .6), 0 0 10px rgba(255, 230, 0, .5); }

/* ---------- Characters ---------- */
#screen-chars { justify-content: flex-start; overflow-y: auto; gap: 16px; }
.char-grid {
  width: min(100%, 1100px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.char-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.char-card:hover, .char-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 18px rgba(45, 226, 255, .25);
}
.char-card.boss { border-color: rgba(255, 45, 149, .5); }
.char-card.boss:hover, .char-card.boss:focus-visible { border-color: var(--pink); box-shadow: 0 0 18px rgba(255, 45, 149, .35); }
.char-pic, .detail-pic {
  aspect-ratio: 4 / 5;
  background: radial-gradient(circle at 50% 30%, #fff, #e6e1fa);
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 8px;
  overflow: hidden;
}
.char-pic img, .detail-pic img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35));
}
.char-name {
  font-family: var(--arcade);
  font-size: .7rem;
  line-height: 1.5;
  color: var(--yellow);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .6);
}
.char-card.boss .char-name { color: var(--pink); }
.char-badge {
  align-self: center;
  font-family: var(--arcade);
  font-size: .45rem;
  color: #fff;
  background: var(--pink);
  padding: 4px 8px;
  border-radius: 6px;
}
.char-story {
  margin: 0;
  font-size: .85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.soon { color: var(--muted); font-style: italic; }

.detail {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(5, 4, 20, .85);
  display: grid;
  place-items: center;
  padding: 16px;
}
.detail[hidden] { display: none; }
.detail-box {
  position: relative;
  width: min(100%, 760px);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(160px, 260px) 1fr;
  gap: 20px;
  background: linear-gradient(#22164d, #130d30);
  border: 3px solid var(--frame);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 0 40px rgba(255, 45, 149, .2), 0 24px 50px rgba(0, 0, 0, .6);
  text-align: left;
  user-select: text;
  -webkit-user-select: text;
}
@media (max-width: 560px) { .detail-box { grid-template-columns: 1fr; } }
.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  font: inherit;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, .4);
  border: 2px solid var(--frame);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}
.detail-pic { padding: 12px; border-radius: 12px; }
.detail-text { display: flex; flex-direction: column; gap: 10px; padding-right: 36px; }
.detail-name {
  font-family: var(--arcade);
  font-size: clamp(.8rem, 3vw, 1.2rem);
  line-height: 1.5;
  color: var(--yellow);
  margin: 0;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .6);
}
.detail-text .char-badge { align-self: flex-start; }
.detail-story p { margin: 0 0 10px; line-height: 1.55; }

/* ---------- Effects ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--arcade);
  font-size: 1.1rem;
  color: var(--yellow);
  text-shadow: 2px 2px 0 #000, 0 0 10px rgba(255, 230, 0, .8);
  animation: floatUp .7s ease-out forwards;
}
.float.boss { color: var(--pink); font-size: 1.5rem; text-shadow: 2px 2px 0 #000, 0 0 12px rgba(255, 45, 149, .9); }

@keyframes floatUp { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -70px; } }
@keyframes wiggle { from { transform: translateX(-6%) rotate(-4deg); } to { transform: translateX(6%) rotate(4deg); } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes glow { from { filter: brightness(1); } to { filter: brightness(1.18); } }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-5px, 2px); } 50% { transform: translate(5px, -2px); } 75% { transform: translate(-3px, 1px); } }
@keyframes chase { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 18; } }
@keyframes chase2 { from { stroke-dashoffset: 9; } to { stroke-dashoffset: 27; } }

/* ---------- Angry Borgs ---------- */
.angry #screen-start { overflow-y: auto; gap: 12px; }
.howto { margin: 0; color: var(--muted); font-size: .9rem; max-width: 460px; }
.borg-preview { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; min-height: 20px; }
.borg-preview img {
  width: clamp(46px, 9vw, 72px);
  height: auto;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .45));
  animation: bob 1.4s ease-in-out infinite alternate;
}
.borg-preview img:nth-child(2n) { animation-delay: .35s; }
.borg-preview img:nth-child(3n) { animation-delay: .7s; }
/* The Chompers, in CSS, for the title screen */
.chomper-preview { display: flex; gap: 22px; align-items: center; }
.chomp {
  --c: var(--yellow);
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .18), 0 6px 10px rgba(0, 0, 0, .45);
}
.chomp::before { /* the mouth */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 240deg at 50% 50%, #5a0f22 0 60deg, transparent 60deg);
  animation: chomp .4s steps(1, end) infinite alternate;
}
.chomp::after { /* the eye */
  content: '';
  position: absolute;
  left: 42%;
  top: 14%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset -2px 0 0 2px #1b0f3d;
}
.chomp.c2 { --c: #ff9f1c; }
.chomp.c3 { --c: #b8ff3c; }
.chomp.c2::before { animation-delay: .13s; }
.chomp.c3::before { animation-delay: .27s; }
@keyframes chomp {
  from { background: conic-gradient(from 240deg at 50% 50%, #5a0f22 0 60deg, transparent 60deg); }
  to   { background: conic-gradient(from 258deg at 50% 50%, #5a0f22 0 24deg, transparent 24deg); }
}
@keyframes bob { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-8px) rotate(4deg); } }

.angry #screen-game { gap: 8px; }
.angry .hud { width: min(100%, 1200px); }
.stage-box {
  position: relative;
  flex: 0 0 auto;
  width: min(100%, 1200px);    /* real size is set by angry.js to keep 16:9 */
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #07061a;
  border: 3px solid var(--frame);
  box-shadow: 0 0 0 3px #0b0a22, 0 0 40px rgba(255, 45, 149, .18), 0 24px 50px rgba(0, 0, 0, .6);
  touch-action: none;
}
#stage { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#stage:active { cursor: grabbing; }
.stage-buttons { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 5; }
.btn-icon.inline { position: static; text-decoration: none; line-height: 1.3; }
.rotate-hint { display: none; margin: 0; color: var(--muted); font-size: .8rem; }
@media (orientation: portrait) and (max-width: 700px) { .rotate-hint { display: block; } }
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 4, 20, .8);
  animation: fadeIn .3s ease-out;
}
.overlay[hidden] { display: none; }
.overlay-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(100%, 520px);
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 18px;
  background: linear-gradient(#22164d, #130d30);
  border: 3px solid var(--frame);
  border-radius: 20px;
  box-shadow: 0 0 40px rgba(255, 45, 149, .2), 0 24px 50px rgba(0, 0, 0, .6);
}
.overlay-box .title-small { margin: 0; }
.overlay-box .title-small.lost { color: var(--red); text-shadow: .08em .08em 0 #1b0f3d, 0 0 .6em rgba(255, 59, 59, .45); }
.stars { font-size: clamp(1.8rem, 6vw, 2.6rem); color: var(--yellow); text-shadow: 0 0 14px rgba(255, 230, 0, .7), 2px 2px 0 rgba(0, 0, 0, .6); letter-spacing: .1em; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Angry Borgs: level select */
#screen-levels { overflow-y: auto; gap: 14px; }
.level-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; width: min(100%, 760px); }
.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(100%, 300px);
  padding: 18px 16px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  transition: transform .1s, border-color .1s, box-shadow .1s;
}
.level-card:hover:not(:disabled), .level-card:focus-visible { transform: translateY(-3px); border-color: var(--cyan); outline: none; box-shadow: 0 0 18px rgba(45, 226, 255, .25); }
.level-card.cleared { border-color: rgba(255, 230, 0, .5); }
.level-card.locked { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.level-no { font-family: var(--arcade); font-size: .6rem; color: var(--cyan); }
.level-name { font-family: var(--arcade); font-size: clamp(.7rem, 2.6vw, .95rem); line-height: 1.5; color: var(--yellow); text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }
.level-stars { font-size: 1.5rem; color: var(--yellow); text-shadow: 0 0 10px rgba(255, 230, 0, .6); letter-spacing: .08em; }
.level-meta { color: var(--muted); font-size: .85rem; }
.level-best { font-family: var(--arcade); font-size: .55rem; color: var(--pink); }
button.btn-link { background: none; cursor: pointer; }
