/* 通关麻将（小鱼玩法）· 2.5D 横版益智麻将样式 */
:root {
  --bg-deep: #062b1b;
  --rail-bg: rgba(7, 37, 24, 0.9);
  --rail-border: rgba(212, 175, 55, 0.25);
  --card-bg: rgba(12, 54, 36, 0.72);
  --gold: #f5c95c;
  --gold-soft: rgba(245, 201, 92, 0.18);
  --emerald: #34d399;
  --rose: #fb7185;
  --text-main: #f5f2e9;
  --text-muted: #9bc4b0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* 3-Column Landscape Shell */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100dvh;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-deep);
}

.rail {
  width: clamp(98px, 12.5vw, 136px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px;
  background: var(--rail-bg);
  z-index: 5;
}

.rail-left {
  border-right: 1px solid var(--rail-border);
}

.rail-right {
  border-left: 1px solid var(--rail-border);
}

/* Brand & Mode Header */
.brand-box {
  background: linear-gradient(145deg, rgba(245, 201, 92, 0.16), rgba(16, 86, 56, 0.55));
  border: 1px solid rgba(245, 201, 92, 0.36);
  border-radius: 10px;
  padding: 7px 6px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.brand-box:active {
  transform: scale(0.97);
}

.brand-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.variant-tag {
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.5px;
}

.variant-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(6, 30, 20, 0.72);
  border: 1px solid rgba(245, 201, 92, 0.22);
  border-radius: 10px;
}

.variant-bar-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
}

.variant-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 54, 36, 0.8);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
}

.variant-chip.active {
  background: rgba(245, 201, 92, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.variant-chip.coming-soon {
  opacity: 0.52;
  cursor: not-allowed;
  border-style: dashed;
}

.mode-pill {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: #e6fff2;
  background: rgba(5, 36, 23, 0.65);
  border-radius: 99px;
  padding: 2px 6px;
  display: inline-block;
}

.daily-sub {
  margin-top: 3px;
  font-size: 10px;
  color: #fde68a;
  font-weight: 600;
}

/* Stats Panel */
.stat-panel {
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  gap: 4px;
}

.stat-label {
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-val {
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
  white-space: nowrap;
}

.stat-highlight .stat-val {
  color: var(--gold);
  font-size: 12px;
}

.stat-mini {
  font-size: 10px;
}

.stat-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 2px 0;
}

/* Left Nav Grid */
.rail-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.nav-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 68, 45, 0.72);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 2px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.nav-btn:hover {
  background: rgba(22, 92, 62, 0.9);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* Center Board Stage */
.board-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#game-canvas:active {
  cursor: grabbing;
}

/* Floating Banners on Board */
.floating-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  z-index: 12;
  white-space: nowrap;
}

.banner-trial {
  background: rgba(28, 22, 8, 0.88);
  border: 1.5px solid #f59e0b;
  color: #fef3c7;
}

.banner-hammer {
  background: rgba(45, 10, 18, 0.9);
  border: 1.5px solid #fb7185;
  color: #ffe4e6;
}

.banner-btn {
  appearance: none;
  border: none;
  background: #f59e0b;
  color: #1f1402;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
}

.banner-hammer .banner-btn {
  background: #fb7185;
  color: #fff;
}

.toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 26, 17, 0.92);
  border: 1px solid rgba(245, 201, 92, 0.45);
  color: #fef3c7;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  z-index: 14;
  white-space: nowrap;
  pointer-events: none;
}

/* Right Rail: Free Trial Revert + 4 Props + Footer */
.revert-btn {
  appearance: none;
  width: 100%;
  border: 1.5px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
  border-radius: 10px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.revert-btn:not(:disabled) {
  border-color: #f59e0b;
  background: linear-gradient(145deg, #d97706, #b45309);
  color: #fff;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45);
  animation: softPulse 1.4s infinite;
}

.revert-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

@keyframes softPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.38); }
  50% { box-shadow: 0 0 18px rgba(245, 158, 11, 0.72); }
}

.props-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  justify-content: center;
}

.props-header {
  font-size: 10px;
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 1.5px;
}

.prop-btn {
  position: relative;
  appearance: none;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(14, 65, 43, 0.8);
  color: var(--text-main);
  border-radius: 9px;
  padding: 5px 6px;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 4px;
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.prop-btn:hover:not(:disabled) {
  border-color: rgba(245, 201, 92, 0.55);
  background: rgba(20, 88, 58, 0.92);
}

.prop-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.prop-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.prop-btn.active-hammer {
  border-color: #fb7185;
  background: rgba(159, 18, 57, 0.72);
  box-shadow: 0 0 12px rgba(251, 113, 133, 0.45);
}

.prop-btn .prop-icon {
  grid-row: 1 / 3;
  font-size: 16px;
  text-align: center;
}

.prop-btn .prop-name {
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.15;
}

.prop-btn .prop-cost {
  font-size: 9.5px;
  color: var(--text-muted);
}

.prop-sub {
  font-size: 9.5px;
  opacity: 0.88;
}

.prop-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: #103c29;
  border: 1px solid rgba(245, 201, 92, 0.55);
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-footer {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.action-btn {
  appearance: none;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(16, 70, 48, 0.78);
  color: var(--text-main);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:hover {
  background: rgba(24, 96, 66, 0.92);
}

.action-gold {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #fbbf24;
  color: #fff;
}

/* Portrait Overlay */
.portrait-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 24, 15, 0.94);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}

.portrait-card {
  max-width: 320px;
  text-align: center;
  background: #0c3d28;
  border: 1px solid rgba(245, 201, 92, 0.4);
  border-radius: 16px;
  padding: 24px 20px;
}

.rotate-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.portrait-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--gold);
}

