:root {
  --bg-felt: #0c3324;
  --bg-felt-dark: #071f16;
  --felt-texture: radial-gradient(circle at 50% 30%, #15573d 0%, #0c3324 70%, #061d14 100%);
  --panel-bg: rgba(9, 31, 22, 0.94);
  --panel-border: rgba(255, 215, 0, 0.25);
  --text-main: #f7fafc;
  --text-muted: #a0aec0;
  --gold-highlight: #ecc94b;
  --card-red: #e53e3e;
  --card-black: #1a202c;
  --btn-primary-bg: #d69e2e;
  --btn-primary-hover: #b7791f;
  --btn-secondary-bg: rgba(255, 255, 255, 0.12);
  --btn-secondary-hover: rgba(255, 255, 255, 0.2);
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --border-radius-sm: 6px;
  --border-radius-md: 10px;
  --border-radius-lg: 16px;
}

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

html, body {
  width: 100%;
  min-height: 100%;
  background-color: #05140e;
  font-family: var(--font-family);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* 非全屏固定视口卡片布局：留出呼吸感与桌面质感 */
.game-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1024px;
  height: 94vh;
  max-height: 820px;
  background: var(--felt-texture);
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 215, 0, 0.3);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.meta-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-highlight);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-width: 68px;
}

.stat-title {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-number {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--btn-secondary-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  text-decoration: none;
}

.icon-button:hover {
  background: var(--btn-secondary-hover);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button.text-btn {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.ui-icon {
  width: 18px;
  height: 18px;
}

.canvas-wrap {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: default;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn.primary {
  background: var(--btn-primary-bg);
  color: #1a202c;
  box-shadow: 0 2px 6px rgba(214, 158, 46, 0.4);
}

.action-btn.primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
  color: #fff;
}

.action-btn.secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btn.secondary:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-icon {
  width: 16px;
  height: 16px;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
}

.modal-card {
  background: #112d22;
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  width: 90%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.modal-title {
  font-size: 20px;
  color: var(--gold-highlight);
  margin-bottom: 12px;
}

.modal-title.win-title {
  color: #68d391;
  font-size: 24px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.rules-body {
  text-align: left;
  font-size: 13px;
  line-height: 1.6;
  color: #e2e8f0;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules-body strong {
  color: var(--gold-highlight);
}

.settle-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.settle-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-highlight);
}

.modal-submit-btn {
  width: 100%;
  padding: 12px;
  background: var(--btn-primary-bg);
  color: #1a202c;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
}

.modal-submit-btn:hover {
  background: var(--btn-primary-hover);
  color: #fff;
}

.hidden {
  display: none !important;
}

.noscript-banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: #e53e3e;
  color: #fff;
  padding: 12px;
  text-align: center;
  font-weight: 600;
}

@media (max-width: 768px) {
  body {
    padding: 0;
  }
  .game-container {
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
  }
  .game-header {
    padding: 6px 10px;
  }
  .stat-pill {
    padding: 2px 6px;
    min-width: 50px;
  }
  .stat-title {
    font-size: 9px;
  }
  .stat-number {
    font-size: 12px;
  }
  .action-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .action-btn span {
    display: none;
  }
  .action-btn .btn-icon {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
