/* 极简 · 单文件 · 系统字体（不依赖外网） */
:root {
  --bg: #eceff1;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --line: #ddd;
  --accent: #0284c7;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

.hidden {
  display: none !important;
}

/* 登录 */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
}

.auth-gate .card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.auth-gate h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.auth-gate .sub {
  margin: 0 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f5f5f5;
  cursor: pointer;
  font: inherit;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.form input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.cap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px;
  background: #f5f5f5;
  border-radius: 6px;
  font-weight: 700;
}

.err {
  min-height: 1.2em;
  margin: 10px 0 0;
  color: #c00;
  font-size: 0.85rem;
}

/* 按钮 */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  width: 100%;
  padding: 10px;
}

.btn.sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn.full {
  width: 100%;
  margin-top: 8px;
}

.btn.mini {
  width: auto;
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* 主界面 */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.bar .who {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(150px, 170px) 1fr;
  gap: 12px;
  padding: 12px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 640px) {
  .main {
    grid-template-columns: 1fr;
  }
}

.side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  height: fit-content;
}

.nums {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.85rem;
}

.nums div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.nums span {
  color: var(--muted);
}

.nums b {
  font-size: 1.1rem;
}

.eq-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 0.8rem;
}

.eq-row em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.btn.half {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  font-size: 0.85rem;
}

.play {
  min-width: 0;
}

.frame {
  position: relative;
  border: 2px solid #333;
  border-radius: 6px;
  overflow: hidden;
  background: #0f172a;
}

.frame.is-fever {
  border-color: #e11d48;
}

.frame.is-burst {
  border-color: #d97706;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 280px;
  touch-action: none;
  cursor: crosshair;
  vertical-align: middle;
}

/* HUD 在画布顶部，避免遮挡下方湖面与点击 */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 6px 10px;
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.2) 100%);
  color: #fff;
  font-size: 0.8rem;
  pointer-events: none;
  z-index: 4;
}

.hud.on {
  display: flex;
}

.hud-left {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hud-label {
  font-size: 0.7rem;
  opacity: 0.85;
}

.hud-big {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.hud-mid {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.8rem;
}

.hud-mid b {
  font-weight: 700;
}

.hud-hearts {
  letter-spacing: 2px;
}

/* 头衔解锁全屏动画（在画布区域内） */
.title-fx {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, rgba(251, 191, 36, 0.25) 0%, rgba(0, 0, 0, 0.45) 70%);
}

.title-fx.hidden {
  display: none !important;
}

.title-fx:not(.hidden) {
  display: flex;
  animation: titleFxBg 0.5s ease-out;
}

.title-fx-card {
  text-align: center;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.35);
}

.title-fx-card.pop {
  animation: titleFxPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.title-fx-k {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}

.title-fx-name {
  display: block;
  font-size: 1.35rem;
  color: var(--text);
  margin-bottom: 4px;
}

.title-fx-tier {
  font-size: 0.78rem;
  color: var(--accent);
}

@keyframes titleFxPop {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes titleFxBg {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.end-titles {
  font-size: 0.88rem;
  color: var(--accent);
  text-align: center;
  margin: 0 0 8px;
  min-height: 0;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.sheet-lg {
  max-width: 560px;
}

.sheet-pad {
  padding: 10px 12px 12px;
}

.titles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
}

.t-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.88rem;
}

.t-row.locked {
  opacity: 0.55;
}

.t-row .nm {
  font-weight: 700;
}

.t-row .meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  max-height: 55vh;
  overflow: auto;
}

.g-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafafa;
  font-size: 0.82rem;
}

.g-card.locked {
  background: #f0f0f0;
  color: var(--muted);
}

.g-card .gn {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.g-card.locked .gn {
  color: var(--muted);
}

.g-card .gt {
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.g-card .gd {
  margin: 0;
  line-height: 1.35;
  color: var(--muted);
}

.cover {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
}

.cover.on {
  display: flex;
}

.cover p {
  margin: 0;
  color: var(--muted);
}

.cover .btn {
  width: auto;
  min-width: 120px;
}

.frame.shake-hit {
  animation: sh 0.35s ease;
}

@keyframes sh {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-3px, 2px);
  }
  75% {
    transform: translate(3px, -2px);
  }
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.sheet {
  background: var(--card);
  border-radius: 8px;
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
}

.sheet-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.sheet-b {
  overflow: auto;
  padding: 8px;
}

.tb {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tb th,
.tb td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.tb th {
  color: var(--muted);
  font-size: 0.75rem;
}

.muted {
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  padding: 8px 16px;
  background: #222;
  color: #fff;
  border-radius: 20px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 90vw;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
