:root {
  --bg0: #1a0d4a;
  --bg1: #3a1578;
  --ink: #f4f7ff;
  --muted: #c9b6ea;
  --gold: #ffd24a;
  --gold-deep: #a86a10;
  --mint: #14b89a;
  --mint-deep: #0c7d6c;
  --pink: #ff4fd8;
  --glass: rgba(16, 12, 48, 0.42);
  --line: rgba(120, 230, 255, 0.78);
  --radius: 22px;
  --safe: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  color: var(--ink);
  font-family: "Nunito", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  justify-content: center;
  overflow: hidden;
  background: #140a3a;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 92% 18%, rgba(255, 210, 255, 0.5) 0 22px, transparent 23px),
    radial-gradient(circle at 6% 24%, rgba(120, 170, 255, 0.4) 0 28px, transparent 29px),
    radial-gradient(circle at 94% 72%, rgba(255, 120, 210, 0.28) 0 34px, transparent 35px),
    radial-gradient(circle at 10% 84%, rgba(90, 140, 255, 0.36) 0 40px, transparent 41px),
    radial-gradient(circle at 70% 94%, rgba(180, 120, 255, 0.28) 0 26px, transparent 27px),
    linear-gradient(180deg, #2a1468 0%, #3d1788 38%, #4a1578 62%, #241050 100%);
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.14), transparent 42%),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.28), transparent 46%);
}

#app,
.screen,
.overlay,
.sheet-overlay,
.drag-layer {
  position: relative;
  z-index: 1;
}

#app {
  width: min(100vw, 430px);
  height: 100%;
  max-height: 100dvh;
  padding: 12px 14px calc(12px + var(--safe));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.play-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.back-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: rgba(14, 18, 52, 0.55);
  color: #fff;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 12px rgba(80, 200, 255, 0.4), inset 0 0 10px rgba(80, 180, 255, 0.15);
}

.back-btn:active { transform: scale(0.96); }

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: transparent;
  padding: 0;
  flex: 0 0 auto;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat .label {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
}

.score-card {
  min-width: 0;
  padding: 8px 16px 8px 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(48, 86, 190, 0.55), rgba(16, 28, 84, 0.72));
  border: 2px solid rgba(140, 210, 255, 0.7);
  box-shadow: 0 0 16px rgba(70, 150, 255, 0.4), inset 0 0 14px rgba(90, 160, 255, 0.18);
}

.hud-crown {
  width: 42px;
  height: 32px;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.score-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.score-card .label { color: #ffe08a; }

#score {
  color: #ffe14a;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #a86a10, 0 0 12px rgba(255, 200, 60, 0.45);
}

#turnWrap {
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 6px 12px;
  border-radius: 16px;
  background: rgba(18, 14, 48, 0.45);
  border: 2px solid rgba(255, 210, 90, 0.7);
  box-shadow: 0 0 12px rgba(255, 190, 60, 0.25);
}

#turnWrap .label { color: #ffe08a; font-size: 0.72rem; }

#turnLeft {
  color: #fff;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.combo-card {
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 0;
  min-width: 108px;
  padding: 8px 16px 6px;
  border-radius: 16px;
  background: rgba(48, 8, 58, 0.28);
  border: 2px solid var(--pink);
  box-shadow: 0 0 14px rgba(255, 79, 216, 0.65), inset 0 0 12px rgba(255, 80, 200, 0.2);
}

.combo-card .label { color: #fff; }

#combo {
  color: #fff;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(255, 79, 216, 0.9);
}

.combo-card::before,
.combo-card::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px #fff;
  pointer-events: none;
}

