:root {
  --ink: #ece7dd;
  --muted: #9aa4ae;
  --accent: #d0493e;
  --granite: #575d66;
  --granite-dark: #2a2e33;
  --cell-a: #2f353d;
  --cell-b: #292e35;
  --s: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: linear-gradient(#3b4653 0%, #232b35 45%, #16202a 100%) fixed;
  color: var(--ink);
  font: 15px/1.45 "PT Sans", system-ui, sans-serif;
  overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* дождь — не бывает в Петербурге дня без него */
#rain { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#rain i {
  position: absolute; top: -40px; width: 1px; height: 28px;
  background: linear-gradient(transparent, rgba(200, 215, 230, .35));
  animation: drop linear infinite;
}
@keyframes drop { to { transform: translate(-60px, 110vh); } }

#wrap { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 14px 16px 40px; }

header { text-align: center; margin-bottom: 10px; }
h1 {
  margin: 0; font: 700 clamp(30px, 8vw, 42px)/1.05 "PT Serif", Georgia, serif;
  letter-spacing: .5px; text-shadow: 0 2px 0 #0008;
}
h1::first-letter { color: var(--accent); }
.sub { margin: 2px 0 0; font: italic 400 15px "PT Serif", Georgia, serif; color: var(--muted); }

.hud { display: flex; gap: 8px; margin-bottom: 8px; }
.hud > div {
  background: #0003; border: 1px solid #ffffff14; border-radius: 10px; padding: 6px 10px;
  display: flex; flex-direction: column; justify-content: center;
}
.hud span { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.hud b { font-size: 20px; line-height: 1.1; }
.place { flex: 1; min-width: 0; }
.place b { font: 700 17px "PT Serif", Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat { width: 76px; text-align: center; }
.stat.low b { color: var(--accent); }

#goals { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 34px; }
.goal {
  display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px;
  background: #0003; border: 1px solid #ffffff14; border-radius: 99px; font-weight: 700;
  transition: transform .15s;
}
.goal .e { font-size: 20px; line-height: 1; }
.goal.bump { transform: scale(1.12); }
.goal.done { opacity: .55; }
.goal.done b::after { content: " ✓"; color: #7fd18e; }

#boardWrap { position: relative; width: max-content; margin: 0 auto; }
#board {
  position: relative; overflow: hidden; border-radius: 8px; touch-action: none;
  background: conic-gradient(var(--cell-a) 25%, var(--cell-b) 0 50%, var(--cell-a) 0 75%, var(--cell-b) 0);
  background-size: calc(var(--s) * 2) calc(var(--s) * 2);
  /* гранитная набережная */
  box-shadow: 0 0 0 7px var(--granite), 0 0 0 10px var(--granite-dark), 0 22px 50px #000a;
}
.tile {
  position: absolute; left: 0; top: 0; width: var(--s); height: var(--s);
  transition: transform .2s cubic-bezier(.3, .7, .4, 1.05);
  will-change: transform; cursor: pointer;
}
.tile .in {
  position: absolute; inset: 3px; border-radius: 24%;
  background: var(--c);
  display: grid; place-items: center;
  font-size: calc(var(--s) * .56); line-height: 1;
  box-shadow: inset 0 -4px 0 #0004, inset 0 2px 0 #fff4, 0 2px 3px #0005;
  transition: transform .18s, opacity .22s, box-shadow .15s;
}
.tile.sel .in { transform: scale(1.08); box-shadow: 0 0 0 3px #fff, inset 0 -4px 0 #0004; }
.tile.pop .in { transform: scale(1.45) rotate(14deg); opacity: 0; }
.tile.born .in { animation: born .35s ease-out; }
.tile.hint .in { animation: wiggle .45s ease-in-out 3; }
@keyframes born { from { transform: scale(.2); } 70% { transform: scale(1.18); } }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.06); } 75% { transform: rotate(12deg) scale(1.06); } }

.badge {
  position: absolute; right: -3px; bottom: -4px; font-style: normal;
  font-size: calc(var(--s) * .34); filter: drop-shadow(0 1px 1px #000a);
}
.tile.sp-axeH .in { background-image: repeating-linear-gradient(0deg, #fff5 0 3px, transparent 3px 9px); }
.tile.sp-axeV .in { background-image: repeating-linear-gradient(90deg, #fff5 0 3px, transparent 3px 9px); }
.tile.sp-axeV .badge { transform: rotate(90deg); }
.tile.sp-bath .in { animation: glow .9s ease-in-out infinite alternate; }
.tile.sp-pack .in { background: radial-gradient(circle at 50% 40%, #6b5a45, #2b241c); }
.tile.sp-pack .in { animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 14px 3px #ffe9a8, inset 0 -4px 0 #0004; } }

/* следы бонусов */
.beam { position: absolute; pointer-events: none; background: linear-gradient(90deg, transparent, #fff, transparent); animation: beam .35s ease-out forwards; z-index: 5; }
.beam.v { background: linear-gradient(0deg, transparent, #fff, transparent); }
@keyframes beam { from { opacity: 1; } to { opacity: 0; } }
.ring { position: absolute; pointer-events: none; border: 4px solid #cfe6ff; border-radius: 50%; animation: ring .4s ease-out forwards; z-index: 5; }
@keyframes ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.flash { position: absolute; inset: 0; background: #fff; pointer-events: none; animation: beam .5s ease-out forwards; z-index: 5; }

#quip {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.6);
  font: 700 clamp(22px, 6.5vw, 32px) "PT Serif", Georgia, serif; white-space: nowrap;
  color: #fff; text-shadow: 0 3px 0 #000, 0 0 18px #000c; pointer-events: none; opacity: 0; z-index: 6;
}
#quip.on { animation: quip 1.1s ease-out; }
@keyframes quip {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  75% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

.bar { display: flex; gap: 8px; justify-content: center; margin: 22px 0 12px; flex-wrap: wrap; }
.bar button, .card button {
  background: #ffffff12; border: 1px solid #ffffff22; border-radius: 9px; padding: 8px 14px;
}
.bar button:hover, .card button:hover { background: #ffffff20; }

.ticker {
  overflow: hidden; white-space: nowrap; border-top: 1px solid #ffffff1a; border-bottom: 1px solid #ffffff1a;
  padding: 7px 0; font-size: 14px; color: #cfd6dd; background: #0002;
}
.ticker-in { display: inline-block; animation: ticker 140s linear infinite; }
.ticker-in b { color: var(--accent); margin: 0 10px; }
@keyframes ticker { to { transform: translateX(-50%); } }

.howto { color: var(--muted); font-size: 14px; }
.howto b { color: var(--ink); }
footer { margin-top: 16px; text-align: center; font-size: 12px; color: #77808a; }

#modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: #0b0f14c9; backdrop-filter: blur(3px);
}
#modal[hidden] { display: none; }
.card {
  width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(#323942, #262b32); border: 1px solid #ffffff1f; border-radius: 14px;
  padding: 20px; box-shadow: 0 20px 60px #000c; animation: born .3s ease-out;
}
.card h2 { margin: 0 0 4px; font: 700 26px "PT Serif", Georgia, serif; }
.card .kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); font-weight: 700; }
.card p { margin: 10px 0; }
.card .goals-line { font-size: 22px; letter-spacing: 2px; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.card .row button.main { background: var(--accent); border-color: transparent; font-weight: 700; }
.card .row button.main:hover { background: #e05a4f; }
.levels { display: grid; gap: 6px; margin-top: 12px; }
.levels button { text-align: left; display: flex; justify-content: space-between; gap: 10px; }
.levels button:disabled { opacity: .4; cursor: default; }
.levels small { color: var(--muted); }
