* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  background: #12301f;
  color: #f2efe4;
  font-size: 14px;
}
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  padding: 8px 14px; background: #e6c15a; color: #2b2208; font-weight: 700;
}
button:hover { filter: brightness(1.08); }
button.secondary { background: #3b5b49; color: #f2efe4; }
button:disabled { opacity: .45; cursor: default; }
input {
  font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid #4b6b58;
  background: #0d2217; color: #f2efe4; min-width: 0;
}

/* ───── 시작 화면 / 로비 ───── */
.center-screen { max-width: 460px; margin: 8vh auto; padding: 0 16px; }
.panel { background: #1b4631; border: 1px solid #2f6a4b; border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1; }
h1 { text-align: center; letter-spacing: 2px; }
.code { font-size: 34px; letter-spacing: 8px; font-weight: 800; color: #e6c15a; text-align: center; margin: 4px 0 10px; }
.seat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.seat-list li { background: #123826; border-radius: 8px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 11px; background: #e6c15a; color: #2b2208; border-radius: 6px; padding: 1px 6px; margin-left: 6px; font-weight: 700; }
.tag.off { background: #8a3b3b; color: #fff; }
.hint { color: #a9c4b3; font-size: 12px; }

/* ───── 게임 화면 ───── */
.game { display: grid; grid-template-columns: 1fr 240px; height: 100vh; }
.board { display: flex; flex-direction: column; padding: 8px 12px; gap: 8px; overflow-y: auto; min-width: 0; }
.log { background: #0d2217; border-left: 1px solid #2f6a4b; padding: 8px; overflow-y: auto; font-size: 12px; line-height: 1.5; }
.log div { border-bottom: 1px solid #16372a; padding: 2px 0; }
.log .hl { color: #ffd76a; font-weight: 700; }
.topbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.score-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #123826; border-radius: 8px; padding: 3px 8px; font-size: 12px; }
.chip.me { outline: 1px solid #e6c15a; }
.status {
  background: #e6c15a; color: #2b2208; border-radius: 10px; padding: 8px 12px; font-weight: 700; text-align: center;
}
.status.wait { background: #2f4f40; color: #d9e6dd; }

.opps { display: flex; gap: 8px; flex-wrap: wrap; }
.opp { background: #17402d; border: 1px solid #2f6a4b; border-radius: 10px; padding: 6px 8px; flex: 1 1 230px; min-width: 200px; }
.opp.turn, .me-panel.turn { border-color: #e6c15a; box-shadow: 0 0 0 2px #e6c15a66; }
.pname { font-weight: 700; margin-bottom: 3px; }
.meta { color: #b8d1c1; font-size: 12px; }

.table { background: #1d5a3c; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 190px; }
.floor { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; min-height: 96px; }
.stack { display: flex; position: relative; padding: 3px; border-radius: 8px; }
.stack .card + .card { margin-left: -34px; }
.stack.pick { outline: 3px solid #ffd76a; cursor: pointer; animation: pulse 1s infinite; }
.stack .badge { position: absolute; top: -9px; left: 2px; background: #c0392b; color: #fff; font-size: 11px; padding: 0 6px; border-radius: 6px; z-index: 5; }
@keyframes pulse { 50% { background: #ffd76a33; } }
.piles { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pile {
  width: 56px; height: 84px; border-radius: 6px; background: repeating-linear-gradient(45deg, #7a1f1f, #7a1f1f 6px, #8e2a2a 6px, #8e2a2a 12px);
  border: 2px solid #f0e3c0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000;
}
.pile.pick { outline: 3px solid #ffd76a; cursor: pointer; animation: pulse 1s infinite; }
.pile.empty { opacity: .25; }
.lbl { font-size: 12px; color: #cfe3d6; margin-bottom: 3px; }
.held-row { display: flex; gap: 6px; align-items: center; }

.me-panel { background: #17402d; border: 1px solid #2f6a4b; border-radius: 10px; padding: 8px; }
.hand { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.hand .card.playable { cursor: pointer; transform: translateY(-4px); box-shadow: 0 4px 10px #0008; }
.hand .card.playable:hover { transform: translateY(-9px); }
.hand .card.dim { opacity: .55; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.cap { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.capgroup { display: flex; align-items: center; gap: 2px; background: #0f2c1e; padding: 2px 4px; border-radius: 6px; }
.capgroup .gl { font-size: 10px; color: #9fc2ad; margin-right: 3px; }

/* ───── 카드 ───── */
.card {
  width: 56px; height: 84px; border-radius: 6px; background: #f6f0de; color: #222;
  border: 2px solid #3a2f1c; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 3px 2px; position: relative; flex: 0 0 auto; user-select: none;
}
.card .m { font-size: 13px; font-weight: 800; align-self: flex-start; padding-left: 3px; line-height: 1; }
.card .e { font-size: 24px; line-height: 1; }
.card .l { font-size: 11px; font-weight: 800; border-radius: 4px; padding: 1px 4px; background: #ddd; white-space: nowrap; }
.card.g-gwang { background: #fff2b8; border-color: #b08a00; }
.card.g-gwang .l { background: #d4a900; color: #fff; }
.card.g-yeol { background: #e6f0ff; }
.card.g-yeol .l { background: #3f72c4; color: #fff; }
.card.g-tti { background: #fbe9e9; }
.card.g-tti .l { background: #a8a8a8; color: #fff; }
.card.t-hong .l { background: #d33a3a; }
.card.t-cheong .l { background: #2b6fd6; }
.card.t-cho .l { background: #2e9a4a; }
.card.g-pi { background: #eef3e4; }
.card.g-pi .l { background: #7a8a5a; color: #fff; }
.card.sp .l { background: #8a5a1f; }
.card.joker { background: linear-gradient(135deg, #e8d4ff, #c9a7ff); border-color: #5b2d9b; }
.card.joker .l { background: #5b2d9b; color: #fff; }
.card.mini { width: 30px; height: 42px; padding: 1px; border-width: 1px; border-radius: 4px; }
.card.mini .m { font-size: 9px; padding-left: 1px; }
.card.mini .e { font-size: 12px; }
.card.mini .l { font-size: 8px; padding: 0 2px; }
.card.small { width: 44px; height: 66px; }
.card.small .e { font-size: 18px; }
.card.small .l { font-size: 9px; }

/* ───── 오버레이 ───── */
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; overflow-y: auto; }
.modal { background: #1b4631; border: 1px solid #e6c15a; border-radius: 14px; padding: 18px; max-width: 760px; width: 100%; }
.modal h2 { margin-top: 0; }
.rps { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.rps button { font-size: 30px; padding: 12px 18px; }
table.sum { border-collapse: collapse; width: 100%; font-size: 13px; }
table.sum th, table.sum td { border-bottom: 1px solid #2f6a4b; padding: 4px 6px; text-align: right; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
.pos { color: #8fe3a3; font-weight: 700; }
.neg { color: #ff9a9a; font-weight: 700; }
.divide-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #8a2b2b; color: #fff; padding: 8px 16px; border-radius: 10px; display: none; z-index: 40; }

@media (max-width: 800px) {
  .game { grid-template-columns: 1fr; height: auto; }
  .log { display: none; }
}

/* 명예의 전당 창 (대기실) */
.famebtn { width: 100%; min-height: 48px; font-size: 18px; font-weight: 800; }
.fameov { position: fixed; inset: 0; background: #000b; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 12px; }
.famemd { background: #12301f; border: 2px solid #e6c15a; border-radius: 14px; padding: 14px 16px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; touch-action: pan-y; }
.famemd h2 { margin: 0 0 6px; }
.famet { width: 100%; border-collapse: collapse; font-size: 16px; margin: 10px 0; }
.famet th, .famet td { padding: 8px 6px; text-align: center; border-bottom: 1px solid #ffffff22; }
.famet td:nth-child(2) { text-align: left; }
.famet tr.me td { color: #ffd76a; font-weight: 800; }
.famemd button { width: 100%; min-height: 44px; font-size: 17px; }

/* 명예의 전당: 원점수 평균은 참고용이라 흐리게 */
.famet .famehint { color: #9bb5a5; font-weight: 400; font-size: 14px; }
.famet th.famehint small { font-size: 11px; }