.combo-card::before { top: -3px; right: 16px; }
.combo-card::after { bottom: 8px; left: -3px; box-shadow: 0 0 6px #ffe27a; background: #ffe27a; }

#comboWrap.hot #combo {
  animation: pop 0.28s ease;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.cup-line {
  flex: 0 0 auto;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  border: 0;
  cursor: pointer;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 0.98rem;
  font-weight: 800;
  color: #6a3808;
  background: linear-gradient(180deg, #fff4c2 0%, #ffd24a 42%, #f0a818 100%);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%);
  padding: 7px 26px;
  text-align: center;
  filter: drop-shadow(0 4px 0 #b87810) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.25));
}

.cup-line::before { content: "🏆 "; }

.cup-line:active { filter: brightness(0.96) drop-shadow(0 2px 0 #b87810); }

.screen {
  width: min(100vw, 430px);
  height: 100%;
  max-height: 100dvh;
  padding: 18px 16px calc(16px + var(--safe));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.screen[hidden], #app[hidden] { display: none !important; }

.screen.flow {
  justify-content: flex-start;
  overflow: auto;
  gap: 12px;
  padding-top: 16px;
}

.flow-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  flex: 0 0 auto;
}

.flow-nav h1,
.sheet-nav h2 {
  grid-column: 2;
  margin: 0;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 0 rgba(40, 20, 80, 0.45);
}

.flow-nav .back-btn,
.sheet-nav .back-btn { grid-column: 1; }

.flow-nav .friends-corner {
  grid-column: 3;
  justify-self: end;
  position: relative;
}

.friends-corner-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 0.72rem;
}

.logo {
  position: relative;
  text-align: center;
  margin: 0 auto 2px;
  width: min(100%, 340px);
}

.crowns {
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  margin-bottom: -10px;
}

.crown {
  width: 58px;
  height: 44px;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35));
}

.crown.left { transform: rotate(-16deg); }
.crown.right { transform: rotate(16deg); }

.logo h1 {
  font-size: unset;
  line-height: 0.92;
  text-align: center;
}

.logo h1 .logo-gold + .logo-gold {
  margin-top: 0.06em;
}

.logo-gold,
.logo-ice {
  display: block;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.logo-gold {
  font-size: clamp(3.5rem, 17vw, 4.7rem);
  background: linear-gradient(180deg, #fff8d4 0%, #ffe56a 28%, #f6b423 62%, #d4890d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #8a4e08) drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
}

.logo-ice {
  font-size: clamp(2.7rem, 13.5vw, 3.7rem);
  margin-top: 2px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 38%, #b9d4f2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #3d6294) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.3));
}

.trophy {
  display: block;
  width: 86px;
  height: auto;
  margin: 2px auto 0;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35));
  animation: trophyGlow 2.8s ease-in-out infinite;
}

@keyframes trophyGlow {
  50% { filter: drop-shadow(0 0 12px rgba(255, 210, 80, 0.85)) drop-shadow(0 8px 8px rgba(0, 0, 0, 0.35)); }
}

.spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  pointer-events: none;
}

.s1 { top: 18px; left: 8px; }
.s2 { top: 46px; right: 6px; width: 4px; height: 4px; background: #ffe27a; box-shadow: 0 0 8px #ffe27a; }
.s3 { top: 78%; left: 14px; width: 3px; height: 3px; }
.s4 { bottom: 18px; right: 22px; background: #ffd0ff; box-shadow: 0 0 8px #ffd0ff; }

.screen h1 {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
}

.screen.flow .flow-nav h1 { font-size: 1.45rem; margin: 0; }

.title-record {
  align-self: center;
  text-align: center;
  font-weight: 800;
  color: #f3e9ff;
  background: rgba(48, 18, 90, 0.55);
  border-radius: 12px;
  padding: 6px 16px;
  font-size: 0.95rem;
}

.rating-entry {
  width: 100%;
  border: 2px solid rgba(255, 210, 90, 0.75);
  border-radius: 20px;
  background: rgba(48, 28, 8, 0.35);
  color: #ffe08a;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 190, 60, 0.22);
}

.rating-entry:active { transform: translateY(2px); }

.awards-entry {
  width: 100%;
  border: 2px solid rgba(120, 220, 255, 0.7);
  border-radius: 20px;
  background: rgba(10, 40, 70, 0.35);
  color: #d7f6ff;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(80, 200, 255, 0.22);
}

.awards-entry:active { transform: translateY(2px); }

.screen.flow.rating-screen { overflow: hidden; }

.span-row { display: flex; gap: 8px; flex: 0 0 auto; }

.span-row button {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 16px;
  padding: 10px 6px;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  background: rgba(18, 16, 48, 0.55);
  color: #efe7ff;
  box-shadow: inset 0 0 0 2px rgba(90, 70, 140, 0.35);
}

.span-row button[aria-pressed="true"] {
  background: linear-gradient(180deg, #fff4c2 0%, #ffd24a 42%, #f0a818 100%);
  color: #6a3808;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), 0 3px 0 #b87810;
}

.rating-when {
  margin: 0;
  flex: 0 0 auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.rating-list {
  list-style: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.rating-list:empty::before {
  content: "рекордов ещё нет";
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  padding: 28px 8px;
}

.rating-me {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 210, 90, 0.28);
}

.rating-me[hidden] { display: none !important; }

.rating-you {
  margin: 0;
  text-align: center;
  color: #ffe08a;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#playBtn.play-main {
  margin-top: 4px;
  padding: 14px 16px 16px;
  font-size: 1.85rem;
  border-radius: 22px;
}

.sheet h3,
.flow h3 {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: 0.78rem;
  color: #d7c6ff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
}

.name-field {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex: none;
  min-width: 0;
  background: rgba(12, 14, 42, 0.72);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 0 12px;
  box-shadow: 0 0 12px rgba(80, 200, 255, 0.32);
}

.field-icon { flex: 0 0 auto; color: #e7f3ff; }

.speaker { flex: 0 0 auto; color: #f4fbff; filter: drop-shadow(0 0 6px rgba(160, 220, 255, 0.6)); }

.switch {
  position: relative;
  width: 62px;
  height: 34px;
  flex: 0 0 auto;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.switch-track {
  display: block;
  width: 62px;
  height: 34px;
  border-radius: 999px;
  background: #2a3358;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
  position: relative;
}

.switch-mark {
  position: absolute;
  left: 9px;
  top: 4px;
  color: #fff;
  font-weight: 900;
  font-size: 1rem;
  opacity: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #e4e9f4);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.16s ease;
}

.switch input:checked + .switch-track {
  background: linear-gradient(180deg, #8dffb0, #22c55e);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 0 10px rgba(40, 220, 110, 0.55);
}

.switch input:checked + .switch-track .switch-mark { opacity: 1; }

.switch input:checked + .switch-track::after { transform: translateX(28px); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.flow input,
.sheet input {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  background: rgba(18, 16, 48, 0.45);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  border-radius: 16px;
  padding: 12px 14px;
  user-select: text;
  -webkit-user-select: text;
}

.room-nick {
  margin: 0;
  text-align: center;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: #f4fbff;
}

.name-note {
  min-height: 1.2em;
  margin: 4px 0 0;
  text-align: center;
  color: #ffb4c8;
  font-size: 0.9rem;
  font-weight: 800;
}

.name-field input {
  display: block;
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  border-radius: 0;
  padding: 12px 2px;
  box-shadow: none;
  user-select: text;
  -webkit-user-select: text;
}

#roomSeconds,
#lobbySeconds {
  text-align: center;
  background: rgba(120, 50, 170, 0.28);
  color: #f6eeff;
  border: 0;
}

#lobbySeconds:disabled { opacity: 0.65; }

#roomCodeInput {
  background: rgba(10, 14, 40, 0.62);
  border: 2px solid var(--line);
  box-shadow: 0 0 12px rgba(70, 200, 255, 0.32);
}

.flow input::placeholder,
.sheet input::placeholder,
.name-field input::placeholder {
  color: rgba(236, 228, 255, 0.72);
}

.flow > .primary,
.flow > .ghost,
#roomWait > .primary,
#roomWait > p,
.zone > .primary,
.zone > input {
  display: block;
  width: 100%;
  margin: 0;
}

#roomTable {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#roomTable li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 14px;
  color: #efe7ff;
  background: rgba(16, 14, 48, 0.45);
  border: 1px solid rgba(160, 140, 255, 0.18);
}

#roomTable .rank,
.sheet .rank { color: var(--gold); font-weight: 800; min-width: 1.2em; }
#roomTable .name,
.sheet .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roomTable .pts,
.sheet .pts { font-variant-numeric: tabular-nums; }

.vis-row { display: flex; gap: 10px; }

.vis-row button {
  flex: 1;
  margin: 0;
  border: 0;
  border-radius: 18px;
  padding: 12px 10px;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
  background: rgba(18, 16, 48, 0.55);
  color: #efe7ff;
  box-shadow: inset 0 0 0 2px rgba(90, 70, 140, 0.35);
}

.vis-row button[aria-pressed="true"] {
  background: linear-gradient(180deg, #d9fff6 0%, #7ef0d4 16%, #2ed3b0 55%, #14b89a 100%);
  color: #12352f;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    0 4px 0 var(--mint-deep);
}

#compete > .primary { margin-top: 0; }

#roomNameInput[hidden] { display: none !important; }

.primary:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.room-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.server-list {
  min-width: 0;
}

.zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0 0;
  border-radius: 0;
  background: transparent;
}

#publicRooms,
#roomTable,
#raceStatus { list-style: none; }

#publicRooms {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(62dvh, 560px);
  overflow: auto;
  min-height: 160px;
}

#publicRooms:empty::before {
  content: "нет открытых комнат";
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  padding: 36px 8px;
}

#publicRooms li {
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

#publicRooms li.selected {
  border-color: #5eecc8;
  background: rgba(18, 88, 82, 0.55);
  box-shadow: 0 0 14px rgba(80, 230, 200, 0.4);
}

.room-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-players,
.room-time,
.room-status { color: var(--muted); font-size: 0.8rem; }

#publicRooms li.selected .room-status { color: #bffff4; }

#raceStatus li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  background: rgba(16, 14, 48, 0.45);
  border-radius: 12px;
  padding: 8px 10px;
  min-height: 40px;
}

#turnWrap[hidden],
#raceStatus[hidden],
#cupLine[hidden] { display: none !important; }

#raceStatus {
  flex: 0 0 auto;
  max-height: 132px;
  overflow: auto;
  background: rgba(12, 14, 40, 0.4);
  border: 2px solid rgba(120, 220, 255, 0.28);
  border-radius: 16px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#raceStatus li.out { opacity: 0.45; }
#raceStatus .pts { font-variant-numeric: tabular-nums; }

.sheet-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}

#roomTable[hidden],
#roomPlay[hidden],
#roomStart[hidden] { display: none !important; }

.flow-nav.lobby-nav {
  grid-template-columns: minmax(0, 1fr) auto minmax(44px, 1fr);
  column-gap: 8px;
}

.lobby-nav .leave-btn { grid-column: 1; justify-self: start; }
.lobby-nav .icon-btn { grid-column: 3; justify-self: end; }

.leave-btn {
  border: 2px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 18, 52, 0.55);
  color: #fff;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(80, 200, 255, 0.4);
}

.leave-btn:active { transform: scale(0.98); }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: rgba(14, 18, 52, 0.55);
  color: #fff;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 12px rgba(80, 200, 255, 0.4), inset 0 0 10px rgba(80, 180, 255, 0.15);
}

