@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 200 700;
  font-display: block;
  src: url(fonts/oswald-latin.woff2) format("woff2");
}
html, body {
  margin: 0;
  height: 100%;
  background: #6fb9e6;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game {
  display: block;
  touch-action: none;
  cursor: pointer;
  outline: none;
}
#ui {
  --u: 0.6px;               /* CSS pixels per design unit, set by game.js */
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  font-family: Oswald, "Arial Narrow", sans-serif;
  color: #1d1d1d;
  pointer-events: none;
}
#ui > * { pointer-events: auto; }
#ui:empty { display: none; }
#ui button { font: inherit; cursor: pointer; }
#ui button:focus-visible { outline: 3px solid #ffd21f; outline-offset: 2px; }

/* ---- song list (UIMusic): white cards on the blue bokeh ---- */
#ui.menu {
  display: flex;
  flex-direction: column;
  background: linear-gradient(#c8ecfb, #7fcaf2);
}
#ui .top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(18 * var(--u)) calc(26 * var(--u));
  background: #2d9bd6;
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
#ui .logo { display: flex; align-items: baseline; gap: calc(10 * var(--u)); }
#ui .logo b { font-weight: 500; font-size: calc(44 * var(--u)); letter-spacing: .5px; }
#ui .logo i {
  font-style: normal; font-weight: 600; font-size: calc(46 * var(--u));
  background: #fff; color: #2d9bd6; border-radius: 50%;
  width: calc(58 * var(--u)); height: calc(58 * var(--u));
  display: inline-flex; align-items: center; justify-content: center;
}
#ui .sound {
  border: 0; border-radius: 999px; background: rgba(255, 255, 255, .22); color: #fff;
  font-size: calc(28 * var(--u)); padding: calc(6 * var(--u)) calc(20 * var(--u));
}
#ui .songs {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(14 * var(--u)) calc(18 * var(--u)) 0;
  touch-action: pan-y;
}
#ui .card {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(16 * var(--u));
  background: #fff;
  border-radius: calc(14 * var(--u));
  margin-bottom: calc(14 * var(--u));
  padding: calc(16 * var(--u)) calc(20 * var(--u));
  box-shadow: 0 calc(3 * var(--u)) calc(8 * var(--u)) rgba(30, 90, 140, .18);
}
#ui .badge {
  position: absolute; left: calc(12 * var(--u)); top: calc(12 * var(--u));
  min-width: calc(36 * var(--u)); height: calc(36 * var(--u)); border-radius: 999px;
  background: #ffb31a; color: #fff; font-size: calc(22 * var(--u));
  display: flex; align-items: center; justify-content: center; padding: 0 calc(4 * var(--u));
  box-sizing: border-box;
}
#ui .info { flex: 1; min-width: 0; padding-left: calc(40 * var(--u)); }
#ui .title { font-size: calc(34 * var(--u)); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ui .composer { font-size: calc(22 * var(--u)); color: #9a9a9a; font-weight: 300; margin-top: calc(2 * var(--u)); }
#ui .row { display: flex; align-items: center; gap: calc(12 * var(--u)); margin-top: calc(8 * var(--u)); }
#ui .best { font-size: calc(22 * var(--u)); color: #7a7a7a; font-weight: 300; }
#ui .play {
  flex: none;
  border: 0; border-radius: 999px; background: #2d9bd6; color: #fff;
  font-size: calc(34 * var(--u)); padding: calc(10 * var(--u)) calc(40 * var(--u));
  box-shadow: 0 calc(3 * var(--u)) 0 #1f7fb4;
}
#ui .play:active { transform: translateY(2px); box-shadow: none; }
#ui .rank {
  width: calc(44 * var(--u)); height: calc(44 * var(--u)); border-radius: 50%;
  border: calc(3 * var(--u)) solid #ffb31a; background: #fff; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
#ui .more { text-align: center; color: #fff; font-size: calc(26 * var(--u)); font-weight: 300; margin: calc(6 * var(--u)) 0 calc(30 * var(--u)); }

/* Icons drawn in CSS/SVG. */
#ui .bars {
  display: inline-block; width: 60%; height: 60%;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg fill='%23ffb31a'%3E%3Crect x='2' y='9' width='4' height='9' rx='1'/%3E%3Crect x='8' y='3' width='4' height='15' rx='1'/%3E%3Crect x='14' y='6' width='4' height='12' rx='1'/%3E%3C/g%3E%3C/svg%3E");
}
#ui .stars { display: inline-flex; gap: calc(4 * var(--u)); }
#ui .st {
  display: inline-block; width: calc(34 * var(--u)); height: calc(34 * var(--u));
  background: no-repeat center/contain;
}
#ui .st.star { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23d8d8d8' d='M12 1.8l3 6.6 7.2.8-5.4 4.9 1.5 7.1L12 17.6l-6.3 3.6 1.5-7.1L1.8 9.2 9 8.4z'/%3E%3C/svg%3E"); }
#ui .st.star.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffb31a' d='M12 1.8l3 6.6 7.2.8-5.4 4.9 1.5 7.1L12 17.6l-6.3 3.6 1.5-7.1L1.8 9.2 9 8.4z'/%3E%3C/svg%3E"); }
#ui .st.crown { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23cfcfcf' d='M2 7l5 5 5-8 5 8 5-5-2 13H4z'/%3E%3C/svg%3E"); }
#ui .st.crown.on { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffb31a' d='M2 7l5 5 5-8 5 8 5-5-2 13H4z'/%3E%3C/svg%3E"); }
#ui .st.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(2); opacity: .2; } 100% { transform: scale(1); opacity: 1; } }

