/* Phone "hand" screen. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 50% 0%, var(--felt-light), var(--felt) 50%, var(--felt-dark));
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; }
#app { height: 100%; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
button { font-family: inherit; }
.btn {
  border: 0; border-radius: 14px; padding: 14px 18px;
  font-size: 17px; font-weight: 700;
  background: rgba(255, 255, 255, 0.14); color: var(--ink);
  min-height: 52px;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--gold); color: var(--felt-dark); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); color: #231a00; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.35; }
.btn .suit-red { color: var(--red); }
.btn.suit { background: var(--card-face); color: var(--black); }

/* Join */
.join { margin: auto 0; display: flex; flex-direction: column; gap: 14px; }
.join .logo { font-size: 40px; font-weight: 800; text-align: center; line-height: 1; }
.join .logo span { color: var(--gold); }
.join p { text-align: center; color: var(--muted); margin: 0 0 10px; }
.field label { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 14px 16px; border-radius: 14px; border: 2px solid transparent;
  background: rgba(0, 0, 0, 0.3); color: var(--ink); font-size: 20px; font-family: inherit; font-weight: 600;
}
.field input:focus { outline: none; border-color: var(--gold); }
.field input.code { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-size: 28px; }
.err { color: #ffb4b4; text-align: center; min-height: 20px; font-weight: 600; }

/* Header */
.header { display: flex; align-items: center; gap: 10px; padding: 12px 0 8px; }
.header .me { font-weight: 700; font-size: 17px; }
.header .room { color: var(--muted); font-size: 13px; }
.header .menu-btn { margin-left: auto; background: rgba(255,255,255,0.12); border: 0; color: var(--ink); width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }
.info { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: rgba(0, 0, 0, 0.28); border-radius: 12px; padding: 6px 10px; display: flex; flex-direction: column; min-width: 64px; }
.chip .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.chip .v { font-size: 18px; font-weight: 800; }

/* Lobby */
.lobby { flex: 1; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding-bottom: 16px; }
.lobby h2 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--muted); }
.big-msg { text-align: center; font-size: 22px; font-weight: 700; padding: 20px 0 0; }
.big-msg small { display: block; color: var(--muted); font-size: 15px; font-weight: 400; margin-top: 6px; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.prow { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.22); border-radius: 12px; padding: 8px 10px; font-weight: 600; }
.prow .x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--gold); color: var(--felt-dark); flex: none; }
.avatar.bot { background: #9fb3c8; }
.glist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gbtn { text-align: left; background: rgba(0,0,0,0.22); border: 2px solid transparent; border-radius: 14px; padding: 10px 12px; color: var(--ink); }
.gbtn.sel { border-color: var(--gold); background: rgba(245,196,81,0.14); }
.gbtn.soon { opacity: 0.4; }
.gbtn .e { font-size: 22px; }
.gbtn .n { font-weight: 700; font-size: 15px; }
.gbtn .c { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

/* Game */
.game { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.prompt { font-size: 20px; font-weight: 700; text-align: center; padding: 12px 4px 4px; min-height: 52px; }
.prompt.turn { color: var(--gold); }
.showcase { display: flex; justify-content: center; gap: 8px; padding: 4px; }
.showcase .card { --cw: 54px; }
.showcase .lbl { align-self: center; color: var(--muted); font-size: 13px; }
.hand-wrap { flex: 1; position: relative; min-height: 170px; display: flex; align-items: flex-end; }
.hand { position: relative; width: 100%; height: 100%; }
.hand .card { position: absolute; bottom: 12px; cursor: pointer; }
.hand .card.sel { transform: translateY(-34px); box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(0,0,0,0.45); }
.hand .card.off { filter: brightness(0.55) saturate(0.6); }
.hand .card.new::after { content: 'NEW'; position: absolute; top: 4px; right: 4px; background: var(--gold); color: var(--felt-dark); font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 6px; }
.hand-empty { margin: auto; color: var(--muted); }
.actions { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 14px; }
.actions .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.actions .movelist { display: flex; flex-direction: column; gap: 6px; max-height: 38vh; overflow-y: auto; }
.actions .movelist .btn { text-align: left; min-height: 46px; font-size: 16px; }
.raise { display: flex; flex-direction: column; gap: 8px; background: rgba(0,0,0,0.22); border-radius: 14px; padding: 10px; }
.raise .top { display: flex; align-items: center; gap: 10px; }
.raise input[type=range] { flex: 1; accent-color: var(--gold); height: 32px; }
.raise .amt { font-size: 22px; font-weight: 800; min-width: 70px; text-align: right; }
.board-mini { display: flex; gap: 4px; justify-content: center; }
.board-mini .card { --cw: 40px; }

/* Menu sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; display: flex; align-items: flex-end; }
.sheet { background: var(--felt-dark); width: 100%; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; max-height: 80vh; overflow-y: auto; }
.sheet h3 { margin: 0 0 4px; }

#toast {
  position: fixed; left: 50%; top: 16px; transform: translate(-50%, -150%);
  background: #fff; color: #222; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: 15px;
  transition: transform 0.25s ease; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { transform: translate(-50%, 0); }

@media (orientation: landscape) and (max-height: 500px) {
  .prompt { font-size: 17px; min-height: 0; padding: 4px; }
  .hand-wrap { min-height: 140px; }
  .actions .grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
}
.melds { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 6px 0; align-items: center; }
.melds .lbl { color: var(--muted); font-size: 13px; }
.meld { background: rgba(0,0,0,0.28); border-radius: 99px; padding: 4px 10px; font-size: 14px; font-weight: 600; }
.meld small { color: var(--muted); margin-left: 3px; }
.meld.natural { background: var(--red); color: #fff; }
.meld.mixed { background: #1d1f24; color: var(--gold); }