.icon-btn:active { transform: scale(0.96); }

.icon-btn.open {
  border-color: #7ef0d4;
  color: #d9fff6;
  box-shadow: 0 0 14px rgba(80, 240, 200, 0.55);
}

#roomWait.screen.flow {
  overflow: hidden;
}

#roomWait.screen.flow > * { flex-shrink: 0; }

#roomWait #roomTable {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.lobby-label {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: 0.78rem;
  color: #d7c6ff;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
}

#roomLobbyNote {
  margin: 0;
  min-height: 1.2em;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

#roomTable li.me {
  background: rgba(80, 140, 255, 0.24);
  border-color: rgba(150, 220, 255, 0.45);
}

#roomTable .role {
  flex: 0 0 auto;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.turn-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(18, 12, 52, 0.45);
  border: 2px solid var(--line);
  box-shadow: 0 0 16px rgba(80, 200, 255, 0.22);
}

.turn-settings[hidden] { display: none !important; }

.turn-settings label,
.turn-hint {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #d7c6ff;
}

.turn-hint {
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--muted);
}

.lobby-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.lobby-foot .primary { width: 100%; }

.code-field {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: rgba(10, 14, 40, 0.62);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 2px 6px 2px 12px;
  box-shadow: 0 0 12px rgba(70, 200, 255, 0.32);
}