/* ---- result (UISuccess / UIFailure) ---- */
#ui.result { display: flex; flex-direction: column; background: #f4f6f8; }
#ui .rhead {
  flex: none; background: #2d9bd6; color: #fff; text-align: center;
  font-size: calc(46 * var(--u)); font-weight: 400;
  padding: calc(40 * var(--u)) calc(20 * var(--u)) calc(34 * var(--u));
}
#ui .rcard {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding-top: calc(50 * var(--u)); background: #fff;
}
#ui .rcard .stars { gap: calc(16 * var(--u)); }
#ui .rcard .st { width: calc(76 * var(--u)); height: calc(76 * var(--u)); }
#ui .phrase { margin-top: calc(14 * var(--u)); font-size: calc(30 * var(--u)); color: #2d9bd6; font-weight: 400; }
#ui .score { position: relative; font-size: calc(170 * var(--u)); line-height: 1.05; font-weight: 500; margin-top: calc(6 * var(--u)); }
#ui .newbest {
  position: absolute; right: calc(-78 * var(--u)); top: calc(26 * var(--u));
  width: calc(76 * var(--u)); height: calc(76 * var(--u)); border-radius: 50%;
  background: #2d9bd6; color: #fff; font-size: calc(18 * var(--u)); line-height: 1; font-weight: 500; padding: calc(8 * var(--u)); box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; text-align: center; transform: rotate(-12deg);
}
#ui .rbest { font-size: calc(30 * var(--u)); color: #8a8a8a; font-weight: 300; }
#ui .rbuttons { display: flex; gap: calc(34 * var(--u)); margin-top: calc(56 * var(--u)); }
#ui .round {
  width: calc(88 * var(--u)); height: calc(88 * var(--u)); border-radius: 50%;
  border: calc(4 * var(--u)) solid #2d9bd6; background: #fff; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
#ui .round .bars { filter: hue-rotate(170deg) saturate(1.4) brightness(.9); }
#ui .i-list, #ui .i-share, #ui .i-retry { display: inline-block; width: 55%; height: 55%; background: no-repeat center/contain; }
#ui .i-list { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg fill='%232d9bd6'%3E%3Crect x='2' y='3' width='16' height='3' rx='1.5'/%3E%3Crect x='2' y='8.5' width='16' height='3' rx='1.5'/%3E%3Crect x='2' y='14' width='16' height='3' rx='1.5'/%3E%3C/g%3E%3C/svg%3E"); }
#ui .i-share { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cg fill='%232d9bd6'%3E%3Ccircle cx='15' cy='4' r='3'/%3E%3Ccircle cx='5' cy='10' r='3'/%3E%3Ccircle cx='15' cy='16' r='3'/%3E%3C/g%3E%3Cpath d='M15 4L5 10l10 6' stroke='%232d9bd6' stroke-width='1.8' fill='none'/%3E%3C/svg%3E"); }
#ui .i-retry { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M16 10a6 6 0 1 1-2-4.5' stroke='%23fff' stroke-width='2.6' fill='none' stroke-linecap='round'/%3E%3Cpath d='M15.5 1.5v5h-5' fill='%23fff'/%3E%3C/svg%3E"); }
#ui .retry {
  margin-top: calc(44 * var(--u)); width: calc(400 * var(--u)); height: calc(88 * var(--u));
  border: 0; border-radius: 999px; background: #2d9bd6; box-shadow: 0 calc(4 * var(--u)) 0 #1f7fb4;
  display: flex; align-items: center; justify-content: center;
}
#ui .retry .i-retry { width: calc(50 * var(--u)); height: calc(50 * var(--u)); }
#ui .retry:active { transform: translateY(2px); box-shadow: none; }

/* ---- pause (UIPause) ---- */
#ui.dialog-wrap { display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .35); }
#ui .dialog { width: calc(480 * var(--u)); background: #fff; border-radius: calc(16 * var(--u)); overflow: hidden; text-align: center; }
#ui .dlg-title { background: #2d9bd6; color: #fff; font-size: calc(42 * var(--u)); padding: calc(26 * var(--u)); }
#ui .dlg-buttons { display: flex; gap: calc(20 * var(--u)); padding: calc(34 * var(--u)); justify-content: center; }
#ui .pill {
  border: 0; border-radius: 999px; background: #2d9bd6; color: #fff;
  font-size: calc(32 * var(--u)); padding: calc(12 * var(--u)) calc(42 * var(--u));
}
#ui .pill.ghost { background: #e8f3fa; color: #2d9bd6; }

#toast {
  position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%); z-index: 60;
  background: rgba(0, 0, 0, .75); color: #fff; padding: 8px 16px; border-radius: 999px;
  font: 400 16px/1.3 Oswald, sans-serif;
}
#toast[hidden] { display: none; }
