/* ══════════════════════════════════════════════════════════
   Daifugo — Casino Green theme
   ══════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Microsoft JhengHei', 'Inter', sans-serif;
  background: radial-gradient(ellipse at center, #0d5a2e 0%, #053818 100%);
  color: #fff;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Views ── */
.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.view.active { display: flex; }

/* ══════════ Lobby / Waiting ══════════ */
#view-lobby, #view-waiting {
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lobby-box {
  background: rgba(0, 0, 0, 0.45);
  padding: 32px 28px;
  border-radius: 16px;
  border: 1px solid rgba(255, 215, 0, 0.35);
  text-align: center;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lobby-box h1 {
  font-size: 32px;
  color: #FFD700;
  margin-bottom: 6px;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}
.subtitle {
  color: #aaa;
  font-size: 13px;
  margin-bottom: 24px;
  letter-spacing: 1px;
}
.lobby-box input[type=text] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #444;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  margin-bottom: 12px;
  outline: none;
}
.lobby-box input[type=text]:focus {
  border-color: #FFD700;
  background: rgba(255, 255, 255, 0.12);
}

.primary-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  background: linear-gradient(180deg, #ff9800, #f57c00);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 1px;
  transition: filter 0.15s, transform 0.1s;
}
.primary-btn:hover:not(:disabled) { filter: brightness(1.1); }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }
.primary-btn:disabled {
  background: #555;
  cursor: not-allowed;
  opacity: 0.7;
}

