:root {
  --pink: #ff5fa8;
  --pink-deep: #e0407f;
  --lilac: #b693ff;
  --cream: #fff6fb;
  --ink: #5a2350;
  --glass: rgba(255, 246, 251, 0.86);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #ffd6ec;
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font-family: inherit; cursor: pointer; border: 0; }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 12px; pointer-events: none; z-index: 5;
}
#hud > * { pointer-events: auto; }

.startng-card {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; border-radius: 999px;
  background: var(--glass); box-shadow: 0 4px 16px rgba(224, 64, 127, 0.25);
  border: 2px solid #ffc2e0; max-width: 46vw;
}
.startng-card img {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #ffc2e0, #d9c6ff); flex: none; object-fit: cover;
}
.startng-card img:not([src]), .startng-card img[src=""] { visibility: hidden; }
.startng-card .who { min-width: 0; }
.startng-card b, .startng-card span {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.startng-card b { font-size: 16px; font-weight: 700; }
.startng-card span { font-size: 12px; opacity: 0.7; }

.pill {
  margin-left: 4px; border-radius: 999px; padding: 6px 12px;
  background: var(--pink); color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: 0 3px 0 var(--pink-deep); white-space: nowrap;
}

#scorebox {
  text-align: center; padding: 4px 18px; border-radius: 20px;
  background: var(--glass); border: 2px solid #ffc2e0; min-width: 90px;
}
#score { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--pink-deep); }
#combo { font-size: 13px; font-weight: 600; color: #9b5de5; min-height: 16px; }

#right { display: flex; align-items: center; gap: 6px; }
#lives { white-space: nowrap; font-size: 15px; letter-spacing: 1px; line-height: 1.3; filter: drop-shadow(0 2px 2px rgba(224,64,127,.3)); }
.icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--glass); border: 2px solid #ffc2e0; color: var(--pink-deep);
  font-size: 16px; font-weight: 700;
}
.icon.off { opacity: 0.45; text-decoration: line-through; }

#powers {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 5; pointer-events: none;
}
#powers div {
  background: var(--glass); border-radius: 999px; padding: 3px 12px;
  font-weight: 600; font-size: 14px; border: 2px solid #ffc2e0;
}

#toast {
  position: fixed; top: 110px; left: 50%; z-index: 6; pointer-events: none;
  transform: translate(-50%, -10px) scale(.9); opacity: 0;
  background: #fff; color: var(--pink-deep); font-weight: 700; font-size: 20px;
  padding: 10px 22px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 6px 24px rgba(224, 64, 127, .35); border: 3px solid #ffc2e0;
}
#toast.show { animation: toast 2.2s ease forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(.9); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(.96); }
}

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 80px 16px 16px; overflow-y: auto;
  background: radial-gradient(circle at 50% 40%, rgba(255,214,236,.35), rgba(181,120,220,.35));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.overlay[hidden] { display: none; }

