:root {
  color-scheme: light;
  --bg: #f7f1e6;
  --ink: #16211d;
  --muted: #6d756f;
  --line: #ddd0ba;
  --panel: #fffdf8;
  --accent: #0d715d;
  --accent-strong: #095544;
  --red: #b73333;
  --blue: #1d609a;
  --gold: #a56f16;
  --loss: #b73333;
  --win: #0d715d;
  --soft: #eef6ef;
  --tile: #fffaf0;
  --shadow: 0 16px 36px rgba(43, 34, 20, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #fff;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(13, 113, 93, 0.16);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 18px;
  height: 194px;
  margin-bottom: 14px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, #fffdf8 0%, #f6efe2 100%);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}

.brand-heading {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  margin-left: 0;
  filter: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.hero-subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.topbar-actions,
.section-head,
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-actions {
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.home-panel {
  display: none;
  gap: 14px;
  margin-bottom: 22px;
}

.home-mode .home-panel {
  display: grid;
}

.home-mode .top-tools,
.home-mode .formed-events-panel,
.home-mode .summary-grid,
.home-mode .stats-filter,
.home-mode .workspace,
.home-mode .ranking-panel,
.home-mode .history-panel,
.home-mode .share-panel,
.home-mode .notice-panel {
  display: none;
}

.home-card,
.home-tool-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.home-card {
  padding: 18px;
}

.home-card h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 26px;
}

.home-card p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.home-room-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

/* Recent rooms */
#recentRooms { margin-top: 12px; }
.recent-rooms-label {
  font-size: 12px;
  color: var(--muted, #999);
  margin: 0 0 6px;
  font-weight: 600;
}
.recent-rooms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recent-room-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--accent, #0d715d);
  background: #fff;
  color: var(--accent, #0d715d);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.recent-room-chip:active {
  background: var(--accent, #0d715d);
  color: #fff;
}
.recent-room-chip.active {
  background: var(--accent, #0d715d);
  color: #fff;
}
.recent-confirm-bar {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.rc-btn {
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--accent, #0d715d);
  background: #fff;
  color: var(--accent, #0d715d);
  transition: background 0.15s, color 0.15s;
}
.rc-enter {
  background: var(--accent, #0d715d);
  color: #fff;
}
.rc-enter:active { opacity: 0.8; }
.rc-delete {
  border-color: var(--loss, #b73333);
  color: var(--loss, #b73333);
}
.rc-delete:active {
  background: var(--loss, #b73333);
  color: #fff;
}
.rc-cancel:active { opacity: 0.7; }

.home-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.home-tool-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
  color: var(--ink);
  text-align: left;
}

.home-tool-card span {
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 900;
}

.home-tool-card strong {
  font-size: 26px;
  line-height: 1.1;
}

.home-install-card {
  border: 1px solid var(--line);
  background: var(--panel);
}

.tool-button {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 16px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  color: #1a1a1a;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.share-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(130px, auto);
  gap: 10px;
  align-items: end;
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
}

.share-panel button {
  min-width: 108px;
}

#syncStatus {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#syncStatus.online {
  color: var(--win);
}

#syncStatus.error {
  color: var(--loss);
}

.notice-panel {
  margin: 14px 0 0;
  border: 1px solid rgba(178, 139, 48, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.notice-panel summary {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.notice-panel summary::-webkit-details-marker {
  display: none;
}

.notice-panel summary::after {
  content: "+";
  color: #1a1a1a;
  font-size: 18px;
  font-weight: 900;
}

.notice-panel[open] summary::after {
  content: "-";
}

.notice-panel summary span {
  color: #1a1a1a;
  font-size: 16px;
  font-weight: 900;
}

.notice-panel summary small {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.notice-content {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.notice-panel p {
  margin: 0;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  min-width: min(320px, calc(100% - 40px));
  max-width: calc(100% - 40px);
  transform: translate(-50%, 18px);
  border: 1px solid rgba(13, 113, 93, 0.24);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 18px 40px rgba(43, 34, 20, 0.18);
  color: #1a1a1a;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}



.helper-dialog {
  width: min(520px, 100%);
  max-width: 100%;
  max-height: 100vh;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.helper-dialog::backdrop {
  background: rgba(21, 33, 31, 0.42);
}

.helper-app {
  overflow-y: auto;
  min-height: min(860px, 100vh);
  padding: 18px 0 0;
  background: var(--accent);
}

.helper-app-head {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 12px 22px 28px 18px;
  color: #fff;
}

.helper-app-head h2 {
  text-align: center;
  font-size: 24px;
  letter-spacing: 6px;
}

.helper-close,
.helper-reset {
  white-space: nowrap;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: transparent;
  color: #fff;
}

.helper-close {
  width: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}

.helper-reset {
  white-space: nowrap;
  padding: 0 10px;
}

.helper-card {
  min-height: calc(100vh - 98px);
  border-radius: 42px 42px 0 0;
  padding: 22px 18px 30px;
  background: #fff;
}

.helper-rule {
  width: min(420px, 100%);
  margin: 0 auto 22px;
  color: #777;
  text-align: center;
  font-weight: 800;
}

.helper-grand-total {
  display: grid;
  place-items: center;
  gap: 4px;
  margin: 0 auto 18px;
  color: var(--accent);
}

.helper-grand-total span {
  color: #8b8b90;
  font-size: 14px;
  font-weight: 900;
}

.helper-grand-total strong {
  font-size: clamp(34px, 9vw, 42px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.helper-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 600px;
}

.helper-player {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
  min-width: 0;
  padding: 0 clamp(5px, 2.2vw, 12px);
  text-align: center;
}

.helper-player + .helper-player {
  border-left: 1px solid #d4d4d6;
}

.helper-name {
  border: 0;
  min-height: 40px;
  padding: 4px;
  text-align: center;
  color: #8b8b90;
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 800;
  min-width: 0;
}

.helper-total {
  color: var(--accent);
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.helper-actions {
  display: grid;
  gap: 8px;
}

.helper-half-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.helper-kick-preview {
  min-width: 0;
  color: var(--accent);
  font-size: clamp(13px, 4vw, 18px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-align: right;
  white-space: nowrap;
}

.helper-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding-inline: 4px;
  font-size: clamp(15px, 4vw, 17px);
  white-space: normal;
}

.helper-half {
  background: var(--red);
}

.helper-sign {
  border: 1px solid rgba(15, 112, 86, 0.22);
  background: #fff;
  color: #1a1a1a;
  transition: background 0.15s, color 0.15s;
}

.helper-find {
  background: #8f8f94;
}

.helper-lines {
  display: grid;
  align-content: start;
  gap: 16px;
  padding-top: 26px;
  font-variant-numeric: tabular-nums;
}

.helper-line-wrap {
  display: grid;
  grid-template-columns: minmax(20px, 0.42fr) minmax(0, 1fr);
  gap: clamp(2px, 1vw, 6px);
  align-items: center;
  min-width: 0;
}

.helper-line-total {
  color: #a5a5aa;
  font-size: clamp(10px, 3vw, 13px);
  font-weight: 900;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
}

.helper-line-input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  padding: 0 1px;
  background: transparent;
  color: var(--accent);
  text-align: center;
  font-size: clamp(20px, 7vw, 28px);
  font-weight: 700;
  outline: none;
}

.helper-line-input::placeholder {
  color: #b5b5ba;
}

.helper-line-input.negative {
  color: var(--loss);
}

.helper-line-input.helper-half-marker {
  color: var(--red);
  font-size: 18px;
  font-weight: 900;
}

.helper-line-input:focus {
  outline: 2px solid rgba(13, 113, 93, 0.18);
  border-radius: 8px;
  background: rgba(13, 113, 93, 0.05);
}

.scorebook-dialog {
  width: min(880px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(34, 26, 10, 0.28);
}

.confirm-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(34, 26, 10, 0.28);
}

.password-dialog {
  width: min(420px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(34, 26, 10, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(21, 33, 31, 0.42);
}

.password-dialog::backdrop {
  background: rgba(21, 33, 31, 0.42);
}

.password-card {
  display: grid;
}

.password-content {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.password-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.password-error {
  display: none;
  color: var(--loss);
  font-size: 13px;
  font-weight: 900;
}

.password-error.show {
  display: block;
}

.admin-settings-btn {
  width: 100%;
  margin-top: 2px;
}

.confirm-head,
.confirm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.confirm-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.confirm-content {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 16px;
}

.confirm-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.confirm-meta div,
.confirm-player {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.confirm-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.confirm-meta strong {
  display: block;
  margin-top: 4px;
}

.confirm-players {
  display: grid;
  gap: 8px;
}

.confirm-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 900;
}

.confirm-total {
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
  color: #1a1a1a;
  font-weight: 900;
  text-align: center;
  line-height: 1.6;
}

.confirm-meta strong .weekday {
  display: block;
  font-size: 13px;
  color: inherit;
  font-weight: 700;
  margin-top: 2px;
}

.scorebook-dialog::backdrop {
  background: rgba(21, 33, 31, 0.42);
}

.scorebook-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.98);
}

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

.scorebook-reference-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 44px;
  border-color: rgba(180, 126, 27, 0.32);
  border-radius: 999px;
  padding: 0 18px;
  background: linear-gradient(180deg, #fffdf8, #fff5df);
  color: #1a1a1a;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(127, 83, 12, 0.08);
}

.scorebook-reference-link:hover {
  border-color: rgba(15, 112, 86, 0.42);
  background: #fffaf0;
}

.hidden-ref {
  display: none !important;
}

/* Close X button (top-right corner) */
.dialog-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  z-index: 5;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  padding: 0;
}

.dialog-close-x:hover {
  background: rgba(0,0,0,0.12);
  color: var(--ink);
}

/* Scorebook Tabs */
.scorebook-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 12px;
  background: rgba(255, 253, 248, 0.98);
}

.scorebook-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.scorebook-tab.active {
  background: linear-gradient(180deg, #e8f5e9, #c8e6c9);
  border-color: rgba(15, 112, 86, 0.35);
  color: var(--green);
}

.scorebook-tab:hover:not(.active) {
  background: #f5f5f5;
}

/* Vietnamese Tile Grid - match tile-reference.html style */
.vn-tiles-content {
  padding: 0;
}

.vn-tiles-content section {
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  padding: 16px;
}

.vn-tiles-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
}

.vn-tiles-content h4 {
  margin: 20px 0 12px;
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}

.vn-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 10px;
}

.vn-tile-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  border: none;
  border-radius: 10px;
  padding: 2px;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.vn-tile-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.vn-tile-card .tile-frame {
  width: 100%;
  aspect-ratio: 5/7;
  overflow: hidden;
  border: none;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.vn-tile-card .tile-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.vn-tile-card .tile-label {
  display: none;
}

/* Session highlight */
.highlight-session,
.ps-hc-highlight {
  animation: highlight-pulse 2s ease;
}
@keyframes highlight-pulse {
  0%, 100% { background: inherit; }
  50% { background: #fff3cd; }
}

/* Sparkline */
.ps-sparkline {
  width: 100%;
  height: 40px;
  margin: 8px 0;
}

/* Vietnamese Tile Detail Dialog */
.vn-tile-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  max-width: min(90vw, 380px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
}

.vn-tile-dialog::backdrop {
  background: rgba(0,0,0,0.5);
}

.vn-tile-dialog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  background: #fff;
  border-radius: 16px;
}

.vn-tile-dialog-img {
  width: 100px;
  aspect-ratio: 5/7;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.vn-tile-dialog-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vn-tile-dialog-info {
  text-align: center;
}

.vn-tile-dialog-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--green);
  margin-bottom: 4px;
}

.vn-tile-dialog-cat {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 10px;
}

.vn-tile-dialog-desc {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.6;
}

.vn-tile-dialog-close {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.vn-tile-desc .vn-tile-desc-name {
  color: #4caf50;
  font-weight: 900;
}

@media (max-width: 520px) {
  .vn-tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 8px;
  }
  .vn-tile-card .tile-label {
    font-size: 13px;
  }
}

.scorebook-search {
  position: sticky;
  top: 76px;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.98);
}

.scorebook-search label {
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 900;
}

.scorebook-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  outline: none;
}

.scorebook-search input:focus {
  border-color: rgba(15, 112, 86, 0.42);
  box-shadow: 0 0 0 3px rgba(15, 112, 86, 0.12);
}

.scorebook-search p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.scorebook-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.scorebook-content[hidden] {
  display: none !important;
}

.score-calculator {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(239, 250, 244, 0.92), rgba(255, 253, 248, 0.96)),
    #fffefb;
}

.score-calc-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.score-calc-head h3 {
  margin: 2px 0 4px;
  color: var(--ink);
  font-size: 20px;
}

.score-calc-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.score-calc-total {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 2px 12px;
  border: 1px solid rgba(15, 112, 86, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 254, 251, 0.94);
}

.score-calc-total span {
  color: var(--muted);
  font-weight: 900;
}

.score-calc-total strong {
  color: #1a1a1a;
  font-size: 34px;
  line-height: 1;
}

.score-calc-total p {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.score-calc-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: #1a1a1a;
  font-weight: 900;
}

.score-calc-custom input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.score-calc-list {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.score-calc-group {
  display: grid;
  gap: 8px;
}

.score-calc-group h4 {
  margin: 0;
  color: #1a1a1a;
}

.score-calc-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.score-calc-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(214, 199, 171, 0.92);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.score-calc-option input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.score-calc-option-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.score-calc-option-main strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.score-calc-option-main small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.score-calc-value,
.score-calc-select {
  justify-self: end;
  min-width: 72px;
  border: 1px solid rgba(15, 112, 86, 0.12);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft);
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.score-calc-select {
  min-height: 34px;
  border-radius: 8px;
}
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding: 16px;
}

.scorebook-content h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.scorebook-content h4 {
  margin: 14px 0 8px;
  color: #1a1a1a;
}

.scorebook-content ol {
  margin: 0;
  padding-left: 22px;
}

.scorebook-content li,
.scorebook-content p {
  line-height: 1.55;
}

.score-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-list p {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  font-weight: 700;
}

.score-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name value"
    "note note";
  align-items: start;
  gap: 7px 10px;
  min-height: 82px;
  border: 1px solid rgba(214, 199, 171, 0.92);
  border-radius: 8px;
  padding: 12px 12px 11px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(54, 43, 27, 0.05);
  font-weight: 800;
}

.score-hidden {
  display: none !important;
}

.score-row.has-note {
  cursor: pointer;
}

.score-row.has-note:hover {
  border-color: rgba(15, 112, 86, 0.35);
  background: #fffaf0;
}

.score-row.has-tiles .score-name::after {
  content: "牌例";
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(15, 112, 86, 0.1);
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 900;
  font-weight: 800;
  line-height: 1.45;
}

.warning-list p {
  border-color: #e7c1a1;
  background: #fff6e8;
}

.score-note-dialog {
  width: min(94vw, 430px);
  max-height: 88vh;
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: transparent;
}

.score-note-dialog::backdrop {
  background: rgba(16, 30, 25, 0.4);
}

.score-note-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  max-height: 88vh;
  overflow: auto;
  overflow-x: hidden;
  background: #fff;
  box-shadow: 0 24px 60px rgba(22, 40, 32, 0.22);
}

.score-note-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.score-note-head h2 {
  margin: 0;
  color: #1a1a1a;
  font-size: 20px;
}

.score-note-card p {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.7;
}

.score-note-tiles {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  min-width: 0;
}

.score-note-tiles.is-empty {
  display: none;
}

.score-tile-title {
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.score-tile-example {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.score-tile-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.mahjong-tiles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.mahjong-gap {
  width: 4px;
  height: 1px;
  flex: 0 0 4px;
}

.mahjong-tile {
  width: 31px;
  height: 45px;
  flex: 0 0 31px;
  display: inline-grid;
  place-items: center;
  align-content: center;
  gap: 0;
  border: 1px solid #d5d6d2;
  border-radius: 6px;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.96), rgba(235, 235, 231, 0.96)),
    #fdfdfb;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -2px 4px rgba(30, 35, 32, 0.08),
    0 1px 0 #bfc1bc,
    0 4px 8px rgba(22, 40, 32, 0.16);
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", "MingLiU", serif;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.mahjong-tile.tile-sprite {
  overflow: hidden;
  border-color: rgba(31, 35, 31, 0.18);
  background-image: url("./mahjong-sprite-cropped.png?v=20260614629001");
  background-repeat: no-repeat;
  background-size: 900% 500%;
  background-position: var(--tile-x, 0%) var(--tile-y, 0%);
  background-color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 0 rgba(80, 84, 78, 0.32),
    0 3px 7px rgba(22, 40, 32, 0.15);
}

.mahjong-tile.tile-image {
  overflow: hidden;
  border-color: rgba(31, 35, 31, 0.18);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(238, 238, 234, 0.98)),
    #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -2px 4px rgba(30, 35, 32, 0.08),
    0 1px 0 rgba(80, 84, 78, 0.22),
    0 3px 7px rgba(22, 40, 32, 0.15);
}

.mahjong-tile.tile-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
}

.tile-face {
  width: 25px;
  height: 38px;
  display: grid;
  place-items: center;
}

.tile-dots {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
}

.tile-dot {
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #fdfdfb, inset 0 0 0 3px currentColor;
}

.dot-red {
  color: #bd2d3c;
}

.dot-green {
  color: #0c705d;
}

.dot-black {
  color: #1a211d;
}

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

.dots-1 .tile-dot {
  width: 17px;
  height: 17px;
}

.dots-2 {
  grid-template-columns: 1fr;
  align-content: center;
  gap: 7px;
}

.dots-3 {
  grid-template-columns: 1fr;
  align-content: center;
  gap: 4px;
}

.dots-4,
.dots-6,
.dots-8,
.dots-9 {
  grid-template-columns: repeat(2, 1fr);
}

.dots-5,
.dots-7 {
  grid-template-columns: repeat(2, 1fr);
}

.dots-5 .tile-dot:nth-child(3),
.dots-7 .tile-dot:nth-child(3) {
  grid-column: 1 / -1;
  justify-self: center;
}

.dots-7 .tile-dot:nth-child(n + 4) {
  margin-top: -2px;
}

.tile-bamboo {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 2px;
}

.tile-bamboo-stick {
  width: 5px;
  height: 13px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 28%, #fdfdfb 0 1px, transparent 2px),
  box-shadow: inset 0 0 0 1px rgba(8, 54, 45, 0.5);
}

.bamboo-red {
  background:
    radial-gradient(circle at 50% 28%, #fdfdfb 0 1px, transparent 2px),
}

.bamboo-2,
.bamboo-3 {
  grid-template-columns: 1fr;
  align-content: center;
  gap: 5px;
}

.bamboo-4,
.bamboo-6,
.bamboo-8 {
  grid-template-columns: repeat(2, 1fr);
}

.bamboo-5,
.bamboo-7,
.bamboo-9 {
  grid-template-columns: repeat(2, 1fr);
}

.tile-bird {
  color: #0a6c55;
  font-size: 20px;
  line-height: 1;
  text-shadow: 1px 1px 0 #bd2d3c;
  transform: rotate(-8deg);
}

.tile-character {
  gap: 2px;
}

.tile-character-number {
  color: #1c211f;
  font-size: 21px;
  line-height: 1;
}

.tile-character-man {
  color: #b72f32;
  font-size: 18px;
  line-height: 1;
}

.mahjong-tile.tile-red {
  color: #b93235;
}

.mahjong-tile.tile-green {
  color: #0b755d;
}

.mahjong-tile.tile-blue {
  color: #1f5f95;
}

.mahjong-tile.tile-flower {
  color: #a57210;
}

.mahjong-tile.tile-white-face::before {
  content: "";
  width: 19px;
  height: 27px;
  border: 2px solid #bd2d3c;
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 2px #fdfdfb,
    inset 0 0 0 3px #0b755d;
}

@media (max-width: 520px) {
  .score-note-dialog {
    width: calc(100vw - 24px);
  }

  .score-note-card {
    padding: 14px;
  }

  .mahjong-tiles {
    gap: 4px;
  }

  .mahjong-tile {
    width: 27px;
    height: 39px;
    flex-basis: 27px;
  }

  .tile-face {
    width: 22px;
    height: 34px;
  }

  .tile-dot {
    width: 7px;
    height: 7px;
    border-width: 2px;
  }

  .dots-1 .tile-dot {
    width: 15px;
    height: 15px;
  }

  .tile-bamboo-stick {
    width: 4px;
    height: 11px;
  }

  .tile-character-number {
    font-size: 19px;
  }

  .tile-character-man {
    font-size: 16px;
  }
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost:hover {
  background: var(--soft);
}

.danger {
  border: 1px solid #e2b7b7;
  background: #fff;
  color: var(--loss);
}

.danger:hover {
  background: #fff1f1;
}

.file-btn {
  display: inline-grid;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.file-btn input {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.formed-events-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  border: 1px solid rgba(13, 113, 93, 0.32);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.formed-events-panel[hidden] {
  display: none;
}

.formed-events-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.formed-events-head h2 {
  margin: 0;
  color: #1a1a1a;
  font-size: 24px;
}

.formed-events-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.formed-event-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.formed-event-card strong,
.formed-event-card small,
.formed-event-card span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.formed-event-card strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.formed-event-card small {
  width: fit-content;
  margin-top: 7px;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(184, 47, 47, 0.12);
  color: var(--loss);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.25;
}

.formed-event-card.is-full small {
  background: var(--accent);
  color: #fffdf6;
}

.formed-event-card.is-expired small {
  background: #f4efe4;
  color: var(--muted);
}

.formed-event-card span {
  margin-top: 5px;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
}

.formed-event-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.formed-event-edit-btn,
.formed-event-register-btn {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
}

.formed-event-card:not(.is-full) .formed-event-actions {
  grid-template-columns: 1fr;
}

.stats-filter {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 1fr 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stats-filter.hidden-year .stats-year-field,
.stats-filter.hidden-custom .stats-custom-field {
  display: none;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 92px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-button {
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.metric-button:hover,
.metric-button:focus-visible {
  border-color: rgba(13, 113, 93, 0.45);
  box-shadow: 0 14px 34px rgba(13, 113, 93, 0.16);
  outline: 0;
  transform: translateY(-1px);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: start;
}

.player-panel {
  grid-column: 1;
}

.entry-panel {
  grid-column: 2;
  grid-row: 1;
}

.panel {
  padding: 18px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 16px;
}

.chip-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  font-weight: 700;
}

.chip-list.is-editing .chip {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.chip.active {
  border-color: rgba(13, 113, 93, 0.72);
  background: #e5f4ee;
  box-shadow: inset 0 0 0 2px rgba(13, 113, 93, 0.14);
}

.chip span {
  display: block;
  min-height: 30px;
  padding: 5px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.chip span:hover {
  color: var(--accent);
}

.chip.active span {
  color: #1a1a1a;
  font-weight: 900;
}

.chip button {
  display: none;
  min-width: 34px;
  min-height: 32px;
  width: 34px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.chip-list.is-editing .chip button {
  display: block;
}

.chip .remove-player-btn {
  color: var(--loss);
}

.player-edit-toggle {
  min-width: 58px;
  min-height: 36px;
  padding: 0 10px;
  color: #1a1a1a;
  font-size: 13px;
}

.player-edit-toggle.active {
  border-color: rgba(13, 113, 93, 0.45);
  background: var(--soft);
  color: #1a1a1a;
}

.player-panel #playerForm {
  display: none;
}

.player-panel.is-editing #playerForm {
  display: flex;
}

.player-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.player-panel .section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.event-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(86vh, 860px);
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: transparent;
}

.event-dialog::backdrop {
  background: rgba(8, 20, 18, 0.42);
  backdrop-filter: blur(2px);
}

.register-dialog {
  width: min(920px, calc(100vw - 24px));
  max-height: min(90vh, 900px);
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: transparent;
}

.register-dialog::backdrop {
  background: rgba(8, 20, 18, 0.42);
  backdrop-filter: blur(2px);
}

.register-sheet {
  position: relative;
  display: block;
  max-height: min(90vh, 900px);
  overflow: auto;
  border-radius: 16px;
  padding: 18px;
}

.register-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.register-head-actions .icon-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
}

.register-player-block {
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.register-player-block .section-head {
  padding-right: 54px;
}

.event-sheet {
  position: relative;
  display: grid;
  gap: 14px;
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(24, 43, 35, 0.28);
}

.event-sheet .dialog-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding-right: 54px;
}

.event-sheet .icon-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
}

.event-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.event-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.event-meta label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.event-meta input,
.event-meta select {
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.event-meta input[type="time"] {
  appearance: none;
  -webkit-appearance: none;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  text-align: left;
}

.event-note-field {
  grid-column: 1 / -1;
}

.event-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.event-current {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.event-current strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
}

.event-current span {
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
}

.event-list {
  display: grid;
  gap: 12px;
}

.event-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  scroll-margin-top: 18px;
}

.event-card-highlight {
  border-color: rgba(13, 113, 93, 0.72);
  box-shadow:
    0 0 0 3px rgba(13, 113, 93, 0.14),
    var(--shadow);
}

.event-card.is-full {
  border-color: rgba(13, 113, 93, 0.45);
  background: #f7fff8;
}

.event-card.is-expired {
  border-color: rgba(111, 119, 113, 0.24);
  background: #f9f6ef;
}

.event-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.event-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.event-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.event-card-actions {
  display: flex;
  gap: 6px;
}

.event-edit-btn {
  min-height: 34px;
  padding: 0 10px;
  color: var(--accent);
  font-size: 13px;
}

.event-remove-btn {
  min-height: 34px;
  padding: 0 10px;
  color: var(--loss);
  font-size: 13px;
}

.event-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.event-status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(184, 47, 47, 0.12);
  color: var(--loss);
  font-size: 13px;
  font-weight: 900;
}

.event-card.is-full .event-status-pill {
  background: var(--accent);
  color: #fffdf6;
}

.event-card.is-expired .event-status-pill {
  background: #f4efe4;
  color: var(--muted);
}

.event-signup-count {
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
}

.event-signed-summary {
  margin-top: 8px;
  border-radius: 8px;
  padding: 9px 10px;
  background: #eef8f3;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.event-signup-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.event-signup-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.event-signup-chip span {
  min-width: 0;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-signup-chip small {
  border-radius: 999px;
  padding: 4px 7px;
  background: #f4efe4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.event-signup-chip.active {
  border-color: rgba(13, 113, 93, 0.7);
  background: #e5f4ee;
  box-shadow: inset 0 0 0 2px rgba(13, 113, 93, 0.14);
}

.event-signup-chip.active small {
  background: var(--accent);
  color: #fffdf6;
}

.event-signup-chip:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

@media (max-width: 420px) {
  .chip-list {
    grid-template-columns: 1fr;
  }

  .event-sheet {
    padding: 14px;
  }

  .event-meta {
    grid-template-columns: 1fr;
  }

  .event-signup-list {
    grid-template-columns: 1fr;
  }
  .score-calc-options {
    grid-template-columns: 1fr;
  }
}

.session-form {
  margin-top: 16px;
}

.entry-filter-toggle {
  display: inline-flex;
  width: auto;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 900;
}

.entry-filter-toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.session-meta {
  display: grid;
  grid-template-columns: 250px 120px 150px 1fr;
  gap: 12px;
  margin-bottom: 14px;
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.entry-table-wrap,
.table-wrap {
  overflow-x: auto;
}

.entry-hidden {
  display: none !important;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.entry-table input[type="number"] {
  max-width: 140px;
}

.amount-control {
  display: flex;
  gap: 6px;
  align-items: center;
}

.amount-control input {
  min-width: 0;
}

.amount-input.is-win {
  color: var(--win);
  font-weight: 900;
}

.amount-input.is-loss {
  color: var(--loss);
  font-weight: 900;
}

.multiplier-input {
  min-width: 72px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
}

.entry-final {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.entry-final.is-win {
  color: var(--win);
}

.entry-final.is-loss {
  color: var(--loss);
}

.sign-toggle {
  min-width: 46px;
  min-height: 42px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #1a1a1a;
  font-size: 13px;
}

.sign-toggle:hover {
  background: var(--soft);
}

.entry-table input[type="checkbox"] {
  width: 24px;
  min-height: 24px;
  accent-color: var(--accent);
}

.maxfan-input {
  width: 60px;
  min-height: 42px;
  padding: 0 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mobile-entry-list {
  display: none;
}

.balance {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 900;
}

.balance.ok {
  background: #e5f4ee;
  color: var(--win);
}

.balance.bad {
  background: #fff4dc;
  color: var(--gold);
}

.balance.partial {
  background: #e8f0fe;
  color: #1a73e8;
}

.form-footer {
  margin-top: 14px;
}

.form-footer p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ranking-panel,
.history-panel {
  margin-top: 14px;
}

.ranking-actions,
.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-left: auto;
}

.ranking-toggle,
.history-edit-toggle,
.history-toggle {
  min-width: 82px;
  min-height: 36px;
  padding: 0 12px;
  color: #1a1a1a;
  font-size: 13px;
}

.ranking-spotlight {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 14px;
}

.ranking-spotlight[hidden] {
  display: none !important;
}

.ranking-mini {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 251, 0.86);
  padding: 12px;
}

.ranking-mini h3 {
  margin: 0 0 8px;
  color: #1a1a1a;
  font-size: 15px;
}

.ranking-mini ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-mini li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ranking-mini-rank {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e8f5ef;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 800;
  line-height: 24px;
  text-align: center;
}

.ranking-mini-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 2px;
}
.ranking-mini-name .monthly-star-badge {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.ranking-mini-money {
  font-weight: 900;
  white-space: nowrap;
}

.money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.win-count,
.loss-count {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.win-count {
  color: var(--win);
}

.loss-count {
  color: var(--loss);
}

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

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

.neutral {
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.session-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.session-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.session-title {
  display: grid;
  gap: 4px;
}

.session-title strong {
  font-size: 16px;
}

.session-title span,
.session-total {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.session-actions {
  display: flex;
  gap: 8px;
}

.session-actions button {
  min-width: 38px;
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.session-actions .edit-btn,
.session-actions .delete-btn {
  display: none;
}

.session-card.is-editing .edit-btn,
.session-card.is-editing .delete-btn {
  display: inline-grid;
}

.history-edit-toggle.active {
  border-color: rgba(13, 113, 93, 0.45);
  background: var(--soft);
}

.history-panel .section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.history-panel .history-actions {
  flex: 0 0 auto;
}

.session-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag,
.session-line {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.date-input-wrap {
  position: relative;
  display: block;
}

.date-input-wrap input {
  color: transparent;
  caret-color: transparent;
}

.weekday-hint {
  position: absolute;
  top: 50%;
  left: 12px;
  right: 38px;
  transform: translateY(-50%);
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  color: #1a1a1a;
}

.session-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 940px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topbar-actions {
    justify-content: start;
  }

  .top-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-panel {
    grid-template-columns: 1fr;
  }

  .tool-button {
    width: 100%;
  }

  .score-list {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formed-events-list {
    grid-template-columns: 1fr;
  }

  .stats-filter {
    grid-template-columns: 1fr 1fr;
  }

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

  .player-panel,
  .entry-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .session-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .scorebook-head,
  .score-calc-head {
    align-items: stretch;
    flex-direction: column;
  }

  .scorebook-actions {
    justify-content: stretch;
  }

  .scorebook-actions > * {
    flex: 1 1 auto;
  }

  .score-calc-custom {
    grid-template-columns: 1fr;
  }

  .score-calc-total {
    grid-template-columns: 1fr;
  }

  .score-calc-total strong {
    font-size: 30px;
  }

  .score-calc-list {
    max-height: 320px;
  }

  .score-calc-option {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .score-calc-value,
  .score-calc-select {
    grid-column: 2;
    justify-self: start;
  }
}

.achv-cell { text-align: center; }

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero {
    height: 142px;
    padding: 0;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .home-room-form,
  .home-tool-grid {
    grid-template-columns: 1fr;
  }

  .home-card h2,
  .home-tool-card strong {
    font-size: 22px;
  }

  .summary-grid,
  .formed-events-panel,
  .stats-filter,
  .session-meta {
    grid-template-columns: 1fr;
  }


  .scorebook-actions {
    justify-content: stretch;
  }

  .scorebook-actions > * {
    flex: 1 1 auto;
  }
    grid-column: 2;
    justify-self: start;
  }

  .formed-events-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
  }

  .formed-events-head .ghost {
    flex: 0 0 auto;
    width: auto;
    min-width: 84px;
    padding: 0 12px;
  }

  input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
  }

  .panel,
  .metric {
    padding: 14px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .summary-grid .metric {
    min-height: 58px;
    padding: 10px 12px;
  }

  .summary-grid .metric span {
    font-size: 11px;
  }

  .summary-grid .metric strong {
    margin-top: 4px;
    font-size: clamp(18px, 5.5vw, 22px);
    line-height: 1.05;
  }

  .section-head,
  .form-footer,
  .session-card-head {
    display: grid;
    justify-content: stretch;
  }

  .ranking-panel .section-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 10px;
  }

  .ranking-panel .ranking-actions {
    flex: 0 0 auto;
    justify-content: flex-end;
    margin-left: auto;
  }

  .ranking-panel .ranking-actions .ghost {
    width: auto;
    min-width: 70px;
    min-height: 34px;
    padding: 0 10px;
  }

  .event-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .event-meta label,
  .event-meta input,
  .event-meta select,
  .event-meta input[type="time"] {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .event-note-field {
    grid-column: auto;
  }

  .sticky-entry-head {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -14px -14px 0;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.98);
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .balance {
    width: fit-content;
  }

  .entry-table-wrap {
    display: none;
  }

  .mobile-entry-list {
    display: grid;
    gap: 10px;
  }

  .mobile-entry-card {
    display: grid;
    grid-template-columns: minmax(0, 0.88fr) minmax(158px, 1.12fr);
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
  }

  .mobile-entry-card strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 16px;
  }

  .mobile-entry-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }

  .mobile-entry-card label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
  }

  .mobile-entry-card .mobile-active-toggle {
    margin-top: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 6px;
    background: #fffaf0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
  }

  .mobile-entry-card .mobile-active-toggle:has(input:checked) {
    border-color: rgba(13, 113, 93, 0.45);
    background: #e5f4ee;
    color: #1a1a1a;
  }

  .mobile-entry-multiplier {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  .mobile-entry-multiplier label {
    justify-content: start;
    margin-top: 0;
    color: var(--muted);
    font-weight: 900;
  }

  .mobile-entry-multiplier select {
    width: 76px;
    min-height: 38px;
    margin-left: 6px;
    padding: 0 8px;
    font-size: 16px;
    font-weight: 900;
  }

  .mobile-entry-multiplier .entry-final {
    max-width: 42vw;
    overflow-wrap: anywhere;
    text-align: right;
    font-size: 18px;
  }

  .mobile-entry-card input[type="checkbox"] {
    width: 20px;
    min-height: 20px;
    accent-color: var(--accent);
  }

  .mobile-entry-card input[type="number"] {
    min-height: 54px;
    text-align: right;
    font-size: 21px;
    font-weight: 900;
  }

  .mobile-entry-card .amount-control {
    width: 100%;
    justify-content: end;
  }

  .mobile-entry-card .amount-control input {
    min-width: 0;
    flex: 1;
  }

  .ranking-table {
    min-width: 800px;
  }

  .ranking-spotlight {
    grid-template-columns: 1fr;
  }

  .event-actions {
    grid-template-columns: 1fr;
  }

  .form-footer button {
    width: 100%;
  }
}

.player-panel .section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.player-panel .player-edit-toggle {
  width: auto;
  flex: 0 0 auto;
}

/* 禁止手機雙擊縮放 */
* {
  touch-action: manipulation;
  -ms-touch-action: manipulation;
}

/* 四個主按鈕統一白色底 */
.tool-button {
  background: #fff !important;
}

/* 約局分享按鈕 */
.share-events-btn {
  font-size: 14px;
  color: #1a1a1a;
  white-space: nowrap;
}

/* Helper History */
.helper-head-actions {
  display: flex;
  gap: 8px;
}

.helper-save {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
}

.helper-save:hover {
  background: rgba(255, 255, 255, 0.25);
}

.helper-history {
  margin-top: 12px;
  padding: 0 18px 18px;
}

.helper-history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.helper-history-head span {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.helper-history-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.helper-history-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.helper-history-list.expanded {
  display: flex;
}

.helper-history-item {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
}

.helper-history-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.helper-history-item-date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.helper-history-item-actions {
  display: flex;
  gap: 6px;
}

.helper-history-item-actions button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.helper-history-item-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.helper-history-item-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.helper-history-player {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 10px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.helper-history-player-name {
  font-size: 12px;
  opacity: 0.8;
}

.helper-history-player-score {
  font-size: 16px;
  font-weight: 700;
}

.helper-history-player.positive {
  color: #90EE90;
}

.helper-history-player.negative {
  color: #FFB6C1;
}

.helper-history-total {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 6px;
}

.helper-history-empty {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 10px;
}

.helper-head-actions {
  display: flex;
  gap: 8px;
}

.helper-history-btn {
  white-space: nowrap;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
}

.helper-history-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* 轉正負按鈕閃綠效果 */
.helper-sign.flash {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* 小助手每行負號按鈕 */
.helper-neg-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #d1d1d6;
  border-radius: 6px;
  background: #f2f2f7;
  color: #8e8e93;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.helper-neg-btn:hover {
  background: #e5e5ea;
}

.helper-neg-btn.flash {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* 正/負切換掣紅色狀態 */
.helper-sign.neg-active {
  background: var(--loss) !important;
  color: #fff !important;
  border-color: var(--loss) !important;
}


/* ===== Achievement System ===== */
.achievement-dialog {
  max-width: 480px;
  width: calc(100% - 32px);
  border: none;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}
.achievement-dialog::backdrop { background: rgba(0,0,0,.4); }
.achv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.achv-header h2 { margin: 0; font-size: 20px; }
.achv-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.achv-summary-card {
  background: #fdfbf7;
  border: 1px solid #e8dcc8;
  border-radius: 20px;
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(184,134,11,.06);
  min-height: 120px;
}
.achv-card-label {
  font-size: 11px;
  font-weight: 600;
  color: #a09880;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.achv-card-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin: 2px 0 6px;
}
.achv-card-value .achv-earned-count {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  color: #1a8a6e;
}
.achv-card-slash {
  font-size: 20px;
  font-weight: 300;
  color: #c0b8a8;
  margin: 0 2px;
}
.achv-card-value .achv-total-count {
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  color: #888;
}
.achv-card-sub {
  font-size: 11px;
  font-weight: 500;
  color: #b0a898;
  letter-spacing: 0.3px;
}
.achv-card-level {
  position: relative;
}
.achv-card-badge {
  margin-top: 4px;
  filter: drop-shadow(0 2px 8px rgba(205,175,100,.3));
}
.achv-card-level::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 20px;
  box-shadow: inset 0 0 20px rgba(205,175,100,.1);
  pointer-events: none;
}
.achv-stat {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e0dcd4);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06));
}
.achv-stat .val {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent, #b8860b);
  display: block;
}
.achv-stat .label {
  font-size: 11px;
  color: var(--muted, #888);
  font-weight: 700;
}
/* Achievement dialog: enlarge trophy image, shrink level text */
.achievement-dialog .achv-trophy-level img {
  width: 90px !important;
  height: 102px !important;
}
.achievement-dialog .achv-trophy-level span {
  font-size: 10px !important;
}
.achv-section-title {
  font-size: 14px;
  font-weight: 800;
  margin: 14px 0 10px;
}
.achv-badge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.achv-badge {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e0dcd4);
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06));
  position: relative;
  transition: transform .15s;
}
.achv-badge:hover { transform: translateY(-2px); }
.achv-badge.earned { border-color: var(--accent, #b8860b); background: #fdf6e3; }
.achv-badge.locked { opacity: 0.35; filter: grayscale(0.8); }
.achv-badge-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #2e7d32;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}
.achv-badge-icon { font-size: 24px; display: block; margin-bottom: 4px; }
.achv-badge-name { font-size: 11px; font-weight: 700; line-height: 1.2; display: block; }
.achv-badge-fan { font-size: 11px; color: var(--accent, #b8860b); font-weight: 800; display: block; margin-top: 2px; }
.achv-history-list { max-height: 250px; overflow-y: auto; }
.achv-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e0dcd4);
  border-radius: 10px;
  margin-bottom: 6px;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06));
}
.achv-hi-date { font-size: 12px; color: var(--muted, #888); }
.achv-hi-fans { font-size: 13px; font-weight: 600; }
.achv-hi-total { font-size: 16px; font-weight: 900; color: var(--accent, #b8860b); }
.achv-empty { text-align: center; color: var(--muted, #888); padding: 20px; font-size: 14px; }

/* Fan tags in entry form */
.fan-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.fan-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: #fdf6e3;
  color: #b8860b;
  border: 1px solid #e8d9a0;
}
.fan-tag .fan-val { font-size: 10px; opacity: 0.7; }
.add-fan-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px dashed var(--line, #e0dcd4);
  border-radius: 20px;
  background: transparent;
  color: var(--muted, #888);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.add-fan-btn:hover { border-color: var(--accent, #b8860b); color: var(--accent, #b8860b); background: #fdf6e3; }
.maxfan-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border: 1px dashed var(--line, #e0dcd4);
  border-radius: 20px;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}
.maxfan-chip-label {
  color: var(--muted, #888);
  white-space: nowrap;
  font-size: 12px;
}
.maxfan-chip .maxfan-input {
  width: 40px;
  border: none;
  background: transparent;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: var(--text, #333);
  padding: 2px 0;
  text-align: center;
  -moz-appearance: textfield;
  min-height: auto;
  height: auto;
}
.maxfan-chip .maxfan-input::-webkit-inner-spin-button,
.maxfan-chip .maxfan-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.maxfan-chip .maxfan-input::placeholder { color: #bbb; font-weight: 400; font-size: 11px; }

/* Fan picker dropdown */
.fan-picker {
  background: var(--panel, #fff);
  border: 1px solid var(--line, #e0dcd4);
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.fan-picker-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line, #e0dcd4);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.fan-picker-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fan-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.fan-picker-item:hover { background: #fdf6e3; }
.fan-picker-item.selected { background: #e8f5e9; }
.fan-picker-item .fp-name { font-weight: 600; }
.fan-picker-item .fp-val { color: #b8860b; font-weight: 800; font-size: 12px; }
.fan-picker-total {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line, #e0dcd4);
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 14px;
}

/* Achievement buttons */
.chip .achv-chip-btn {
  display: inline-flex !important;
  align-items: center;
  background: none !important;
  border: none;
  cursor: pointer;
  font-size: 15px !important;
  padding: 2px 6px !important;
  width: auto !important;
  min-width: auto !important;
  height: auto !important;
  min-height: auto !important;
  color: var(--ink, #1a1a1a) !important;
  list-style: none !important;
  text-align: center;
  line-height: 1;
}
.achv-rank-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 6px 8px;
  min-width: 40px;
  text-align: center;
  white-space: nowrap;
  color: var(--ink, #1a1a1a);
  list-style: none;
}
.achv-count {
  font-size: 12px;
  font-weight: 700;
}

/* Player stats achievement button */
.ps-achv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent, #0d715d);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.ps-achv-btn:hover { opacity: 0.85; }
.ps-achv-btn img { display: inline-block; width: 20px; height: 24px; vertical-align: middle; }

/* ===== Player Link (clickable names) ===== */
.player-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
}
.player-link:hover,
.player-link:active {
  opacity: 0.7;
}

/* ===== Player Stats Page ===== */
.player-stats-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  background: var(--bg, #f5f0e8);
  min-height: 100vh;
}

.ps-header {
  text-align: center;
  padding: 16px 0 8px;
}
.ps-back-btn {
  background: none;
  border: none;
  color: var(--accent, #2d7a3a);
  font-size: 15px;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  margin-bottom: 8px;
}
.ps-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent, #2d7a3a);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto;
}
.ps-player-name {
  font-size: 22px;
  margin: 8px 0 4px;
}
.ps-rank-line {
  font-size: 14px;
  color: var(--muted, #666);
  margin: 0;
}
.ps-last-played {
  font-size: 13px;
  color: var(--muted, #999);
  margin: 4px 0 0;
}

.ps-maxfan-line {
  font-size: 14px;
  color: #b8860b;
  margin: 6px 0 0;
  font-weight: 700;
}

.ps-maxfan-line strong {
  color: #d4380d;
  font-size: 16px;
}

/* Profit card */
.ps-profit-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  margin: 16px 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ps-profit-label {
  font-size: 14px;
  color: var(--muted, #666);
  display: block;
  margin-bottom: 4px;
}
.ps-profit-value {
  font-size: 34px;
  font-weight: 800;
  display: block;
}
.ps-profit-card.win .ps-profit-value { color: #1b8a32; }
.ps-profit-card.loss .ps-profit-value { color: #c0392b; }
.ps-profit-card.draw .ps-profit-value { color: #888; }

/* Summary grid */
.ps-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin: 0 0 16px;
}
.ps-summary-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ps-sc-label {
  font-size: 13px;
  color: var(--muted, #666);
  display: block;
  margin-bottom: 4px;
}
.ps-sc-value {
  font-size: 20px;
  font-weight: 700;
  display: block;
}
.ps-sc-value.win { color: #1b8a32; }
.ps-sc-value.loss { color: #c0392b; }
.ps-sc-value.draw { color: #888; }

/* Section title */
.ps-section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0 12px;
  padding: 0 4px;
}

/* WDL bar */
.ps-wdl-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.helper-vn-tiles {
  margin: 12px 16px;
  background: #f9f9f9;
  border-radius: 10px;
  overflow: hidden;
}
.helper-vn-tiles summary {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  color: #333;
}
.helper-vn-grid {
  padding: 0 12px 12px;
}
.helper-vn-cat {
  padding: 8px 0 4px;
  color: #666;
  font-size: 13px;
}
.helper-vn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}
.helper-vn-row img {
  width: 32px;
  height: 44px;
  object-fit: contain;
  border-radius: 4px;
}
.helper-vn-row span {
  font-weight: 600;
  font-size: 14px;
  min-width: 70px;
}
.helper-vn-row small {
  color: #888;
  font-size: 12px;
}
.ps-wdl-bar {
  display: flex;
  height: 20px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  background: #f0f0f0;
}
.ps-wdl-seg {
  height: 100%;
}
.ps-wdl-seg.ps-wdl-win { background: #2ecc71; }
.ps-wdl-seg.ps-wdl-draw { background: #bdc3c7; }
.ps-wdl-seg.ps-wdl-loss { background: #e74c3c; }
.ps-wdl-counts {
  display: flex;
  justify-content: space-around;
  font-size: 14px;
  font-weight: 600;
}
.ps-wdl-counts .ps-wdl-win { color: #1b8a32; }
.ps-wdl-counts .ps-wdl-draw { color: #888; }
.ps-wdl-counts .ps-wdl-loss { color: #c0392b; }

/* Records grid */
.ps-records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.ps-record-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ps-rc-label {
  font-size: 12px;
  color: var(--muted, #888);
  display: block;
  margin-bottom: 4px;
}
.ps-rc-value {
  font-size: 18px;
  font-weight: 700;
  display: block;
}
.ps-rc-value.win,
.ps-record-card.win .ps-rc-value { color: #1b8a32; }
.ps-rc-value.loss,
.ps-record-card.loss .ps-rc-value { color: #c0392b; }
.ps-rc-date {
  font-size: 12px;
  color: var(--muted, #999);
  display: block;
  margin-top: 2px;
}

/* Streaks */
.ps-streaks-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ps-streaks-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ps-streak-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line, #eee);
}
.ps-streak-card:last-child { border-bottom: none; }
.ps-streak-label {
  font-size: 14px;
  color: var(--muted, #666);
}
.ps-streak-value {
  font-size: 15px;
  font-weight: 600;
}
.ps-streak-value.win { color: #1b8a32; }
.ps-streak-value.loss { color: #c0392b; }

/* Recent 5 */
.ps-recent5-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ps-r5-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 12px 0;
}
.ps-r5-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.ps-r5-dot.win { background: #2ecc71; }
.ps-r5-dot.loss { background: #e74c3c; }
.ps-r5-dot.draw { background: #bdc3c7; }
.ps-r5-total {
  text-align: center;
  font-size: 14px;
  margin-top: 8px;
}
.ps-r5-total strong {
  font-weight: 700;
}
.ps-r5-total .win { color: #1b8a32; }
.ps-r5-total .loss { color: #c0392b; }
.ps-r5-total .draw { color: #888; }
.ps-r5-status {
  display: inline-block;
  margin-left: 8px;
  font-size: 13px;
}

/* Opponents */
.ps-opponents-section,
.ps-venues-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ps-opponents-section > summary,
.ps-venues-section > summary {
  cursor: pointer;
  list-style: none;
}
.ps-opponents-section > summary::-webkit-details-marker,
.ps-venues-section > summary::-webkit-details-marker { display: none; }
.ps-opp-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.ps-opp-highlight {
  padding: 8px 12px;
  background: var(--bg, #f5f0e8);
  border-radius: 8px;
}
.ps-opp-label {
  font-size: 12px;
  color: var(--muted, #888);
  display: block;
}
.ps-opp-highlight strong {
  font-size: 15px;
  display: block;
}
.ps-opp-highlight small {
  font-size: 13px;
  color: var(--muted, #666);
}
.ps-opp-list {
  margin-top: 8px;
}
.ps-opp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line, #eee);
  font-size: 14px;
}
.ps-opp-row:last-child { border-bottom: none; }
.ps-opp-name { font-weight: 600; min-width: 60px; }
.ps-opp-shared { color: var(--muted, #888); font-size: 13px; }
.ps-opp-avg, .ps-opp-total { font-weight: 600; font-size: 13px; margin-left: auto; }
.ps-opp-avg.win, .ps-opp-total.win { color: #1b8a32; }
.ps-opp-avg.loss, .ps-opp-total.loss { color: #c0392b; }

/* Venues */
.ps-venue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line, #eee);
  font-size: 14px;
}
.ps-venue-row:last-child { border-bottom: none; }
.ps-venue-row strong { min-width: 60px; }
.ps-venue-row span { font-size: 13px; color: var(--muted, #666); }
.ps-venue-row span.win { color: #1b8a32; font-weight: 600; }
.ps-venue-row span.loss { color: #c0392b; font-weight: 600; }

/* History */
.ps-history-section {
  margin-bottom: 24px;
}
.ps-history-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.ps-filter-btn {
  background: #fff;
  border: 2px solid var(--accent, #2d7a3a);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--accent, #2d7a3a);
  font-weight: 600;
  transition: all 0.15s;
}
.ps-filter-btn.active {
  background: var(--accent, #2d7a3a);
  color: #fff;
  border-color: var(--accent, #2d7a3a);
}
.ps-filter-btn:not(.active):hover {
  background: rgba(45, 122, 58, 0.08);
}
.ps-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ps-history-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.ps-history-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.ps-history-card.ps-highlight {
  box-shadow: 0 0 0 2px var(--accent, #2d7a3a);
}
.ps-hc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.ps-hc-head strong { font-size: 15px; }
.ps-hc-head span { font-size: 13px; color: var(--muted, #888); }
.ps-hc-meta {
  font-size: 13px;
  color: var(--muted, #888);
  margin-bottom: 6px;
}
.ps-hc-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ps-hc-amount {
  font-size: 18px;
  font-weight: 700;
}
.ps-hc-amount.win { color: #1b8a32; }
.ps-hc-amount.loss { color: #c0392b; }
.ps-hc-amount.draw { color: #888; }
.ps-hc-rank {
  font-size: 13px;
  color: var(--muted, #888);
}
.ps-hc-note {
  font-size: 13px;
  color: var(--muted, #999);
  margin-top: 6px;
  font-style: italic;
}
.ps-load-more-btn {
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line, #ddd);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  min-height: 44px;
  margin-top: 12px;
}
.ps-load-more-btn:hover {
  background: var(--bg, #f5f0e8);
}
.ps-empty {
  text-align: center;
  color: var(--muted, #888);
  padding: 24px;
  font-size: 14px;
}

/* Not found */
.ps-not-found {
  text-align: center;
  padding: 48px 16px;
}
.ps-not-found h2 {
  font-size: 20px;
  margin-bottom: 12px;
}
.ps-not-found p {
  color: var(--muted, #666);
  font-size: 15px;
}

.back-home-wrap {
  max-width: 600px;
  margin: 16px auto;
  padding: 0 16px;
}
.back-home-button {
  width: 100%;
  background: #fff;
  border: 2px solid var(--accent, #2d7a3a);
  color: var(--accent, #2d7a3a);
  font-weight: 600;
  font-size: 15px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
}

/* Loading spinner */
.ps-loading {
  text-align: center;
  padding: 64px 16px;
  color: var(--muted, #888);
}
.ps-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line, #ddd);
  border-top-color: var(--accent, #2d7a3a);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: ps-spin 0.8s linear infinite;
}
@keyframes ps-spin {
  to { transform: rotate(360deg); }
}
/* Monthly winner star badge */
.monthly-star-badge {
  display: inline-block;
  width: 30px;
  height: 30px;
  margin-left: 4px;
  vertical-align: middle;
  border-radius: 3px;
  object-fit: contain;
}

/* Monthly star wrapper & info dialog */
.monthly-star-wrap {
  display: inline-block;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 2px;
  line-height: 1;
}
.monthly-star-wrap:hover { opacity: 0.8; }

.star-info-dialog {
  max-width: 420px;
  width: 90vw;
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
.star-info-dialog::backdrop { background: rgba(0,0,0,0.4); }
.star-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.star-info-header h2 { margin: 0; font-size: 16px; }
.star-info-desc {
  padding: 12px 20px;
  margin: 0;
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}
.star-info-months {
  padding: 8px 20px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #0d715d;
  line-height: 1.5;
}
.recent-cell {
  white-space: nowrap;
  line-height: 1.3;
  font-size: 12px;
}
.recent-line1 { font-weight: 700; color: #333; }
.recent-line2 { color: #888; font-size: 11px; }
.recent-line3 { font-weight: 700; font-size: 13px; }
.money-pos { color: #16a34a; }
.money-neg { color: #dc2626; }
.star-info-levels { padding: 0 20px 20px; display: flex; flex-wrap: wrap; gap: 12px; }
.star-info-level {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 10px 6px;
  border-bottom: none;
  opacity: 0.25;
  transform: scale(0.88);
  flex: 0 0 calc(33.33% - 8px);
}
.star-info-level.unlocked { opacity: 1; transform: none; }
.star-info-img { width: 60px; height: 60px; object-fit: contain; }
.star-info-level:not(.unlocked) .star-info-img { filter: brightness(0); opacity: 0.35; }
.star-info-level.unlocked .star-info-img:hover { transform: scale(1.2); transition: transform 0.2s; }
.star-info-level strong { font-size: 12px; display: block; }
.star-info-level:not(.unlocked) strong { font-weight: 400; color: #aaa; }
.star-info-level small { font-size: 11px; color: #888; display: block; }
.star-info-level:not(.unlocked) small { color: #ccc; }

/* Confetti celebration effect */
.confetti-piece {
  position: fixed;
  pointer-events: none;
  z-index: 2147483647;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(0.3); }
  5% { opacity: 1; transform: translate(calc(var(--dx) * 0.2), calc(var(--dy) * -0.15)) rotate(45deg) scale(1.1); }
  15% { opacity: 1; transform: translate(calc(var(--dx) * 0.5), calc(var(--dy) * -0.35)) rotate(150deg) scale(1); }
  30% { opacity: 1; transform: translate(calc(var(--dx) * 0.7 + var(--wobble, 10px)), calc(var(--dy) * 0.1)) rotate(300deg) scale(0.95); }
  50% { opacity: 0.95; transform: translate(calc(var(--dx) * 0.9), calc(var(--dy) * 0.45)) rotate(500deg) scale(0.9); }
  70% { opacity: 0.8; transform: translate(calc(var(--dx) * 1.05 + var(--wobble, 10px) * -0.5), calc(var(--dy) * 0.7)) rotate(680deg) scale(0.8); }
  85% { opacity: 0.5; transform: translate(calc(var(--dx) * 1.15), calc(var(--dy) * 0.88)) rotate(800deg) scale(0.6); }
  100% { opacity: 0; transform: translate(calc(var(--dx) * 1.2), var(--dy)) rotate(900deg) scale(0.3); }
}
/* History card highlight when scrolling from recent5 dot */
@keyframes hcHighlight {
  0% { background: #fff9c4; box-shadow: 0 0 0 3px #f39c12; }
  100% { background: #fff; box-shadow: none; }
}
.ps-history-card.ps-hc-highlight {
  animation: hcHighlight 2s ease-out;
}
