:root {
  color-scheme: dark;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: #1a120c;
  color: #f6efe2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.top, #status, #actions {
  padding: 12px 16px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.top-actions { display: flex; gap: 8px; flex: none; }

h1 { margin: 0; font-size: 28px; color: #f6e7bf; }
.top p { margin: 4px 0 0; color: #eadcc4; }

main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
  padding: 0 16px;
  min-height: 0;
}

#table { min-height: 640px; }

.felt {
  height: 100%;
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(240px, 1fr) minmax(210px, 280px);
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 45%, #248a58 0%, #0e5c39 68%, #083d26 100%);
  box-shadow: inset 0 0 0 10px #6b3f1e, inset 0 0 0 12px #e6c36a;
}

.seat.wide:first-child { grid-column: 1 / -1; grid-row: 1; }
.center { grid-column: 2; grid-row: 2; }
.seat.side:nth-child(2) { grid-column: 1; grid-row: 2; }
.seat.side:nth-child(4) { grid-column: 3; grid-row: 2; }
.seat.wide:last-child { grid-column: 1 / -1; grid-row: 3; }

.seat, .center {
  border-radius: 16px;
  background: rgba(8, 28, 18, 0.78);
  padding: 8px 10px;
  min-width: 0;
}

.seat.actor { outline: 3px solid #f0d78c; background: rgba(78, 58, 24, 0.9); }
.seat.winner { outline: 3px solid #ffe08a; }
.seat.folded { opacity: 0.72; }

.who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.identity { min-width: 0; flex: 1; }
.sitter {
  width: 64px; height: 78px; object-fit: cover; object-position: center 12%;
  border-radius: 12px; border: 2px solid #e6c36a; flex: none; background: #2a2a2a;
}
.seat.wide .sitter { width: 86px; height: 104px; }
.seat header { display: flex; gap: 8px; align-items: center; }
.made {
  margin-left: 8px; color: #8ec5ff; font-style: normal; font-weight: 800;
  background: rgba(16, 36, 72, 0.72); border: 1px solid #6aa0d8; border-radius: 8px; padding: 2px 8px;
}
.dealer {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: #e6c36a; color: #3a2a10; font-style: normal; font-weight: 800;
}

.money {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  margin-top: 4px;
}
.money b { font-size: 22px; color: #fff6d8; }
.money span { color: #ffe7a3; font-size: 12px; }
.money .up { color: #b6f3c6; }
.money .down { color: #f0b4b4; }
.seat p { margin: 4px 0; color: #d7ecff; min-height: 1.2em; }

.hands { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.group {
  border: 1.5px solid #e6c36a;
  border-radius: 10px;
  padding: 4px 6px 6px;
  background: rgba(0, 0, 0, 0.28);
  min-width: 0;
  max-width: 100%;
}
.group:first-child { flex: 1 1 150px; }
.group:last-child { flex: 1 1 190px; }
.group h3 { margin: 0 0 4px; text-align: center; color: #ffe7a3; font-size: 13px; white-space: nowrap; }
.slots { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.seat.side .hands { flex-direction: column; }
.seat.side .group { flex: none; width: 100%; }
.seat.side .card { width: 40px; height: 58px; }
.seat.side .group:last-child .slots {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  justify-content: center;
}

.card {
  width: 46px; height: 66px; border-radius: 6px;
  background: #fffaf2; color: #1b1b1b;
  display: grid; place-items: center; position: relative;
  font-weight: 800;
}
.card b { position: absolute; top: 3px; left: 4px; font-size: 14px; }
.card span { font-size: 22px; }
.card.red { color: #c81e1e; }
.card.back {
  background: #163e86;
  box-shadow: inset 0 0 0 4px #d4af37;
}
.card.empty { background: transparent; border: 1px dashed rgba(255,255,255,.45); }
.card.picked { outline: 3px solid #ffd76a; }
.card.stick { animation: stick 0.22s ease-out; }
.card.pick { cursor: pointer; }

@keyframes stick {
  0% { transform: translateY(-36px) scale(0.72) rotate(-8deg); opacity: 0.2; }
  70% { transform: translateY(3px) scale(1.06); }
  100% { transform: none; opacity: 1; }
}

.center { display: grid; align-content: center; justify-items: center; text-align: center; gap: 8px; }
.center .dealer-avatar {
  width: 168px; height: 210px; object-fit: contain; background: transparent;
}
.center strong { font-size: 26px; color: #f6e7bf; }
.center .line { color: #8ec5ff; white-space: nowrap; font-size: 16px; }

#log {
  margin: 0; padding: 8px 10px; overflow: auto;
  background: #100c09; border: 1px solid #6a5030; border-radius: 12px;
  list-style: none;
}
#log li { padding: 3px 0; color: #f3e6cf; }

#status { margin: 0; color: #fff4d2; font-size: 16px; }
#actions { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  background: #3c2c1d; color: #fff8ea; border: 1px solid #c6a15b;
  border-radius: 8px; padding: 10px 12px; font-weight: 700; cursor: pointer;
}
button:disabled { color: #8d7f6e; background: #2a2118; cursor: default; }
button.allin:not(:disabled) { background: #8d1d1d; }
button.half:not(:disabled) { background: #8a6820; }
button.call:not(:disabled), #actions button:first-child:not(:disabled) { background: #1d6b45; }

#toast {
  position: fixed; right: 28px; bottom: 92px;
  display: flex; align-items: flex-end; gap: 12px; z-index: 5;
}
#toast img {
  width: min(280px, 34vw); height: auto; border-radius: 16px;
  border: 2px solid #e6c36a; background: #222;
  animation: rise 0.55s ease-out;
}
.bubble {
  background: #fff8ec; color: #2a2118; border: 1.5px solid #e6c36a;
  border-radius: 14px; padding: 12px 14px; max-width: 240px;
}
.bubble p { margin: 0 0 6px; font-weight: 800; white-space: pre-line; }
.bubble small { color: #6a4a28; }

@keyframes rise {
  from { transform: translateY(70px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

dialog { background: #140f0b; color: #f6efe2; border: 1px solid #6a5030; border-radius: 12px; max-width: 560px; }
dialog h2 { margin-top: 0; }

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; }
  .felt { grid-template-columns: 1fr; grid-template-rows: auto; min-height: 0; }
  .seat.wide:first-child, .center, .seat.side, .seat.wide:last-child { grid-column: 1; grid-row: auto; }
  #table { min-height: 0; }
  .card { width: 38px; height: 54px; }
}