.portrait-card p {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.5;
  color: #d6ede0;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 16, 10, 0.76);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 50;
}

.modal-card {
  background: linear-gradient(165deg, #0e442c, #082b1c);
  border: 1px solid rgba(245, 201, 92, 0.36);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  max-height: 92dvh;
  overflow-y: auto;
  color: var(--text-main);
}

.modal-wide {
  width: min(680px, 94vw);
}

.modal-compact {
  width: min(420px, 92vw);
  text-align: center;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--gold);
}

.modal-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}

/* Mode Selector Grid */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-card {
  appearance: none;
  text-align: left;
  background: rgba(8, 38, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s, background 0.15s;
}

.mode-card:hover {
  border-color: var(--gold);
  background: rgba(14, 58, 39, 0.95);
}

.mode-card-daily {
  cursor: default;
  border-color: rgba(245, 201, 92, 0.35);
}

.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.mc-icon {
  font-size: 20px;
}

.mc-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
}

.tag-gold {
  background: rgba(245, 201, 92, 0.2);
  color: var(--gold);
}

.mc-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 4px;
}

.mc-desc {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.daily-picker {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.daily-picker input[type="date"],
.lb-daily-filter input[type="date"] {
  background: #062517;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
}

.daily-num-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
}

.daily-num-wrap input,
.lb-daily-filter input[type="number"] {
  width: 44px;
  background: #062517;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 6px;
  padding: 4px 5px;
  font-size: 11.5px;
  text-align: center;
}

/* Buttons */
.btn-primary {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1c1002;
  font-weight: 800;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
}

.btn-emerald {
  background: linear-gradient(135deg, #34d399, #059669);
  color: #032416;
}

.btn-rose {
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 11.5px;
}

.btn-secondary {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-weight: 600;
  font-size: 12.5px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
}

/* Leaderboard */
.player-name-box {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: auto;
}

.player-name-box input {
  width: 96px;
  background: #062517;
  border: 1px solid rgba(245, 201, 92, 0.35);
  color: #fff;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 12px;
}

.lb-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.seg-group {
  display: flex;
  gap: 5px;
}

.seg-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(6, 33, 21, 0.8);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 99px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.lb-daily-filter {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
}

.lb-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.lb-tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(6, 30, 20, 0.7);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
}

.lb-tab.active {
  background: rgba(52, 211, 153, 0.18);
  border-color: var(--emerald);
  color: #ecfdf5;
}

.lb-weight-tip {
  font-size: 11px;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
}

.lb-table-wrap {
  max-height: 220px;
  overflow-y: auto;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(5, 26, 17, 0.72);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.lb-table th, .lb-table td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(8, 38, 25, 0.9);
  position: sticky;
  top: 0;
}

.lb-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* Rules List */
.rules-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: rgba(6, 30, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.48;
  color: #e2f2e9;
}

.rule-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  color: #1c1002;
  font-weight: 900;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* Victory & Deadlock Modals */
.win-crown {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 4px;
}

.win-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.win-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 10px;
}

.win-stat-box {
  background: rgba(6, 30, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 7px 8px;
}

.ws-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.ws-val {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}

.win-rank-note {
  font-size: 11.5px;
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 12px;
}

.deadlock-title {
  font-size: 18px;
  font-weight: 800;
  color: #fca5a5;
  margin-bottom: 6px;
}

.deadlock-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #d6ede0;
  margin: 0 0 12px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-actions-col {
  flex-direction: column;
}

.dl-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Compact short mobile landscape phones (height <= 420px, e.g., iPhone landscape) */
@media (max-height: 430px) {
  .rail {
    width: 96px;
    padding: 6px 5px;
    gap: 4px;
  }
  .brand-box {
    padding: 4px 4px;
  }
  .brand-title {
    font-size: 12.5px;
  }
  .mode-pill {
    font-size: 9.5px;
  }
  .stat-panel {
    padding: 5px 6px;
    gap: 2px;
  }
  .stat-row {
    font-size: 10px;
  }
  .stat-highlight .stat-val {
    font-size: 11px;
  }
  .nav-btn {
    padding: 4px 1px;
    font-size: 9.5px;
  }
  .revert-btn {
    padding: 4px 3px;
  }
  .prop-btn {
    padding: 3.5px 5px;
  }
  .prop-btn .prop-icon {
    font-size: 14px;
  }
  .prop-btn .prop-name {
    font-size: 10.5px;
  }
  .prop-btn .prop-cost {
    font-size: 8.5px;
  }
  .action-btn {
    padding: 4px 3px;
    font-size: 10px;
  }
  .floating-banner {
    top: 4px;
    padding: 4px 10px;
    font-size: 11px;
  }
}

[hidden] {
  display: none !important;
}