.code-field input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 10px 4px;
  text-align: center;
  letter-spacing: 0.08em;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #f4f7ff;
}

.copy-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #e7f6ff;
  cursor: pointer;
  padding: 0;
}

.copy-btn:active { transform: scale(0.96); }
.copy-btn .icon-check { display: none; }
.copy-btn.copied { color: #7ef0d4; background: rgba(40, 180, 150, 0.22); }
.copy-btn.copied .icon-copy { display: none; }
.copy-btn.copied .icon-check { display: block; }

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 4, 24, 0.62);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.sheet-overlay[hidden] { display: none !important; }

.sheet {
  width: min(100%, 430px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(48, 28, 110, 0.96), rgba(22, 12, 64, 0.98));
  border: 2px solid rgba(130, 220, 255, 0.4);
  border-radius: 26px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 0 28px rgba(80, 40, 180, 0.35);
}

.sheet ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet li.me {
  border-color: rgba(255, 210, 90, 0.75);
  box-shadow: 0 0 14px rgba(255, 190, 60, 0.28);
}

#boardWrap {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

#boardBox {
  position: relative;
  filter: drop-shadow(0 0 16px rgba(80, 170, 255, 0.45));
}

#board {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 26px;
  background: transparent;
  touch-action: none;
  cursor: pointer;
}