.panel {
  width: min(440px, 100%); margin: auto;
  background: var(--glass); border-radius: 28px; padding: 22px 22px 18px;
  text-align: center; border: 3px solid #fff;
  box-shadow: 0 10px 40px rgba(181, 64, 140, 0.3), inset 0 0 0 2px #ffc2e0;
  animation: pop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.panel.slim { width: min(320px, 100%); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

h1 {
  margin: 0; font-size: clamp(40px, 11vw, 58px); line-height: 1; font-weight: 700;
  color: var(--lilac); text-shadow: 0 3px 0 #fff, 0 6px 0 rgba(155,93,229,.25);
}
h1 span { color: var(--pink); }
h2 { margin: 0 0 8px; font-size: 34px; color: var(--pink); text-shadow: 0 3px 0 #fff; }
h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: #9b5de5; }

.tag { margin: 8px 0 12px; font-size: 16px; }
.hint { margin: 10px 0 4px; font-size: 13px; opacity: .65; }

.legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.legend div {
  background: #fff; border-radius: 14px; padding: 4px 8px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 4px; border: 2px solid #ffe0ef;
}
.legend.small div { font-size: 12px; }
.legend .bad { border-color: #d8d2e8; color: #6b6280; }
.legend i { font-style: normal; font-size: 18px; }

.big {
  margin-top: 12px; padding: 14px 40px; border-radius: 999px;
  background: linear-gradient(180deg, #ff86bd, var(--pink));
  color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 5px 0 var(--pink-deep), 0 10px 20px rgba(224,64,127,.3);
  transition: transform .1s;
}
.big:hover { transform: translateY(-2px); }
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--pink-deep); }

.daily {
  margin: 12px auto 4px; padding: 8px 12px; border-radius: 16px; max-width: 340px;
  background: linear-gradient(135deg, #fff, #ffeef7); border: 2px dashed #ff9cc9;
  display: flex; flex-direction: column; gap: 2px;
}
.daily b { font-size: 14px; color: #9b5de5; }
.daily span { font-size: 15px; font-weight: 600; }
.daily em { font-style: normal; font-size: 12px; color: #e07b00; font-weight: 600; }
.daily.done { border-style: solid; border-color: #ffd24d; background: linear-gradient(135deg, #fffbe6, #fff0f8); }

.baskets { margin-top: 10px; }
#basket-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.basket {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 5px; border-radius: 999px;
  background: #fff; border: 2px solid #ffe0ef; color: var(--ink); font-weight: 600; font-size: 12px;
}
.basket i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #ffc2e0; }
.basket.on { border-color: var(--pink); background: #ffeef7; box-shadow: 0 2px 0 var(--pink-deep); }
.basket.locked { opacity: .55; cursor: not-allowed; }

#over-extra { display: flex; flex-direction: column; gap: 6px; align-items: center; }
#over-extra .unlock {
  background: linear-gradient(90deg, #fff0a8, #ffd1e8); border-radius: 14px; padding: 8px 12px; font-weight: 700;
}
#over-extra .next { font-size: 13px; opacity: .8; }
.link {
  display: block; margin: 10px auto 0; background: none; color: #9b5de5; font-weight: 600; font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px;
}

.final { display: flex; justify-content: center; gap: 10px; margin: 6px 0; }
.final div { background: #fff; border-radius: 18px; padding: 8px 12px; min-width: 88px; border: 2px solid #ffe0ef; }
.final b { display: block; font-size: 26px; color: var(--pink-deep); }
.final span { font-size: 12px; opacity: .7; }

.board-wrap { margin-top: 16px; text-align: left; }
.board-wrap h3 { text-align: center; }
.board { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow-y: auto; }
.board li {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; font-size: 14px;
}
.board li:nth-child(odd) { background: rgba(255, 194, 224, .35); }
.board li.me { background: #ffe066; font-weight: 700; }
.board li.empty { justify-content: center; opacity: .6; background: none; }
.board .rank { width: 26px; font-weight: 700; color: #9b5de5; }
.board .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.board .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 700; color: var(--pink-deep); }
.board .dia { font-size: 12px; opacity: .75; width: 44px; text-align: right; }

@media (max-width: 520px) {
  .startng-card { padding-right: 10px; }
  .startng-card img { width: 36px; height: 36px; }
  .startng-card b { font-size: 14px; }
  #score { font-size: 22px; }
  #lives { font-size: 17px; }
  .icon { width: 30px; height: 30px; font-size: 12px; }
  #right { gap: 4px; }
  #toast { font-size: 16px; top: 96px; }
  #hud { padding: 8px; }
  #powers { top: 64px; }
  #scorebox { min-width: 64px; padding: 4px 10px; }
  #lives { font-size: 12px; letter-spacing: 0; }
  .startng-card { max-width: 50vw; gap: 6px; }
  .startng-card .who { min-width: 52px; }
  .startng-card .pill { padding: 5px 8px; font-size: 12px; margin-left: 0; }
  #scorebox { min-width: 58px; }
  .startng-card span { display: none; }
}
