:root {
  --ink: #172b3a;
  --muted: #657987;
  --paper: #fffdf8;
  --cream: #f7f4ed;
  --line: #dfe8e8;
  --teal: #167d75;
  --teal-dark: #0f625c;
  --teal-soft: #dff3ee;
  --coral: #ee7258;
  --yellow: #f3bd51;
  --shadow: 0 20px 55px rgba(37, 74, 78, .12);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(243, 189, 81, .2), transparent 23rem),
    radial-gradient(circle at 92% 82%, rgba(22, 125, 117, .17), transparent 26rem),
    linear-gradient(145deg, #f7faf6 0%, #f3f6f0 52%, #f8f2e8 100%);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }

.svg-icon {
  width: 1.2em;
  height: 1.2em;
  display: inline-block;
  flex: 0 0 auto;
  overflow: visible;
  vertical-align: -.18em;
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.ambient {
  position: fixed;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .6;
  pointer-events: none;
}

.ambient.one { top: -155px; left: -90px; background: rgba(243, 189, 81, .16); }
.ambient.two { right: -130px; bottom: -180px; background: rgba(22, 125, 117, .14); }

.topbar {
  min-height: 52px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-link, .bgm-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 14px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  box-shadow: 0 7px 24px rgba(37, 74, 78, .08);
  backdrop-filter: blur(12px);
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.home-link:hover, .bgm-toggle:hover {
  transform: translateY(-2px);
  background: #fff;
  box-shadow: 0 10px 28px rgba(37, 74, 78, .13);
}

.bgm-toggle.muted { color: var(--muted); }
.bgm-toggle .music-off { display: none; }
.bgm-toggle.muted .music-on { display: none; }
.bgm-toggle.muted .music-off { display: inline-block; }

.main-container {
  width: 100%;
  position: relative;
  border: 1px solid rgba(255, 255, 255, .94);
  border-radius: 34px;
  padding: 30px;
  background: rgba(255, 253, 248, .84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 4px 6px 26px;
}

.eyebrow {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.header h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.5rem, 5vw, 5.15rem);
  font-weight: 900;
  line-height: .98;
  letter-spacing: -.055em;
}

.header h1 .title-mark { color: var(--coral); }

.sub-header {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.18rem);
  line-height: 1.7;
}

.sub-header strong { color: var(--teal-dark); }

.hero-card {
  min-width: 220px;
  border: 1px solid #d6ebe6;
  border-radius: 24px;
  padding: 20px 22px;
  background: linear-gradient(145deg, #effaf6, #e5f4ef);
}

.hero-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.progress-line { margin-top: 14px; display: flex; align-items: baseline; gap: 7px; }
.progress-number { font-size: 2.7rem; line-height: 1; font-weight: 900; color: var(--teal); }
.progress-total { color: var(--muted); font-weight: 700; }

.progress-track {
  height: 7px;
  margin-top: 13px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(22, 125, 117, .12);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #46ad99);
  transition: width .45s ease;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin: 0 0 22px;
  padding: 7px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f1f5f2;
  scrollbar-width: thin;
}

.tab-button {
  min-width: 76px;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 9px 13px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s ease, background .2s ease, box-shadow .2s ease, transform .2s ease;
}

.tab-button:hover { color: var(--ink); background: rgba(255,255,255,.7); }
.tab-button.active { color: #fff; background: var(--teal); box-shadow: 0 6px 16px rgba(22,125,117,.25); }
.tab-button:active { transform: scale(.96); }

.row-split {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(300px, .72fr);
  gap: 22px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255,255,255,.66);
}

.bubbles-area { padding: 22px; }

.panel-heading {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
}

.panel-note { color: var(--muted); font-size: 13px; font-weight: 650; }

.bubbles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 12px;
}

.bubble {
  min-height: 72px;
  position: relative;
  overflow: hidden;
  border: 1px solid #dbe9e5;
  border-radius: 18px;
  padding: 13px 8px;
  background: linear-gradient(145deg, #fff, #f3faf7);
  color: #28414b;
  box-shadow: 0 5px 13px rgba(37, 74, 78, .07);
  font: inherit;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, color .2s ease;
  animation: rise .36s both;
  animation-delay: calc(var(--order, 0) * 12ms);
}

.bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--teal);
  opacity: .72;
}

.bubble:hover {
  z-index: 1;
  transform: translateY(-3px);
  border-color: #a9d8ce;
  color: var(--teal-dark);
  box-shadow: 0 12px 22px rgba(37, 74, 78, .13);
}

.bubble:active { transform: translateY(0) scale(.97); }
.bubble.hidden-bubble { display: none; pointer-events: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.leaderboard-area {
  min-height: 430px;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, #fffaf0, #fffdf8);
  border-color: #efe5cf;
}

.live-badge {
  margin: 0 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.live-title { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 850; }
.live-chip { padding: 5px 8px; border-radius: 7px; background: #ffe7e1; color: #c64f3d; font-size: 10px; font-weight: 900; letter-spacing: .1em; }

.leaderboard-list {
  max-height: 568px;
  margin: 0;
  padding: 0 6px 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #bfd0cc transparent;
}

.leaderboard-item {
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #ece9df;
  border-radius: 15px;
  padding: 9px 9px 9px 10px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 4px 11px rgba(74,66,48,.05);
  animation: rise .24s both;
}

.leaderboard-item .rank {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  background: #edf3f1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.leaderboard-item .name { min-width: 0; flex: 1; font-size: 15px; font-weight: 850; }
.leaderboard-item.top1 .rank { background: #fff0bd; color: #9b6b00; }
.leaderboard-item.top2 .rank { background: #e9eef1; color: #526774; }
.leaderboard-item.top3 .rank { background: #f8ded0; color: #a55c37; }

.delete-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #a6b0b4;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.delete-btn:hover { color: #c9503f; background: #fff0ed; }
.delete-btn .svg-icon { width: 17px; height: 17px; }

.empty-state {
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.empty-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #eef7f4;
  color: var(--teal);
}

.empty-icon .svg-icon { width: 28px; height: 28px; }

.leaderboard-hint {
  margin: 14px 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.cheer-message {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 999;
  max-width: min(620px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255,255,255,.95);
  border-radius: 18px;
  padding: 14px 20px;
  background: rgba(23, 43, 58, .94);
  color: #fff;
  box-shadow: 0 18px 45px rgba(19,43,50,.3);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 22px) scale(.96);
  transition: opacity .22s ease, transform .28s cubic-bezier(.2,.8,.2,1);
  font-size: 16px;
  font-weight: 800;
}

.cheer-message.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.cheer-message .cheer-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--yellow); color: #5d4308; }

.index-body { display: grid; place-items: center; }
.index-wrap { width: min(920px, 100%); position: relative; z-index: 2; }
.index-brand { margin-bottom: 26px; display: flex; align-items: center; gap: 13px; color: var(--teal-dark); font-size: 15px; font-weight: 850; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--teal); color: #fff; box-shadow: 0 10px 24px rgba(22,125,117,.25); }
.index-card { border: 1px solid rgba(255,255,255,.95); border-radius: 34px; padding: clamp(28px, 5vw, 58px); background: rgba(255,253,248,.86); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.index-kicker { margin: 0 0 12px; color: var(--coral); font-size: 13px; font-weight: 900; letter-spacing: .16em; }
.index-card h1 { max-width: 670px; margin: 0; font-size: clamp(2.4rem, 7vw, 5.2rem); line-height: 1.04; letter-spacing: -.055em; }
.index-desc { max-width: 580px; margin: 20px 0 30px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.class-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 0; padding: 0; list-style: none; }
.class-link { min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: #fff; color: var(--ink); text-decoration: none; box-shadow: 0 6px 18px rgba(37,74,78,.06); transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease; }
.class-link:hover { transform: translateY(-4px); border-color: #9dcec5; box-shadow: 0 15px 28px rgba(37,74,78,.12); }
.class-link-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.class-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--teal-soft); color: var(--teal); }
.class-arrow { color: #9badb2; }
.class-name { font-size: 19px; font-weight: 900; }
.empty-class { grid-column: 1 / -1; padding: 28px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }

:focus-visible { outline: 3px solid rgba(22,125,117,.34); outline-offset: 3px; }

@media (max-width: 900px) {
  body { padding: 18px; }
  .main-container { padding: 20px; border-radius: 27px; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-card { width: 100%; min-width: 0; }
  .row-split { grid-template-columns: 1fr; }
  .leaderboard-area { min-height: 0; }
  .leaderboard-list { max-height: 400px; }
}

@media (max-width: 640px) {
  body { padding: 12px; }
  .topbar { margin-bottom: 10px; }
  .home-link span, .bgm-toggle .label { display: none; }
  .home-link, .bgm-toggle { width: 44px; padding: 0; }
  .main-container { padding: 14px; border-radius: 22px; }
  .hero { padding: 9px 4px 20px; gap: 20px; }
  .header h1 { font-size: 2.55rem; }
  .tab-bar { margin-bottom: 14px; border-radius: 14px; }
  .tab-button { min-width: 68px; }
  .panel { border-radius: 20px; }
  .bubbles-area { padding: 16px; }
  .panel-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .bubbles-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
  .bubble { min-height: 62px; border-radius: 14px; padding: 9px 4px; font-size: 13px; }
  .cheer-message { bottom: 16px; font-size: 14px; }
  .class-list { grid-template-columns: 1fr; }
  .class-link { min-height: 105px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
