/* 川麻 —— 墨绿毡面牌桌 + 象牙色牌 */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(ellipse at 50% 8%, #23503a 0%, #0f1f17 70%), #0d1a13;
  color: #f0e9d8;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button {
  font: inherit; border: none; border-radius: 10px;
  padding: 8px 14px; background: #2f6146; color: #f0e9d8; cursor: pointer;
  transition: filter .12s, transform .06s;
}
button:hover:not(:disabled) { filter: brightness(1.18); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: #c9932f; color: #241a08; font-weight: 700; }
button.warn { background: #a34434; }
button.big { padding: 11px 18px; font-size: 16px; }
button.linkish { background: none; color: #cdb98e; text-decoration: underline; padding: 4px; }
input {
  font: inherit; padding: 10px 12px; border-radius: 9px;
  border: 1px solid #7d6c4c; background: #fff; color: #241a12; width: 100%;
}
.err { color: #ff9d8a; min-height: 1.2em; margin: 0; }
.hint { color: #a9986f; font-size: 13px; line-height: 1.7; margin: 0; }
.hint a { color: #e8c04b; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 首页 / 等人 */
.screen { min-height: 100dvh; }
#home, #lobby { display: grid; place-items: center; padding: 18px; }
.card {
  background: #f6efdd; color: #2b2118;
  border-radius: 16px; padding: 24px; width: min(460px, 94vw);
  display: flex; flex-direction: column; gap: 13px;
  box-shadow: 0 20px 50px rgba(0,0,0,.62);
}
.card h1 { margin: 0; font-size: 30px; letter-spacing: 1px; }
.card h2 { margin: 0; }
.card .hint { color: #7a6749; }
.card .hint a { color: #a8541c; }
.sub { font-size: 14px; color: #967c4e; margin-left: 10px; letter-spacing: 3px; }
.tagline { margin: 0; color: #7a6749; font-size: 14px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; }
.room-code { font-family: ui-monospace, monospace; letter-spacing: 5px; color: #a8541c; }
#lobby-seats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
#lobby-seats li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.tag { font-size: 11px; background: #ddcba6; color: #4a3a28; border-radius: 5px; padding: 1px 7px; }

/* ---------- 牌桌 ---------- */
#table { display: flex; flex-direction: column; height: 100dvh; padding: 8px; gap: 6px; }
#felt {
  position: relative; flex: 1; min-height: 0;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,235,180,.12), rgba(0,0,0,.38) 74%),
    url("img/felt.jpg") center / cover,
    linear-gradient(#1f4e35, #173a28);
  box-shadow: inset 0 0 60px rgba(0,0,0,.55), 0 10px 30px rgba(0,0,0,.5);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 8px;
  overflow: hidden;
}

.opp { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
#opp-2 { grid-row: 1; }
.opp.side { position: absolute; top: 50%; transform: translateY(-50%); flex-direction: column; max-height: 66%; }
#opp-1 { right: 6px; }     /* 下家 */
#opp-3 { left: 6px; }      /* 上家 */
.opp .who {
  font-size: 12px; color: #d8cba6; background: rgba(0,0,0,.4);
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.opp .who.turn { background: #c9932f; color: #241a08; font-weight: 700; }
.opp .who.won { background: #a8541c; color: #fff; }
.opp .backs { display: flex; gap: 1px; }
/* 左右两家的牌要竖着摞,横着排 13 张会顶出毡面 */
.opp.side .backs { flex-direction: column; }
.opp.side .disc { max-width: 84px; }
.opp.side .melds { max-width: 84px; }
.opp .melds { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.opp .disc { display: flex; gap: 1px; flex-wrap: wrap; max-width: 300px; justify-content: center; }

#center {
  grid-row: 2; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; min-height: 0; padding: 0 90px;
}
#wall-info { font-size: 12.5px; color: #bfae86; }
#banner {
  font-size: 15px; font-weight: 600; text-align: center; min-height: 22px;
  text-shadow: 0 2px 6px rgba(0,0,0,.7);
}
#banner.mine { color: #ffd95e; }
#river {
  display: flex; flex-wrap: wrap; gap: 2px; justify-content: center;
  max-width: 520px; max-height: 40%; overflow: hidden;
}
#river .just { outline: 2px solid #ffd95e; border-radius: 4px; }

#mine { grid-row: 3; display: flex; flex-direction: column; gap: 5px; align-items: center; }
#my-melds { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; min-height: 0; }
#my-hand { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
#my-info { font-size: 12px; color: #bfae86; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.tile { cursor: pointer; line-height: 0; border-radius: 7px; transition: transform .1s; position: relative; }
.tile:hover { transform: translateY(-7px); }
.tile.sel { transform: translateY(-12px); filter: drop-shadow(0 0 7px #ffd95e); }
.tile.dead { opacity: .42; cursor: not-allowed; }
.tile.dead:hover { transform: none; }
.tile.drawn { margin-left: 14px; }
.tile.hintok::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: #6fd08a;
}
.tile.static { cursor: default; }
.tile.static:hover { transform: none; }
.meld { display: flex; gap: 1px; padding: 2px; border-radius: 6px; background: rgba(0,0,0,.22); }

#acts {
  position: absolute; left: 50%; bottom: 116px; transform: translateX(-50%);
  display: flex; gap: 10px; z-index: 6;
}
#acts button { font-size: 17px; font-weight: 700; padding: 11px 20px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
#acts .hu { background: #d3453a; }
#acts .pass { background: #4a4a44; }

#phase-panel {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(10,20,14,.82);
  display: grid; place-items: center; padding: 16px;
}
.panel-box {
  background: #f6efdd; color: #2b2118; border-radius: 14px; padding: 20px;
  width: min(560px, 94vw); display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.panel-box h3 { margin: 0; font-size: 20px; }
.suit-pick { display: flex; gap: 12px; justify-content: center; }
.suit-pick button { font-size: 19px; padding: 14px 22px; background: #e2d5b6; color: #3a2d1c; }
.suit-pick button.on { background: #c9932f; color: #241a08; font-weight: 700; }
.swap-hand { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }

#btn-quit, #btn-music {
  position: absolute; top: 8px; z-index: 7;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #f0e9d8; font-size: 15px; line-height: 1;
}
#btn-quit { right: 8px; }
#btn-music { right: 46px; }
#btn-music.off { opacity: .45; }

#log {
  flex: none; height: 52px; overflow-y: auto; font-size: 11.5px; line-height: 1.6;
  color: #93866a; padding: 0 6px;
}

#modal-layer { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 40; padding: 16px; }
#modal { gap: 10px; }
.score-row { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.score-row .pos { color: #1d7a45; font-weight: 700; }
.score-row .neg { color: #b03a2b; font-weight: 700; }
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: #241a12; color: #f0e9d8; padding: 10px 16px; border-radius: 9px; z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,.55);
}

@media (max-width: 720px) {
  #center { padding: 0 54px; }
  #acts { bottom: 104px; }
  #acts button { font-size: 15px; padding: 9px 15px; }
  .opp .disc { max-width: 180px; }
  #river { max-width: 300px; }
  #log { height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile, .tile:hover, .tile.sel { transition: none; transform: none; }
}