#fx {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.floater {
  position: absolute;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.55rem;
  color: #fff8d0;
  text-shadow: 0 2px 0 #a86a10, 0 0 10px rgba(255, 220, 80, 0.8);
  animation: floatUp 0.7s ease forwards;
  pointer-events: none;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.8); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1.15); }
}

.board-combo {
  position: absolute;
  left: 50%;
  top: 50%;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 3.4rem;
  line-height: 1;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px #ff4fd8, 0 3px 0 #8a2068;
  pointer-events: none;
  animation: comboFade 0.7s ease forwards;
}

@keyframes comboFade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.86); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

#tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex: 0 0 auto;
  min-height: 118px;
  background: rgba(12, 16, 48, 0.38);
  border: 2px solid rgba(120, 235, 255, 0.82);
  border-radius: 26px;
  padding: 8px;
  touch-action: none;
  box-shadow: 0 0 18px rgba(70, 190, 255, 0.38), inset 0 0 22px rgba(40, 70, 170, 0.22);
}

.slot {
  background: transparent;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 102px;
  cursor: grab;
  position: relative;
}

.slot:active { cursor: grabbing; }

.slot.selected {
  background: rgba(90, 220, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(140, 245, 255, 0.85);
}

.slot.dead {
  opacity: 0.35;
  cursor: default;
}

.slot canvas {
  width: auto;
  max-width: 96%;
  max-height: 96%;
  pointer-events: none;
}

.primary,
.ghost,
.quiet {
  border: 0;
  cursor: pointer;
  font-family: "Baloo 2", "Nunito", sans-serif;
}

.revive-sub { font-size: 0.65rem; color: var(--muted); font-weight: 700; }

.overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(180deg, #2a1468 0%, #3d1788 42%, #241050 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
  overflow: auto;
}

.overlay[hidden] { display: none !important; }

body:has(#overlay:not([hidden])) .play-nav { visibility: hidden; }

.share-panel {
  width: min(92vw, 380px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-height: 0;
}

.share-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 250px);
  object-fit: contain;
  object-position: center top;
  border-radius: 22px;
  background: #1a1048;
  align-self: center;
  box-shadow: 0 0 24px rgba(80, 40, 180, 0.4);
}

.share-panel .primary,
.share-panel .ghost,
.share-panel .quiet { margin-top: 0; }

.primary {
  width: 100%;
  margin-top: 0;
  flex: 0 0 auto;
  background: linear-gradient(180deg, #e7fff8 0%, #8ff3dc 14%, #36d6b6 52%, #14b89a 100%);
  color: #12352f;
  font-weight: 800;
  font-size: 1.4rem;
  border-radius: 20px;
  padding: 13px 16px 15px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -3px 0 rgba(0, 80, 70, 0.15),
    0 5px 0 var(--mint-deep),
    0 10px 16px rgba(0, 0, 0, 0.22);
}

.primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.65),
    0 1px 0 var(--mint-deep);
}

