@font-face {
  font-family: "DSEG7Mini";
  src:
    url("assets/DSEG7ClassicMini-Bold.woff2") format("woff2"),
    url("https://cdn.jsdelivr.net/npm/dseg@0.46.0/fonts/DSEG7-Classic-MINI/DSEG7ClassicMini-Bold.woff2") format("woff2"),
    url("https://unpkg.com/dseg@0.46.0/fonts/DSEG7-Classic-MINI/DSEG7ClassicMini-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #101522;
  --panel: rgba(255, 255, 255, 0.1);
  --panel-strong: rgba(255, 255, 255, 0.16);
  --text: #f8fbff;
  --muted: #aeb8ce;
  --line: rgba(255, 255, 255, 0.18);
  --accent: #67e8f9;
  --danger: #fb7185;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at 20% 8%, rgba(103, 232, 249, 0.22), transparent 28rem),
    radial-gradient(circle at 85% 18%, rgba(168, 85, 247, 0.2), transparent 26rem),
    linear-gradient(145deg, #0b1020, #151827 48%, #0f172a);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.list-view {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow,
.muted,
p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 64px);
}

h2 {
  font-size: 24px;
}

h3 {
  margin: 22px 0 12px;
}

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  margin-top: 22px;
}

.home-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.join-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.project-card,
.empty-card {
  min-height: 180px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.project-card {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.project-card h2 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
}

.project-card > div,
.project-meta,
.project-actions {
  min-width: 0;
}

.project-meta span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.project-colors {
  display: flex;
  gap: 8px;
}

.color-dot {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
}

.project-actions,
.dialog-actions,
.dialog-head,
.score-editor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-btn,
.ghost-btn,
.count-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-btn {
  padding: 12px 18px;
  border-color: rgba(103, 232, 249, 0.65);
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  color: #06111f;
  font-weight: 900;
}

.ghost-btn {
  padding: 11px 16px;
}

.count-btn {
  padding: 9px 14px;
}

.count-btn.active {
  border-color: rgba(103, 232, 249, 0.65);
  background: rgba(103, 232, 249, 0.18);
  color: var(--accent);
  font-weight: 800;
}

.danger {
  color: var(--danger);
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 22px;
}

button:hover {
  transform: translateY(-1px);
}

.active-toggle {
  border-color: rgba(134, 239, 172, 0.75);
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.14);
}

.game-view {
  position: fixed;
  inset: 0;
  overflow: visible;
  background: #0b1020;
  display: grid;
  grid-template-rows: 62px 1fr;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 56px);
  padding: 8px 18px;
  background: #111;
  color: #fff;
}

.game-title {
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
  text-align: center;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.2;
}

.sync-badge {
  position: fixed;
  z-index: 9;
  top: 10px;
  right: 12px;
  min-width: 72px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
}

.sync-badge[data-mode="online"] {
  background: rgba(34, 197, 94, 0.22);
}

.sync-badge[data-mode="offline"] {
  background: rgba(244, 63, 94, 0.25);
}