.secondary-btn {
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid #555;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 12px;
  transition: background 0.15s;
}
.secondary-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.secondary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.err { color: #f55; font-size: 13px; min-height: 18px; margin-top: 8px; }
.hint { color: #888; font-size: 12px; margin-top: 16px; }

.counter { font-size: 14px; color: #ddd; margin-bottom: 12px; }
.counter strong { color: #FFD700; font-size: 18px; }
.player-list { margin-bottom: 16px; max-height: 240px; overflow-y: auto; }
.prow {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 14px;
  text-align: left;
}
.pnum { color: #888; margin-right: 8px; }
.htag {
  background: #FFD700;
  color: #000;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  font-weight: 700;
}

.pn-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0;
  justify-content: center;
}
.pn-label { font-size: 13px; color: #aaa; }
.pn-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid #555;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.pn-btn.sel {
  background: #FFD700;
  color: #000;
  border-color: #FFD700;
}

/* ── Password control (host only, in waiting view) ── */
.pwd-control {
  margin: 14px 0 12px;
  padding: 12px;
  background: rgba(255, 215, 0, 0.06);
  border: 1px dashed rgba(255, 215, 0, 0.35);
  border-radius: 8px;
  text-align: left;
}
.pwd-label {
  display: block;
  font-size: 13px;
  color: #FFD700;
  margin-bottom: 6px;
  font-weight: 600;
}
.pwd-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.pwd-input-row input {
  flex: 1;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #555;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.pwd-input-row input:focus {
  border-color: #FFD700;
}
.mini-btn {
  padding: 8px 14px;
  background: linear-gradient(180deg, #ff9800, #f57c00);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.mini-btn:hover { filter: brightness(1.1); }
.pwd-display {
  font-size: 12px;
}
.pwd-show {
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  border-left: 3px solid #FFD700;
}
.pwd-show strong {
  color: #FFD700;
  font-size: 15px;
  letter-spacing: 1px;
}
.pwd-hint {
  font-size: 11px;
  color: #aaa;
  margin-top: 6px;
  word-break: break-all;
  line-height: 1.5;
}
.copy-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px;
  font-size: 12px;
}

/* ── Floating mute button ── */
.mute-btn {
  position: fixed;
  top: 8px;
  right: 8px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 215, 0, 0.4);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 200;
  transition: transform 0.15s, background 0.15s;
}
.mute-btn:hover {
  background: rgba(0, 0, 0, 0.85);
  transform: scale(1.08);
}
.mute-btn:active { transform: scale(0.95); }

/* ══════════ Game ══════════ */
#view-game { flex-direction: column; }

.top-bar {
  height: 38px;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 13px;
  color: #ddd;
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  z-index: 10;
}
.round-num { color: #FFD700; font-weight: 600; }
.rev-badge {
  background: linear-gradient(180deg, #cc44ff, #8800cc);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}
.chat-btn {
  background: none;
  border: 1px solid #666;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
}
.chat-btn:hover { background: rgba(255, 255, 255, 0.1); }

.game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Seats */
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
}
.seat-inner { width: 96px; }
.avatar {
  width: 52px;
  height: 52px;
  background: #1a1a1a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #555;
  margin: 0 auto 4px;
  font-size: 24px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.avatar.cur {
  border-color: #FFD700;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.8);
  animation: pulse 1.4s ease-in-out infinite;
}
.avatar.dc { opacity: 0.4; filter: grayscale(1); }
.avatar.done { opacity: 0.65; border-color: #4f4; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
  50%      { box-shadow: 0 0 22px rgba(255, 215, 0, 1); }
}
.s-name {
  font-size: 12px;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 96px;
}
.s-rn { font-size: 10px; min-height: 14px; margin-top: 2px; }
.s-cnt {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.rank-tag {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  font-size: 10px;
  color: #FFD700;
}

/* Table */
.table-zone {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
.table-cards {
  min-height: 80px;
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.table-info {
  font-size: 13px;
  color: #FFD700;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 14px;
  border-radius: 12px;
  display: inline-block;
}

/* My zone (bottom) */
.my-zone {
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 12px 10px;
  border-top: 1px solid rgba(255, 215, 0, 0.3);
  z-index: 20;
}
.me-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 13px;
  flex-wrap: wrap;
}
.me-info span:first-child {
  color: #FFD700;
  font-weight: 600;
}
#me-count { color: #aaa; margin-left: auto; font-size: 12px; }
.status {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  min-height: 24px;
}
.status.myturn {
  color: #FFD700;
  font-weight: 600;
  background: rgba(255, 215, 0, 0.18);
}
.status.wait { color: #999; }

.timer-wrap {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 8px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  background: #4f4;
  width: 100%;
  transition: width 0.25s linear;
}

.my-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 8px;
  max-height: 140px;
  overflow-y: auto;
  padding: 4px 0;
}

/* Cards */
.card {
  width: 46px;
  height: 66px;
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.1;
  text-align: center;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}
.card.sm {
  width: 38px;
  height: 54px;
  font-size: 12px;
  cursor: default;
}
.card.red { color: #e22; }
.card.blk { color: #111; }
.card.joker {
  background: linear-gradient(135deg, #ffd54f, #ff9800);
  color: #1a1a1a;
}
.card .cv { line-height: 1.2; }
.card.sel {
  border-color: #FFD700;
  transform: translateY(-8px);
  box-shadow: 0 6px 14px rgba(255, 215, 0, 0.5);
}
.card:hover:not(.sm) {
  border-color: rgba(255, 215, 0, 0.5);
}

.action-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.action-bar button {
  flex: 1;
  max-width: 160px;
  padding: 11px;
}

/* Chat */
.chat-panel {
  position: fixed;
  right: -300px;
  top: 38px;
  bottom: 0;
  width: 280px;
  background: rgba(0, 0, 0, 0.9);
  border-left: 1px solid rgba(255, 215, 0, 0.3);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.chat-panel.open { right: 0; }
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-size: 13px;
}
.cmsg { margin-bottom: 4px; word-break: break-word; }
.cs { color: #FFD700; font-weight: 600; margin-right: 4px; }
.chat-input {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid rgba(255, 215, 0, 0.2);
}
.chat-input input {
  flex: 1;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  outline: none;
}
.chat-input button {
  padding: 6px 14px;
  background: #ff9800;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal.show { display: flex; }
.modal-inner {
  background: linear-gradient(180deg, #2a1500, #1a0a00);
  border: 2px solid #FFD700;
  padding: 28px 32px;
  border-radius: 16px;
  max-width: 90%;
  width: 360px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(255, 215, 0, 0.3);
}
.modal-inner h2 {
  color: #FFD700;
  margin-bottom: 16px;
  letter-spacing: 2px;
}
.frow {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 15px;
  text-align: left;
}
.frow strong { color: #FFD700; }
#btn-next-round { margin-top: 16px; }

/* ══════════ Toast notifications ══════════ */
.toast-container {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  width: 340px;
  max-width: 90%;
}
.toast {
  background: rgba(30, 0, 60, 0.96);
  color: #fff;
  padding: 14px 20px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 14px;
  text-align: center;
  border: 1px solid rgba(255, 215, 0, 0.4);
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.4s, transform 0.4s;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7);
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast small { display: block; color: #aaa; font-size: 11px; margin-top: 4px; }

.toast-jback {
  border-color: #cc44ff;
  background: linear-gradient(135deg, rgba(80, 0, 100, 0.97), rgba(40, 0, 70, 0.97));
}
.toast-swap {
  border-color: #00ddff;
  background: linear-gradient(135deg, rgba(0, 60, 90, 0.97), rgba(0, 30, 60, 0.97));
}
.toast-draw {
  border-color: #ff9800;
  background: linear-gradient(135deg, rgba(90, 40, 0, 0.97), rgba(50, 20, 0, 0.97));
}
.toast-nuke {
  border-color: #ff3030;
  background: linear-gradient(135deg, rgba(120, 0, 0, 0.98), rgba(60, 0, 0, 0.98));
  font-size: 16px;
  font-weight: 700;
  animation: shake 0.55s;
}
.toast-info {
  border-color: rgba(255, 215, 0, 0.5);
}
.toast-cut8 {
  border-color: #00ddff;
  background: linear-gradient(135deg, rgba(0, 70, 100, 0.97), rgba(0, 40, 70, 0.97));
}
.toast-queen {
  border-color: #ff66cc;
  background: linear-gradient(135deg, rgba(100, 0, 70, 0.97), rgba(60, 0, 50, 0.97));
}
.toast-spade3 {
  border-color: #888;
  background: linear-gradient(135deg, rgba(40, 40, 40, 0.97), rgba(20, 20, 20, 0.97));
  color: #fff;
}
.toast-tornado {
  border-color: #4488ff;
  background: linear-gradient(135deg, rgba(0, 50, 120, 0.97), rgba(0, 30, 80, 0.97));
}
.toast-revolution {
  border-color: #ff3030;
  background: linear-gradient(135deg, rgba(140, 0, 0, 0.98), rgba(80, 0, 0, 0.98));
  font-size: 16px;
  font-weight: 700;
  animation: shake 0.55s;
}

/* Suit lock badge in top bar */
.suit-lock-badge {
  background: linear-gradient(180deg, #4488ff, #2266cc);
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-left: 4px;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

/* ══════════ Responsive ══════════ */
@media (max-width: 500px) {
  .card { width: 38px; height: 56px; font-size: 12px; }
  .card.sm { width: 32px; height: 46px; font-size: 11px; }
  .seat-inner { width: 76px; }
  .avatar { width: 44px; height: 44px; font-size: 20px; }
  .s-name { font-size: 11px; max-width: 76px; }
  .table-cards { min-height: 60px; }
  .my-hand { max-height: 110px; }
  .lobby-box { padding: 24px 20px; }
  .lobby-box h1 { font-size: 26px; }
}
