:root {
  --bg-primary: #0a0e17;
  --bg-card: #131b2e;
  --bg-card-hover: #1c2742;
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-green: #10b981;
  --accent-yellow: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #a855f7;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: rgba(255, 255, 255, 0.08);
  --dice-red: #dc2626;
  --dice-dot: #1f2937;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding-bottom: 40px;
  line-height: 1.5;
  background-image: 
    radial-gradient(circle at 10% 15%, rgba(79, 172, 254, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, rgba(168, 85, 247, 0.08) 0%, transparent 45%);
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

header {
  text-align: center;
  margin-bottom: 16px;
  padding-top: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(168, 85, 247, 0.2));
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
  margin-bottom: 6px;
}

h1 {
  font-size: 23px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 3px;
}

.subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.algo-switcher-card {
  background: #111827;
  border-radius: 14px;
  padding: 6px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.algo-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.algo-tab {
  background: transparent;
  border: none;
  padding: 10px 6px;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.algo-tab .tab-icon { font-size: 18px; }
.algo-tab .tab-name { font-size: 13px; font-weight: 700; }
.algo-tab .tab-sub { font-size: 10px; opacity: 0.75; }

.algo-tab.active-binomial {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

.algo-tab.active-bayesian {
  background: rgba(79, 172, 254, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(79, 172, 254, 0.4);
  box-shadow: 0 0 12px rgba(79, 172, 254, 0.2);
}

.algo-tab.active-cfr {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.2);
}

.algo-specific-bar {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  font-size: 12px;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.personality-options {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.personality-btn {
  flex: 1;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.personality-btn.active {
  background: #0284c7;
  color: #fff;
  font-weight: 700;
  border-color: #38bdf8;
}

.cfr-mix-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0;
  background: #1f2937;
}
.cfr-mix-challenge { background: #ef4444; }
.cfr-mix-value { background: #10b981; }
.cfr-mix-bluff { background: #a855f7; }

.cfr-mix-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.cfr-dice-roll-btn {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(135deg, #7c3aed, #9333ea);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.cfr-dice-roll-btn:active {
  transform: scale(0.98);
  filter: brightness(1.1);
}

.card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.counter-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.counter-btn {
  width: 40px;
  height: 38px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.counter-btn:active { background: rgba(255, 255, 255, 0.1); }

.counter-value {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border-color);
}

.segment-btn {
  flex: 1;
  border: none;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.segment-btn.active.zhai-active {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.my-dice-section { text-align: center; }

.dice-container {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0;
}

.die {
  width: 58px;
  height: 58px;
  background: #f8fafc;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 -3px 4px rgba(0, 0, 0, 0.15), inset 0 2px 2px rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.die:active { transform: scale(0.92); }

.die-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dice-dot);
  align-self: center;
  justify-self: center;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.die[data-val='1'] .die-pip {
  background: var(--dice-red);
  width: 16px;
  height: 16px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.die[data-val='4'] .die-pip { background: var(--dice-red); }

.hand-summary {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-around;
  margin-top: 8px;
}

.hand-summary span { color: var(--accent-cyan); font-weight: bold; }

.quick-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 8px;
  cursor: pointer;
}

.bid-input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.point-selector {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.point-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  height: 38px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.point-btn.active {
  background: var(--accent-cyan);
  color: #04101e;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

.point-btn[data-point='1'] { color: #f87171; }
.point-btn[data-point='1'].active { color: #7f1d1d; }

.decision-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0, 242, 254, 0.2);
}

.decision-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.current-bid-tag {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.current-bid-tag span { color: var(--accent-cyan); font-size: 20px; }

.odds-meter-box { margin-bottom: 14px; }

.meter-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.meter-bar {
  height: 14px;
  background: #1f2937;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  position: relative;
}

.meter-fill-pass {
  background: linear-gradient(90deg, #10b981, #059669);
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter-fill-open {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
  height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter-hint-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.action-hero {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.3s;
}

.action-hero.open-strong {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(185, 28, 28, 0.3));
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.action-hero.bid-strong {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.3));
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.action-hero.balanced {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.3));
  border: 1px solid rgba(245, 158, 11, 0.5);
}

.action-icon { font-size: 32px; flex-shrink: 0; }
.action-info { flex: 1; }

.action-main-text {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 2px;
}

.open-strong .action-main-text { color: #fca5a5; }
.bid-strong .action-main-text { color: #6ee7b7; }
.balanced .action-main-text { color: #fde68a; }

.action-sub-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.algo-badge-note {
  font-size: 11px;
  color: var(--accent-cyan);
  margin-top: 4px;
  display: block;
}

.strategies-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.strategy-card {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--border-color);
}

.strategy-tag {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.strategy-val {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.strategy-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}

.matrix-table th {
  color: var(--text-muted);
  text-align: left;
  padding: 6px 4px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.matrix-table td {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.prob-bar-cell { width: 45%; }

.prob-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.prob-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.2s;
}

footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 20px;
  line-height: 1.6;
}

/* ================== PWA & Mobile Install Styles ================== */
.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 6px;
}

.header-install-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(79, 172, 254, 0.25));
  border: 1px solid rgba(0, 242, 254, 0.4);
  color: var(--accent-cyan);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.header-install-btn:hover {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.35), rgba(79, 172, 254, 0.4));
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.install-banner {
  background: linear-gradient(135deg, rgba(19, 27, 46, 0.95), rgba(15, 23, 42, 0.95));
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 16px rgba(0, 242, 254, 0.1);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.install-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.install-icon {
  font-size: 24px;
  line-height: 1;
}

.install-text {
  display: flex;
  flex-direction: column;
}

.install-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.install-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.install-banner-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-install {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
}

.btn-install:active {
  transform: scale(0.96);
  filter: brightness(1.1);
}

.btn-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-dismiss:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* iOS Safari 引导弹窗 */
.ios-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ios-modal-card {
  background: #131b2e;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  max-width: 360px;
  width: 100%;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

.ios-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.ios-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.ios-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}

.ios-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.ios-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.ios-step strong {
  color: var(--text-primary);
}

.ios-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(79, 172, 254, 0.2);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.ios-inline-icon {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent-cyan);
}

.ios-modal-btn {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}