.play-main {
  background: linear-gradient(180deg, #ffe7a4 0%, #ffc24a 18%, #ff8e1f 58%, #f06a00 100%);
  color: #5c2c08;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.75),
    inset 0 -4px 0 rgba(140, 50, 0, 0.18),
    0 6px 0 #c85a00,
    0 12px 18px rgba(0, 0, 0, 0.28);
}

.play-main:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    0 2px 0 #c85a00;
}

.end-reason {
  margin: 0 0 8px;
  text-align: center;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffd24a;
}

.share-panel .play-main { margin-bottom: 6px; }

.quiet {
  width: 100%;
  margin-top: 0;
  flex: 0 0 auto;
  box-sizing: border-box;
  background: rgba(16, 12, 42, 0.55);
  color: #efe7ff;
  font-weight: 800;
  font-size: 1.15rem;
  border: 2px solid rgba(186, 164, 240, 0.55);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: none;
}

.quiet:active { opacity: 0.65; }

.ghost {
  width: 100%;
  margin-top: 0;
  background: rgba(16, 12, 42, 0.35);
  color: var(--ink);
  border: 2px solid rgba(170, 150, 230, 0.45) !important;
  border-radius: 18px;
  padding: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  flex: 0 0 auto;
}

.ghost span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.drag-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  display: none;
}

#title { position: relative; overflow: auto; }

.profile-btn,
.avatar-lg {
  border: 2px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.85));
  color: #fff;
  box-shadow: 0 0 14px rgba(80, 200, 255, 0.45);
  cursor: pointer;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
}

.profile-btn {
  position: absolute;
  top: 10px;
  right: 0;
  z-index: 3;
  width: 52px;
  height: 52px;
  font-size: 1.35rem;
}

@media (min-width: 552px) {
  .profile-btn {
    position: fixed;
    left: 500px;
    right: auto;
  }
}

.profile-btn img,
.avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  grid-area: 1 / 1;
}

.profile-btn span,
.avatar-lg span { grid-area: 1 / 1; }

.profile-btn:active,
.avatar-lg:active { transform: scale(0.96); }

#title .logo { margin-top: 36px; }

.profile-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.avatar-lg {
  width: 112px;
  height: 112px;
  font-size: 2.6rem;
}

.profile-name {
  margin: 0;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
}

.avatar-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.id-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#userId {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(10, 14, 40, 0.62);
  border: 2px solid var(--line);
  color: #f4fbff;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-align: center;
}

.id-copy {
  flex: 0 0 auto;
  border: 2px solid rgba(170, 150, 230, 0.45);
  border-radius: 14px;
  background: rgba(16, 12, 42, 0.45);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 12px 12px;
  cursor: pointer;
}

.profile-btn .profile-invite {
  grid-area: 1 / 1;
  justify-self: end;
  align-self: start;
  width: 12px;
  height: 12px;
  margin: 1px;
  border-radius: 50%;
  background: #ffd24a;
  box-shadow: 0 0 8px #ffd24a;
  z-index: 1;
}

.friends-entry {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(16, 14, 48, 0.55);
  border: 1px solid rgba(160, 140, 255, 0.28);
  box-shadow: inset 0 0 12px rgba(40, 20, 90, 0.25);
  color: #efe7ff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.friends-entry svg { flex: 0 0 auto; color: var(--muted); }

.friends-entry-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.friends-entry-title {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
}

.friends-entry-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.friends-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffd24a;
  color: #5c2c08;
  display: grid;
  place-items: center;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
}

.friends-badge[hidden] { display: none !important; }

.screen.flow.friends-screen { overflow: hidden; }

.friend-add {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.friend-add input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: rgba(10, 14, 40, 0.62);
  color: #f4fbff;
  font: inherit;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-align: center;
  padding: 12px 10px;
  user-select: text;
  -webkit-user-select: text;
}

.friend-add input::placeholder {
  letter-spacing: 0;
  font-family: "Nunito", sans-serif;
  color: rgba(236, 228, 255, 0.72);
}

.friend-note {
  margin: 0;
  min-height: 1.1em;
  flex: 0 0 auto;
  text-align: center;
  color: #ffe08a;
  font-size: 0.82rem;
  font-weight: 800;
}

