:root {
  --bg-top: #1a6b3c;
  --bg-bottom: #0e4226;
  --card-w: 46px;
  --card-h: 66px;
  --text-light: #f5f0e0;
  --gold: #ffd54f;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ---------- 开始界面 ---------- */
#start-screen {
  justify-content: center;
  align-items: center;
  gap: 32px;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.logo {
  text-align: center;
}

.logo h1 {
  font-size: 64px;
  letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 3px 0 #8d6e00, 0 6px 12px rgba(0,0,0,.5);
}

.logo .sub {
  margin-top: 10px;
  color: var(--text-light);
  font-size: 15px;
  letter-spacing: 3px;
  opacity: .85;
}

.start-btns {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 220px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffb300, #f57f17);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  box-shadow: 0 4px 0 #a86400, 0 8px 16px rgba(0,0,0,.35);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a86400;
}

.rules-toggle {
  color: var(--text-light);
  text-decoration: underline;
  font-size: 14px;
  opacity: .9;
  padding: 8px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.55);
}

.modal-box {
  width: 82%;
  max-width: 340px;
  background: linear-gradient(160deg, #fdf8ec, #f3e6c8);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}

.modal-box h2 {
  font-size: 22px;
  color: #6d4c00;
  margin-bottom: 14px;
}

.modal-box ul {
  text-align: left;
  font-size: 13px;
  color: #5a4630;
  line-height: 1.9;
  padding-left: 18px;
  margin-bottom: 16px;
}

.call-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-call {
  padding: 12px 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffb300, #f57f17);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 3px 0 #a86400;
}

.btn-call:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #a86400;
}

/* ---------- 游戏主界面（横屏） ---------- */
#game-screen {
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 70%);
}

.table {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

/* 主体行：左电脑 | 中间牌桌 | 右电脑 */
.main-row {
  flex: 1;
  display: flex;
  min-height: 0;
  gap: 4px;
}

.side-col {
  width: 120px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.center-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.center-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.call-info {
  color: var(--gold);
  font-size: 16px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
  text-align: center;
}

.landlord-info {
  color: var(--text-light);
  font-size: 13px;
}

.dizhu-cards {
  display: flex;
  gap: 3px;
}

.dizhu-cards .mini-card {
  width: 40px;
  height: 58px;
}

/* 玩家信息条 */
.player-info {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,.3);
  border-radius: 20px;
  padding: 4px 10px 4px 4px;
  color: var(--text-light);
  font-size: 12px;
  width: 100%;
}

.player-info .avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(160deg, #5c7cfa, #3b5bdb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  flex-shrink: 0;
}

.player-info .avatar.me {
  background: linear-gradient(160deg, #f783ac, #e64980);
}

.player-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.player-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
}

.role-badge {
  font-size: 10px;
  color: var(--gold);
  height: 12px;
  line-height: 12px;
}

.card-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-left: auto;
}

/* 出牌区域 */
.play-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  width: 100%;
  flex-wrap: wrap;
}

.play-area .played-card {
  width: 44px;
  height: 62px;
}

.play-area.side {
  min-height: 60px;
}

.play-area.side .mini-card {
  width: 40px;
  height: 56px;
}

/* 底部我的区域 */
.my-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#player-me {
  align-self: flex-start;
  width: auto;
  max-width: 60%;
}

/* 手牌 */
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--card-h) + 24px);
  position: relative;
  padding-top: 6px;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  background: #fff;
  border: 1px solid #c8c2b2;
  box-shadow: 0 2px 3px rgba(0,0,0,.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
  transition: transform .12s ease;
  margin-left: -20px;
  cursor: pointer;
  flex-shrink: 0;
}

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

.card .rank {
  font-size: 14px;
  line-height: 1;
}

.card .suit {
  font-size: 11px;
  line-height: 1;
  margin-top: 2px;
}

.card.red .rank, .card.red .suit {
  color: #d62727;
}

.card.black .rank, .card.black .suit {
  color: #1f2328;
}

.card.selected {
  transform: translateY(-16px);
}

.card.joker-big {
  background: linear-gradient(160deg, #ff7a6e, #e33e2f);
  color: #fff;
}

.card.joker-small {
  background: linear-gradient(160deg, #6e7dff, #3b4bd4);
  color: #fff;
}

.card.small {
  width: 40px;
  height: 56px;
  font-size: 11px;
}

.card.small .rank { font-size: 13px; }
.card.small .suit { font-size: 11px; }

/* 操作按钮 */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 14px;
  min-height: 38px;
  align-items: center;
}

.action-bar button {
  padding: 7px 24px;
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 3px 0 rgba(0,0,0,.3);
}

.action-bar button:active {
  transform: translateY(2px);
}

.btn-pass {
  background: linear-gradient(180deg, #9e9e9e, #616161);
}

.btn-hint {
  background: linear-gradient(180deg, #4fc3f7, #0288d1);
}

.btn-play {
  background: linear-gradient(180deg, #ffb300, #f57f17);
}

/* 结算 */
.result-detail {
  font-size: 15px;
  color: #5a4630;
  line-height: 2;
  margin-bottom: 16px;
}

.win-title { color: #c62828; }
.lose-title { color: #2e5395; }

/* Toast 提示 */
.toast {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 22px;
  border-radius: 20px;
  font-size: 15px;
  z-index: 60;
  pointer-events: none;
}

/* ---------- 强制横屏（竖屏时自动旋转） ---------- */
#app.forced-landscape {
  width: 100vh;
  height: 100vw;
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -50vw;
  margin-left: -50vh;
  transform: rotate(90deg);
  transform-origin: 50% 50%;
}

@media (max-height: 400px) {
  :root {
    --card-w: 42px;
    --card-h: 60px;
  }
  .side-col { width: 108px; }
}
