:root {
  color-scheme: dark;
  --bg: #0a0b0b;
  --panel: #151515;
  --panel-glass: rgba(21, 21, 21, 0.88);
  --panel-strong: #202020;
  --field: #0f1010;
  --line: #32302b;
  --line-soft: #24231f;
  --text: #f3eee4;
  --muted: #9d988f;
  --accent: #c8a15f;
  --accent-strong: #e2c17e;
  --green: #79c891;
  --red: #d96f6b;
  --blue: #8aaed8;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% -8%, rgba(200, 161, 95, 0.13), transparent 25rem),
    radial-gradient(circle at 88% 4%, rgba(89, 38, 40, 0.18), transparent 24rem),
    linear-gradient(180deg, #0d0d0c 0%, var(--bg) 54%, #060707 100%);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 22px 16px 88px;
}

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

.section-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
  line-height: 1.2;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--panel-glass);
  box-shadow: var(--shadow);
}

.poker-board {
  position: relative;
  display: grid;
  gap: 14px;
  overflow: hidden;
  isolation: isolate;
}

.poker-board::before,
.poker-board::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
}

.poker-board::before {
  background:
    linear-gradient(90deg, transparent 0 6px, rgba(200, 161, 95, 0.08) 6px 7px, transparent 7px 18px),
    linear-gradient(180deg, transparent 0 8px, rgba(255, 255, 255, 0.035) 8px 9px, transparent 9px 20px);
  opacity: 0.28;
  mix-blend-mode: screen;
  animation: mosaicDrift 7.2s steps(18) infinite;
}

.poker-board::after {
  background:
    radial-gradient(circle at 18% 30%, rgba(200, 161, 95, 0.2), transparent 15rem),
    radial-gradient(circle at 80% 76%, rgba(166, 54, 60, 0.18), transparent 14rem);
  filter: blur(2px);
}

.fx-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.9;
}

.board-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.board-head .section-label {
  margin-bottom: 0;
}

.board-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.card-stage {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  min-height: 72px;
  perspective: 720px;
}

.poker-card {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 0.72;
  border: 1px solid rgba(243, 238, 228, 0.22);
  border-radius: 7px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(219, 223, 213, 0.9)),
    #f6f2e9;
  color: #171615;
  font-size: clamp(17px, 5vw, 24px);
  font-weight: 950;
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-28px) rotateX(64deg) rotate(-8deg) scale(0.86);
  overflow: hidden;
  animation: dealCardLoop 4.8s cubic-bezier(0.2, 0.82, 0.22, 1) infinite;
  animation-delay: var(--delay);
}

.poker-card::before,
.poker-card::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.poker-card::before {
  background:
    linear-gradient(90deg, transparent 0 10%, rgba(255, 255, 255, 0.6) 45%, transparent 72%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.14) 0 1px, transparent 1px 5px);
  opacity: 0;
  transform: translateX(-120%);
  mix-blend-mode: screen;
  animation: cardGlitch 4.8s steps(7) infinite;
  animation-delay: var(--delay);
}

.poker-card::after {
  inset: auto 8px 8px;
  height: 3px;
  border-radius: 999px;
  background: rgba(200, 161, 95, 0.55);
  filter: blur(5px);
  opacity: 0;
  animation: cardUnderGlow 4.8s ease infinite;
  animation-delay: var(--delay);
}

.poker-card.red {
  color: #a83237;
}

@keyframes dealCardLoop {
  0%,
  86%,
  100% {
    opacity: 0;
    transform: translateY(-28px) rotateX(64deg) rotate(-8deg) scale(0.86);
  }

  12% {
    opacity: 1;
    transform: translateY(4px) rotateX(0deg) rotate(2deg) scale(1.03);
  }

  18%,
  72% {
    opacity: 1;
    transform: translateY(0) rotateX(0deg) rotate(0deg) scale(1);
  }

  78% {
    opacity: 0;
    transform: translateY(22px) rotateX(-44deg) rotate(6deg) scale(0.9);
  }
}

@keyframes cardGlitch {
  0%,
  8%,
  74%,
  100% {
    opacity: 0;
    transform: translateX(-120%);
  }

  10% {
    opacity: 0.72;
    transform: translateX(-38%);
  }

  13% {
    opacity: 0.18;
    transform: translateX(8%);
  }

  16% {
    opacity: 0;
    transform: translateX(120%);
  }
}

@keyframes cardUnderGlow {
  0%,
  9%,
  80%,
  100% {
    opacity: 0;
  }

  13%,
  70% {
    opacity: 1;
  }
}