.friend-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.friend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

#friendList:empty::before {
  content: "Друзей ещё нет. ID копируется в профиле — его и нужно прислать.";
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  padding: 28px 8px;
}

.friend-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 4px;
}

#chatForm input {
  letter-spacing: 0;
  font-family: "Nunito", sans-serif;
  text-align: left;
}

.friend-go {
  border: 0;
  border-radius: 12px;
  padding: 8px 10px;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 0.92rem;
  color: #08352c;
  cursor: pointer;
  background: linear-gradient(180deg, #d9fff6 0%, #7ef0d4 16%, #2ed3b0 55%, #14b89a 100%);
  box-shadow: 0 2px 0 #0c7d6c;
}

.friend-go:active { transform: translateY(1px); }

.friend-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
}

.friend-go.friend-icon svg { display: block; }

.friend-no.friend-icon {
  color: #efe7ff;
  font-size: 1.35rem;
  line-height: 1;
}

.friend-no {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 8px 4px;
}

.screen.flow.chat-screen { overflow: hidden; }

.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.chat-empty[hidden] { display: none !important; }

.chat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.chat-line {
  display: flex;
}

.chat-line.mine { justify-content: flex-end; }

.chat-bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(16, 14, 48, 0.72);
  border: 1px solid rgba(160, 140, 255, 0.28);
  color: #efe7ff;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chat-line.mine .chat-bubble {
  background: linear-gradient(180deg, #fff4c2 0%, #ffd24a 100%);
  color: #4a2a08;
  border-color: transparent;
}

.chat-time {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  font-weight: 800;
  opacity: 0.7;
}

.card-meta .on { color: #5eecc8; }

.sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: rgba(18, 12, 52, 0.38);
  box-shadow: 0 0 14px rgba(80, 200, 255, 0.18);
}

.sound-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-grid div {
  background: rgba(16, 14, 48, 0.45);
  border: 1px solid rgba(160, 140, 255, 0.25);
  border-radius: 16px;
  padding: 10px 6px;
  text-align: center;
  color: #d7c6ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-grid b {
  display: block;
  margin-top: 4px;
  color: #ffe14a;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-all {
  flex: 0 0 auto;
  border: 2px solid rgba(170, 150, 230, 0.45);
  border-radius: 12px;
  background: rgba(16, 12, 42, 0.45);
  color: #efe7ff;
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 6px 10px;
  cursor: pointer;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

#historyList.quiet-empty:empty::before {
  content: none;
}

#historyList:empty::before {
  content: "партий ещё нет";
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
  padding: 18px 8px;
}

.person-card.me {
  border-color: rgba(255, 210, 90, 0.75);
  box-shadow: 0 0 14px rgba(255, 190, 60, 0.28);
}

.person-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(16, 14, 48, 0.55);
  border: 1px solid rgba(160, 140, 255, 0.28);
  box-shadow: inset 0 0 12px rgba(40, 20, 90, 0.25);
  color: #efe7ff;
  font-weight: 800;
  min-width: 0;
}

.card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.5), rgba(16, 18, 52, 0.92));
  border: 2px solid var(--line);
  box-shadow: 0 0 10px rgba(80, 200, 255, 0.35);
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
}

.card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #efe7ff;
}

.card-meta {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-score {
  color: #ffe14a;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-shadow: 0 2px 0 #a86a10;
}

.profile-name-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

.profile-name-edit input {
  flex: 0 1 auto;
  min-width: 4ch;
  max-width: 16rem;
  width: auto;
  field-sizing: content;
  margin: 0;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  color: #fff;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.45rem;
  font-weight: 800;
}

.profile-name-edit .field-icon { color: #bfefff; }

.awards-rules {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.frame-grid,
.medal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.frame-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  border-radius: 16px;
  padding: 8px 4px 10px;
  background: rgba(16, 14, 48, 0.55);
  border: 1px solid rgba(160, 140, 255, 0.28);
  color: #efe7ff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.frame-pick.locked {
  opacity: 0.5;
}

.frame-pick.equipped {
  border-color: rgba(255, 210, 90, 0.85);
  box-shadow: 0 0 12px rgba(255, 190, 60, 0.28);
}

.frame-preview {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92));
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 1.35rem;
}