.sync-code {
  margin-top: 5px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.game-clock {
  color: rgba(255, 255, 255, 0.86);
  text-align: center;
  font-size: clamp(20px, 2.1vw, 32px);
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.game-timer {
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  font-weight: 900;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.2;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.scoreboard {
  display: grid;
  width: 100vw;
  height: 100%;
  min-height: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.scoreboard.layout-3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr;
}

.scoreboard.layout-4 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: 1fr;
}

.scoreboard.layout-5,
.scoreboard.layout-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.team-tile {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(76px, 24%) 1fr;
  background: var(--team-color);
  border-right: 1px solid rgba(0, 0, 0, 0.16);
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.team-tile.scored {
  animation: scored-flash 220ms ease-out;
}

@keyframes scored-flash {
  0% {
    filter: brightness(1.28);
  }
  100% {
    filter: brightness(1);
  }
}

.team-name {
  position: relative;
  z-index: 2;
  align-self: start;
  justify-self: center;
  max-width: calc(100% - 36px);
  margin-top: clamp(26px, 5vh, 74px);
  border: 0;
  background: transparent;
  color: white;
  font-size: clamp(30px, 4vw, 68px);
  font-weight: 950;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.score-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.score-click {
  position: absolute;
  left: 0;
  z-index: 3;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: transparent;
  transform: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.score-click.plus {
  top: 0;
  height: 50%;
}

.score-click.minus {
  bottom: 0;
  height: 50%;
}

.score-click:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.55);
  font-size: clamp(32px, 5vw, 64px);
}

.score-click.holding {
  background: rgba(255, 255, 255, 0.18);
  color: transparent;
  font-size: clamp(32px, 5vw, 64px);
}

.score-click.holding::before {
  position: absolute;
  left: 50%;
  top: 50%;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(34px, 5vw, 68px);
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.score-click.plus.holding::before {
  content: "+1";
}

.score-click.minus.holding::before {
  content: "-1";
}

.score-click.holding::after {
  content: "按住计分";
  position: absolute;
  left: 50%;
  bottom: 14px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
  color: #fff;
  font-size: 14px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.led-score {
  z-index: 2;
  pointer-events: none;
  box-sizing: border-box;
  width: 100%;
  max-width: 96%;
  padding: 0 2%;
  overflow: visible;
  color: #fff;
  font-family: "DSEG7Mini", "Digital-7", "DS-Digital", monospace;
  font-size: 120px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  text-align: center;
  text-shadow: none;
  transform: scaleX(0.82);
  transform-origin: center;
  white-space: nowrap;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.layout-5 .team-tile,
.layout-6 .team-tile {
  grid-template-rows: minmax(58px, 28%) 1fr;
}

.layout-5 .team-name,
.layout-6 .team-name {
  margin-top: clamp(12px, 2.2vh, 28px);
  font-size: clamp(24px, 3vw, 48px);
}

.layout-5 .led-score,
.layout-6 .led-score {
  transform: translateY(-4%) scaleX(0.86);
}

.float-btn {
  position: fixed;
  z-index: 8;
  bottom: 36px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: white;
  font-size: 30px;
  box-shadow: none;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.96);
  transition: opacity 180ms ease, transform 180ms ease;
}

.game-view.controls-visible .float-btn,
.float-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.back-btn {
  left: 36px;
}

.menu-btn {
  right: 36px;
}

.app-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 0;
  overflow: auto;
  background: #111827;
  color: var(--text);
  box-shadow: var(--shadow);
}

.small-dialog {
  width: min(430px, calc(100vw - 32px));
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(5px);
}

.app-dialog form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.label-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  background: rgba(5, 10, 22, 0.75);
  color: var(--text);
}

input[type="color"] {
  height: 43px;
  padding: 4px;
}

.team-count {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.team-setup {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.setup-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.score-editor input {
  text-align: center;
  font-size: 22px;
  font-weight: 900;
}

.confirm-message {
  color: var(--text);
  font-size: 17px;
  line-height: 1.6;
}

.qr-panel {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 260px;
  border-radius: 20px;
  background: #fff;
}

.qr-box img {
  width: min(320px, 100%);
  height: auto;
}

.side-menu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.35);
}

.side-menu.open {
  display: flex;
}

.side-panel {
  width: min(460px, 92vw);
  height: 100%;
  padding: 22px;
  overflow: auto;
  background: rgba(17, 24, 39, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.menu-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li,
.empty-history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.change-plus {
  color: #86efac;
}

.change-minus {
  color: #fda4af;
}

@media (max-width: 820px) {
  .list-header,
  .header-actions,
  .project-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .game-top {
    gap: 8px;
    padding: 7px 8px;
  }

  .game-view {
    grid-template-rows: 54px 1fr;
  }

  .game-title {
    max-width: 28vw;
    font-size: 15px;
  }

  .game-clock {
    font-size: 14px;
  }

  .game-timer {
    font-size: 15px;
  }

  .scoreboard.layout-3,
  .scoreboard.layout-4,
  .scoreboard.layout-5,
  .scoreboard.layout-6 {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: auto;
  }

  .team-tile {
    min-height: 34vh;
  }

  .score-click:hover {
    background: transparent;
    color: transparent;
  }

  .score-click.holding {
    background: rgba(255, 255, 255, 0.18);
    color: transparent;
  }

  .team-name {
    font-size: 34px;
    margin-top: 42px;
  }

  .led-score {
    font-size: 82px;
  }

  .float-btn {
    width: 48px;
    height: 48px;
    bottom: 20px;
    font-size: 26px;
  }

  .back-btn {
    left: 20px;
  }

  .menu-btn {
    right: 20px;
  }
}