@keyframes mosaicDrift {
  0% {
    transform: translate3d(-18px, -12px, 0);
  }

  100% {
    transform: translate3d(18px, 12px, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .poker-card,
  .poker-card::before,
  .poker-card::after,
  .poker-board::before {
    animation: none;
  }

  .poker-card {
    opacity: 1;
    transform: none;
  }
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
}

.primary-button {
  padding: 0 14px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  color: #17120b;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(200, 161, 95, 0.2);
}

.secondary-button {
  padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-weight: 700;
}

button:active {
  transform: scale(0.97);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 14px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 11, 11, 0.72);
}

.tab {
  min-height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: linear-gradient(180deg, #252421, var(--panel-strong));
  color: var(--text);
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: grid;
  gap: 14px;
}

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

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  outline: 0;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: rgba(200, 161, 95, 0.76);
}

.table-footer {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 8px 8px 14px;
  border: 1px solid rgba(200, 161, 95, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(200, 161, 95, 0.08), transparent),
    rgba(18, 18, 17, 0.96);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
}

.table-footer div {
  display: grid;
  gap: 2px;
}

.table-footer span,
.player-meta {
  color: var(--muted);
  font-size: 12px;
}

.table-footer strong {
  font-size: 20px;
  line-height: 1;
}

.player-list,
.settlement-list,
.transfer-list,
.leaderboard-list,
.history-list {
  display: grid;
  gap: 10px;
}

.leaderboard-panel .leaderboard-list {
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.swipe-row {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.player-card {
  position: relative;
  z-index: 1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent),
    var(--panel);
}

.player-card.is-away {
  border-color: rgba(138, 174, 216, 0.42);
  background:
    linear-gradient(135deg, rgba(138, 174, 216, 0.12), transparent 58%),
    var(--panel);
}

.swipe-card {
  transition: transform 180ms ease;
  touch-action: pan-y;
}

.swipe-row.is-open .swipe-card {
  transform: translateX(-86px);
}

.player-head,
.panel-heading,
.result-row,
.transfer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-head {
  align-items: start;
}

.player-name {
  margin: 0;
  font-size: 18px;
  word-break: break-word;
}

.player-profit {
  font-size: 15px;
  font-weight: 900;
}

.buyin-stack {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: max-content;
}

.player-status {
  display: grid;
  gap: 3px;
  margin-top: 5px;
}

.player-status span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.player-status strong {
  font-size: 12px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

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

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.away-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.quick-actions button,
.away-actions button {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--text);
  font-weight: 800;
}

.away-actions button {
  border-color: rgba(138, 174, 216, 0.28);
  background: rgba(138, 174, 216, 0.08);
}

.swipe-delete {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 78px;
  border-radius: 0 8px 8px 0;
  background: #6f2725;
  color: #fff0ee;
  font-weight: 900;
}

.settle-status.is-balanced {
  border-color: rgba(121, 200, 145, 0.38);
}

.settle-status.has-gap {
  border-color: rgba(217, 111, 107, 0.42);
}

.settle-entry-panel {
  display: grid;
  gap: 12px;
}

.settle-entry-panel .settlement-list {
  gap: 0;
  border-top: 1px solid var(--line-soft);
}

.settle-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.settle-complete {
  white-space: nowrap;
}

.result-row,
.transfer-row {
  min-height: 56px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.settle-entry-panel .result-row {
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
}

.settle-entry-panel .result-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.leaderboard-row,
.history-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.leaderboard-row {
  min-height: 66px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.leaderboard-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.history-item {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.history-row {
  min-height: 56px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.history-item.is-open .history-row {
  border-bottom: 1px solid var(--line-soft);
}

.history-detail {
  display: grid;
  gap: 8px;
  padding: 10px 14px 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}

.detail-row span {
  font-weight: 800;
}

.detail-row small {
  color: var(--muted);
  font-size: 12px;
}

.detail-row strong {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.rank-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--accent);
  font-weight: 900;
}

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

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

.row-title small,
.history-row small {
  color: var(--muted);
  font-size: 12px;
}

.settle-row {
  align-items: end;
}

.settle-row div,
.settle-row label {
  display: grid;
  gap: 5px;
}

.settle-row small,
.settle-row label span {
  color: var(--muted);
  font-size: 12px;
}

.settle-row input {
  width: 86px;
  min-height: 38px;
  text-align: right;
}

.settle-row.is-away input {
  border-color: rgba(138, 174, 216, 0.24);
  background: rgba(138, 174, 216, 0.08);
  color: var(--muted);
}

.settle-row strong {
  min-width: 62px;
  text-align: right;
}

.transfer-row strong {
  color: var(--blue);
}

.hand-rules-panel {
  display: grid;
  gap: 14px;
}

.hand-rank-list,
.rule-note-list {
  display: grid;
  gap: 8px;
}

.hand-rank {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent),
    var(--panel);
}

.hand-rank.top-hand {
  border-color: rgba(200, 161, 95, 0.42);
  background:
    linear-gradient(135deg, rgba(200, 161, 95, 0.16), transparent 56%),
    var(--panel);
}

.hand-rank h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.15;
}

.hand-rank p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.hand-cards {
  display: flex;
  justify-content: flex-end;
  min-width: 132px;
  padding-left: 8px;
}

.mini-card {
  display: grid;
  place-items: center;
  width: 32px;
  height: 42px;
  margin-left: -8px;
  border: 1px solid rgba(243, 238, 228, 0.2);
  border-radius: 6px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(220, 222, 215, 0.9)),
    #f5f1e8;
  color: #161514;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.24);
}

.mini-card:first-child {
  margin-left: 0;
}

.mini-card.red {
  color: #a83237;
}

.rule-note-panel {
  box-shadow: none;
}

.rule-note-list {
  gap: 0;
  border-top: 1px solid var(--line-soft);
}

.rule-note-list div {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.rule-note-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.rule-note-list strong {
  color: var(--text);
  font-size: 14px;
}

.rule-note-list span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

@media (max-width: 360px) {
  .add-player {
    grid-template-columns: 1fr;
  }

  .tab {
    min-height: 38px;
    font-size: 13px;
  }

  .settle-row {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .settle-head {
    grid-template-columns: 1fr;
  }

  .settle-row strong {
    grid-column: 1 / -1;
    text-align: left;
  }

  .table-footer strong {
    font-size: 18px;
  }

  .hand-rank {
    grid-template-columns: auto 1fr;
  }

  .hand-cards {
    grid-column: 2;
    justify-self: start;
    min-width: 120px;
    padding-left: 0;
  }

  .mini-card {
    width: 30px;
    height: 38px;
    margin-left: -7px;
    font-size: 12px;
  }
}
