:root {
  --ink: #1d1a33;
  --paper: #fffaf0;
  --yellow: #ffd23f;
  --pink: #ff6fa0;
  --blue: #4f7cff;
  --orange: #ff8a3d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #9fd0ec;
  color: var(--ink);
  font-family: 'Space Mono', ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }

.hud-box {
  position: absolute;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 6px 12px;
}
.hud-score { top: 14px; left: 50%; transform: translateX(-50%); text-align: center; min-width: 130px; }
.hud-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; opacity: .7; }
.hud-big { font-family: 'Bangers', system-ui; font-size: 34px; line-height: 1; letter-spacing: .03em; }
.hud-right {
  top: 14px; right: 14px; font-size: 14px; line-height: 1.5;
  background: var(--yellow);
}
.hud-right b { font-size: 16px; }

.icon-btn {
  position: absolute; top: 14px; left: 14px; pointer-events: auto;
  width: 44px; height: 44px; font-size: 20px; font-weight: 700;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.icon-btn.off { opacity: .45; text-decoration: line-through; }

.combo {
  position: absolute; left: 50%; bottom: 9vh; transform: translateX(-50%);
  text-align: center; width: min(92vw, 640px);
}
.combo-tricks {
  display: inline-block;
  font-size: 13px; font-weight: 700; background: var(--paper);
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 4px 10px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combo-total {
  margin-top: 6px;
  font-family: 'Bangers', system-ui; font-size: 40px; color: var(--yellow);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 3px 3px 0 var(--ink);
  letter-spacing: .04em;
}
.combo.banked .combo-total { color: #7dffb0; animation: bank .6s ease-out; }
.combo.lost .combo-total { color: #ff5d5d; text-decoration: line-through; }
@keyframes bank { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

#pops { position: absolute; inset: 0; }
.pop {
  position: absolute; left: 50%; top: 34%;
  font-family: 'Bangers', system-ui; font-size: clamp(34px, 7vw, 64px);
  color: var(--yellow); letter-spacing: .04em;
  -webkit-text-stroke: 2.5px var(--ink);
  text-shadow: 4px 4px 0 var(--ink);
  white-space: nowrap;
  animation: pop 0.9s cubic-bezier(.2,1.6,.4,1) forwards;
}
.pop.pink { color: var(--pink); }
.pop.blue { color: #8fd3ff; }
.pop.green { color: #7dffb0; }
.pop .pts { display: block; font-size: .45em; text-align: center; color: var(--paper); }
@keyframes pop {
  0% { transform: translate(-50%, 0) scale(.3) rotate(-8deg); opacity: 0; }
  20% { transform: translate(-50%, 0) scale(1.15) rotate(-4deg); opacity: 1; }
  70% { transform: translate(-50%, -20px) scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: translate(-50%, -60px) scale(.9) rotate(-4deg); opacity: 0; }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 16px;
}
#menu { justify-content: space-between; padding: 6vh 16px 5vh; overflow-y: auto; }
@media (max-height: 940px) {
  #menu { justify-content: flex-start; padding-top: 3vh; }
  #menu .title { font-size: clamp(40px, 7vh, 90px); }
  #menu .controls { display: none; }
}

.title-wrap { text-align: center; }
.title {
  margin: 0; font-family: 'Bangers', system-ui; font-weight: 400;
  font-size: clamp(52px, 11vw, 120px); line-height: .9; letter-spacing: .04em;
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 6px 6px 0 var(--ink);
  transform: rotate(-4deg);
  display: flex; flex-direction: column; align-items: center;
}
.title-2 { color: var(--pink); font-size: 1.15em; }

.panel {
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
  padding: 16px 18px;
  width: min(92vw, 380px);
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
}
.panel-label { font-weight: 700; font-size: 12px; letter-spacing: .1em; text-align: center; }
.pick { display: flex; gap: 10px; }
.pick-btn {
  flex: 1; font-family: 'Bangers', system-ui; font-size: 24px; letter-spacing: .06em;
  padding: 6px; cursor: pointer; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.pick-btn.active { background: var(--blue); color: #fff; }

.go-btn {
  font-family: 'Bangers', system-ui; font-size: 34px; letter-spacing: .08em;
  padding: 8px 10px; cursor: pointer; color: var(--ink);
  background: var(--yellow); border: 4px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  transition: transform .08s;
}
.go-btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.go-btn:disabled { background: #ddd; cursor: wait; font-size: 22px; }
.link-btn {
  background: none; border: none; font: inherit; font-size: 13px; text-decoration: underline;
  color: var(--ink); cursor: pointer;
}

.controls { font-size: 12px; line-height: 1.9; text-align: center; }
kbd {
  display: inline-block; min-width: 22px; padding: 0 4px; margin: 0 1px;
  font: 700 11px 'Space Mono', monospace; line-height: 18px;
  background: #fff; border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
}
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch-only { display: block; }
  .controls > div:not(.touch-only) { display: none; }
}
.best { text-align: center; font-size: 13px; }

.burst {
  font-family: 'Bangers', system-ui; font-size: clamp(70px, 16vw, 150px);
  color: #ff5d5d; letter-spacing: .05em;
  -webkit-text-stroke: 3px var(--ink);
  text-shadow: 7px 7px 0 var(--ink);
  transform: rotate(-6deg);
  animation: slam .45s cubic-bezier(.2,1.8,.4,1);
}
.burst.small { font-size: clamp(50px, 10vw, 90px); color: var(--yellow); }
@keyframes slam { 0% { transform: scale(3) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(-6deg); opacity: 1; } }
.hint { font-weight: 700; background: var(--paper); border: 3px solid var(--ink); padding: 4px 10px; }

.over-row { display: flex; justify-content: space-between; font-size: 15px; border-bottom: 2px dashed rgba(29,26,51,.25); padding-bottom: 4px; }
.over-row b { font-family: 'Bangers', system-ui; font-size: 24px; font-weight: 400; letter-spacing: .04em; }
.new-best { text-align: center; font-family: 'Bangers', system-ui; font-size: 28px; color: var(--pink); -webkit-text-stroke: 1px var(--ink); animation: bank .6s ease-out infinite alternate; }

.credit {
  position: fixed; right: 8px; bottom: 6px; font-size: 10px; opacity: .7;
}
.credit a { color: inherit; }

@media (max-width: 600px) {
  .hud-score { top: 10px; min-width: 100px; padding: 4px 10px; }
  .hud-big { font-size: 26px; }
  .hud-right { top: 10px; right: 10px; font-size: 11px; padding: 4px 8px; }
  .icon-btn { top: 10px; left: 10px; width: 38px; height: 38px; }
  .combo-total { font-size: 30px; }
}

/* ---------- style picker ---------- */
.style-picker { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.style-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.style-name {
  flex: 1; text-align: center; font-family: 'Bangers', system-ui; font-size: 22px; letter-spacing: .06em;
  background: #fff; border: 3px solid var(--ink); padding: 2px 6px;
}
.style-arrow {
  width: 38px; height: 38px; font: 700 22px 'Space Mono', monospace; cursor: pointer; color: var(--ink);
  background: var(--yellow); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.board-row { display: flex; gap: 8px; }
.board-chip {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
}
.board-chip.active { outline: 3px solid var(--ink); outline-offset: 3px; }