.frame-pick-title,
.medal-title {
  font-size: 0.72rem;
  line-height: 1.15;
  text-align: center;
}

.frame-pick-meta,
.medal-meta {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.frame-pick.equipped .frame-pick-meta { color: #ffe08a; }

.medal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 8px 4px 10px;
  border-radius: 16px;
  background: rgba(16, 14, 48, 0.55);
  border: 1px solid rgba(160, 140, 255, 0.28);
}

.medal.locked { opacity: 0.48; }

.medal-face {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  background: radial-gradient(circle at 50% 30%, #ffe9a0, #e0a020 55%, #8a5a10);
  color: #4a2a08;
  box-shadow: inset 0 -6px 0 rgba(120, 70, 10, 0.25), 0 0 10px rgba(255, 210, 74, 0.35);
}

.medal.locked .medal-face {
  background: radial-gradient(circle at 50% 30%, #6a6490, #2a2748);
  color: #c9c4e0;
  box-shadow: none;
}

.profile-btn.frame-wins,
.avatar-lg.frame-wins,
.card-avatar.frame-wins,
.frame-preview.frame-wins {
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92)) padding-box,
    linear-gradient(160deg, #fff6c2, #ffb000 42%, #ff6a00) border-box;
  box-shadow: 0 0 14px rgba(255, 176, 40, 0.8);
}

.profile-btn.frame-day,
.avatar-lg.frame-day,
.card-avatar.frame-day,
.frame-preview.frame-day {
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92)) padding-box,
    linear-gradient(160deg, #fff1a8, #ffd24a 40%, #ff8a3d) border-box;
  box-shadow: 0 0 14px rgba(255, 210, 74, 0.75);
}

.profile-btn.frame-week,
.avatar-lg.frame-week,
.card-avatar.frame-week,
.frame-preview.frame-week {
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92)) padding-box,
    linear-gradient(160deg, #f4fbff, #7fd4ff 45%, #2a6cff) border-box;
  box-shadow: 0 0 14px rgba(80, 180, 255, 0.75);
}

.profile-btn.frame-month,
.avatar-lg.frame-month,
.card-avatar.frame-month,
.frame-preview.frame-month {
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92)) padding-box,
    conic-gradient(from 20deg, #fff1a8, #b06bff, #ffd24a, #ff4fa3, #fff1a8) border-box;
  box-shadow: 0 0 14px rgba(176, 107, 255, 0.75);
}

.profile-btn.frame-games,
.avatar-lg.frame-games,
.card-avatar.frame-games,
.frame-preview.frame-games {
  border: 3px solid transparent;
  background:
    radial-gradient(circle at 50% 35%, rgba(90, 160, 255, 0.45), rgba(16, 18, 52, 0.92)) padding-box,
    linear-gradient(160deg, #d9fff8, #2ad4c4 45%, #0e8f86) border-box;
  box-shadow: 0 0 14px rgba(42, 212, 196, 0.7);
}

.award-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe));
  transform: translateX(-50%);
  width: min(92vw, 400px);
  z-index: 40;
  margin: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(28, 18, 8, 0.94);
  border: 2px solid rgba(255, 210, 90, 0.8);
  color: #ffe9a8;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.award-toast[hidden] { display: none !important; }

@media (max-width: 360px) {
  #score { font-size: 1.45rem; }
  #combo { font-size: 1.35rem; }
  .combo-card { min-width: 86px; padding: 6px 10px; }
  .hud-crown { width: 34px; height: 26px; }
  .score-card { padding-right: 10px; }
}

@media (max-height: 740px) {
  #title { justify-content: flex-start; padding-top: 10px; overflow: auto; }
  .trophy { width: 64px; height: auto; margin-top: 0; }
  .crown { width: 46px; height: 36px; }
  #playBtn.play-main { font-size: 1.55rem; padding: 12px; }
  .primary { font-size: 1.2rem; padding: 11px 14px; }
  #tray { min-height: 78px; padding: 6px; }
  .slot { min-height: 66px; }
  #score { font-size: 1.5rem; }
  #combo { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .trophy { animation: none; }
  #comboWrap.hot #combo { animation: none; }
}
