:root {
  --paper: #fbf6ec;
  --ink: #241f1a;
  --ink-soft: #6b6157;
  --vermilion: #c23a22;
  --vermilion-soft: #d9612f;
  --jade: #1f7a4a;
  --card: #fffdf7;
  --line: #e3d6b4;
  --tile-w: 36px;
  --tile-h: 50.4px;
  --tile-w-sm: 24px;
  --tile-h-sm: 33.6px;
}

@media (max-width: 560px) {
  :root {
    --tile-w: clamp(23px, 6.2vw, 30px);
    --tile-h: calc(var(--tile-w) * 1.4);
    --tile-w-sm: clamp(15px, 4.2vw, 20px);
    --tile-h-sm: calc(var(--tile-w-sm) * 1.4);
  }
}

@media (max-width: 440px) {
  :root {
    /* Exact formula for 19.5:9 mobile phone screens (Poco F7, iPhone, Galaxy, Pixel) */
    --tile-w: calc((100vw - 36px) / 14.8);
    --tile-h: calc(var(--tile-w) * 1.4);
    --tile-w-sm: clamp(13.5px, 3.8vw, 17px);
    --tile-h-sm: calc(var(--tile-w-sm) * 1.4);
  }
}

* { box-sizing: border-box; }

/* Author `display` rules (`.table`, `.claim-bar`) would otherwise override the
   UA `[hidden] { display: none }`, leaving empty bordered boxes on screen. */
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  min-height: 100dvh;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hanken Grotesk", "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

button, input, select, .tile.pick, .mode-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 16px;
}

.brand { font-weight: 800; font-size: 18px; }
.brand-accent { color: var(--vermilion); font-style: italic; }

.conn { font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.conn .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #b9aca0; display: inline-block;
}
.conn.on .dot { background: var(--jade); }

h1 { font-size: 24px; margin: 8px 0 2px; }
.sub { color: var(--ink-soft); margin: 0 0 18px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-head { display: flex; flex-direction: column; }
.card-head b { font-size: 15px; }
.card-head span { color: var(--ink-soft); font-size: 13px; }

.create-row, .join-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.create-row input { flex: 1 1 140px; }

input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  background: #fff;
  color: inherit;
  min-width: 0;
}
input:focus { outline: 2px solid var(--vermilion-soft); outline-offset: 1px; }

#join-code { flex: 1 1 120px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; padding: 8px 12px; font: inherit;
  font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.seg button.on { background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------- REA Game Mode Feature */

.mode-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mode-pick {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .mode-pick {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  position: relative;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  font: inherit;
  color: var(--ink);
}

.mode-card:hover {
  border-color: #c9bda4;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.mode-card.on {
  border: 2px solid var(--vermilion);
  background: #fffbf9;
  box-shadow: 0 2px 8px rgba(194, 58, 34, 0.12);
}

.mode-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 10px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
  font-family: "Noto Serif SC", serif;
  background: #eae2d3;
  color: #5a4a3e;
  transition: all 0.15s ease;
}

.mode-card.on .mode-badge {
  background: var(--vermilion);
  color: #fff;
}

.mode-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
  border: 1.5px solid #d4c8b2;
  color: transparent;
  background: transparent;
  transition: all 0.15s ease;
}

.mode-card.on .mode-check {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
}

.mode-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--ink);
}

.mode-desc {
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* Hong Kong mode sub-rules panel */
.hk-rules-panel {
  background: #fbf7ef;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.setting-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-text b {
  font-size: 13px;
  font-weight: 700;
}

.setting-text small {
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.3;
}

.select-chip select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.select-chip select:focus {
  border-color: var(--vermilion);
  outline: 2px solid rgba(194, 58, 34, 0.2);
}

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #fff;
}
.btn.primary:disabled { opacity: 0.6; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.small { padding: 6px 10px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover:not(:disabled) { filter: brightness(0.97); }

.error { color: var(--vermilion); font-size: 13px; margin: 0; }

/* ------------------------------------------------------- admin announcements */

#system-announcements {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  width: min(620px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.announce {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(36, 31, 26, 0.22);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.announce-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
}

.announce-info { border-color: #9ec5e8; }
.announce-info .announce-badge { background: #1d4ed8; color: #fff; }

.announce-warning { border-color: #d9a521; background: #fff8e6; }
.announce-warning .announce-badge { background: #b45309; color: #fff; }

.announce-emergency { border-color: var(--vermilion); background: #fdeceb; }
.announce-emergency .announce-badge { background: var(--vermilion); color: #fff; }

.announce-text { flex: 1; min-width: 0; }

.announce-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 2px 4px;
  border-radius: 6px;
}

.announce-close:hover { background: rgba(0, 0, 0, 0.06); }

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 2px 8px;
}
.kicker {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.room-list { display: flex; flex-direction: column; gap: 8px; }

.room-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.room-row.full { opacity: 0.55; cursor: default; }
.room-row:not(.full):hover { border-color: var(--vermilion-soft); }

.avatar {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--vermilion-soft);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.info b { font-size: 15px; }
.info small { color: var(--ink-soft); font-size: 12.5px; }

.badge-new {
  margin-left: 6px;
  background: var(--jade);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 5px;
  vertical-align: 1px;
  letter-spacing: 0.05em;
}

.join { color: var(--vermilion); font-weight: 800; font-size: 14px; }
.locked { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); font-weight: 700; font-size: 13px; }

.empty {
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 14px;
  font-size: 14px;
}

#refresh-icon.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* room shell */
.room-code {
  font-weight: 800;
  letter-spacing: 3px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
}
.seat-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.seat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
}
.seat-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.seat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.seat.empty {
  opacity: 0.85;
  border-style: dashed;
}
.seat.bot {
  border-color: rgba(90, 160, 240, 0.4);
  background: rgba(90, 160, 240, 0.04);
}
.seat-num { color: var(--ink-soft); font-size: 13px; }
.seat-name { font-weight: 700; }
.seat.away { opacity: 0.65; }
.seat-flag {
  background: var(--ink-soft);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 6px;
  padding: 1px 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.btn-add-bot {
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--brand, #0070f3) !important;
  background: rgba(0, 112, 243, 0.08) !important;
  border: 1px solid rgba(0, 112, 243, 0.25) !important;
  border-radius: 8px !important;
  padding: 4px 10px !important;
  cursor: pointer;
}
.btn-add-bot:hover {
  background: rgba(0, 112, 243, 0.18) !important;
}
.btn-remove-bot {
  font-size: 13px !important;
  color: var(--ink-soft) !important;
  padding: 2px 7px !important;
  cursor: pointer;
}
.btn-remove-bot:hover {
  color: #e53e3e !important;
}
.btn-replace-bot {
  font-size: 11px !important;
  font-weight: 600 !important;
  color: var(--brand, #0070f3) !important;
  background: rgba(0, 112, 243, 0.08) !important;
  border: 1px solid rgba(0, 112, 243, 0.25) !important;
  border-radius: 6px !important;
  padding: 2px 8px !important;
  cursor: pointer;
}
.btn-replace-bot:hover {
  background: rgba(0, 112, 243, 0.18) !important;
}
.hint { color: var(--ink-soft); font-size: 13px; margin-top: 14px; }

/* ---------------------------------------------------------------- the table */

.table {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
  position: relative;
}

.opponents {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

@media (max-width: 480px) {
  .opponents {
    gap: 6px;
  }
  .opponent {
    padding: 6px 8px;
    gap: 8px;
  }
}

.opponent {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* The seat on turn is the one thing a player needs to spot at a glance. */
.opponent.turn {
  border-color: var(--vermilion);
  box-shadow: 0 0 0 2px var(--vermilion-soft) inset, 0 2px 8px rgba(217, 97, 47, 0.12);
}
.opponent.away { opacity: 0.6; }

.opp-info {
  flex: 0 0 112px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
@media (max-width: 480px) {
  .opp-info {
    flex: 0 0 95px;
  }
}
.opp-head { display: flex; align-items: center; gap: 6px; }
.opp-head b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-head .wind {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  background: #f1e7d4;
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}
.opp-head .wind.dealer {
  background: var(--vermilion);
  color: #fff;
}
.opp-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-soft); }
.opp-meta .score { font-weight: 800; color: var(--ink); }

.opp-cards {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.opp-cards::-webkit-scrollbar {
  display: none;
}

.pool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.pool-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 3.5px;
  align-items: center;
}
.pool-empty {
  font-size: 12.5px;
  color: var(--ink-soft);
  opacity: 0.6;
  text-align: center;
  padding: 4px 0;
  user-select: none;
}

.tile-row { display: flex; flex-wrap: wrap; gap: 2.5px; align-items: center; }

/* Opponents revealed hand when the game is won */
.tile-row.revealed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2.5px;
  padding: 2px 0;
}
.tile-row.revealed .tile {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

/* Opponents deck: horizontal tiles in each row ("playerOne (deck kartu)") */
.tile-row.backs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 1.5px;
  flex-shrink: 0;
  padding: 2px 0;
}
.tile-row.backs::-webkit-scrollbar {
  display: none;
}
.tile-row.backs .tile {
  width: 11px;
  height: 15.4px;
  flex: 0 0 11px;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}
@media (min-width: 480px) {
  .tile-row.backs .tile {
    width: 12.5px;
    height: 17.5px;
    flex: 0 0 12.5px;
  }
}
@media (min-width: 580px) {
  .tile-row.backs .tile {
    width: 14px;
    height: 19.6px;
    flex: 0 0 14px;
  }
}
.tile-row.backs .tile .tile-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.tile-row.backs .tile.tile-drawn {
  margin-left: 6px;
}

.opp-cards .tile-row.melds {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.opp-cards .meld {
  padding: 1px 3px;
  gap: 1.5px;
  border-radius: 4px;
}
.opp-cards .meld .tile.small {
  width: 16px;
  height: 22.4px;
}

.meld {
  display: inline-flex;
  gap: 2px;
  padding: 2px 4px;
  border-radius: 6px;
  background: #f3ead6;
  border: 1px solid #e7dcbe;
  margin-right: 6px;
}

.mine {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.my-info { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-soft); }
.wind-badge {
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}
.wind-badge.dealer {
  background: var(--vermilion);
  color: #fff;
}
.my-score { font-weight: 800; color: var(--ink); }
.flower-count { font-size: 12.5px; }

/* The hand is the primary control surface: aligned and padded for elevation. */
.hand {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 2px;
  padding: 14px 2px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.hand::-webkit-scrollbar { display: none; }

/* ------------------------------------------------------------------- tiles */

.tile {
  width: var(--tile-w);
  height: var(--tile-h);
  display: inline-block;
  vertical-align: middle;
  position: relative;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  filter: drop-shadow(0 2px 2.5px rgba(0, 0, 0, 0.18));
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  flex: 0 0 auto;
}

.tile-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.tile.small {
  width: var(--tile-w-sm);
  height: var(--tile-h-sm);
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.15));
}

.tile.back {
  background: transparent;
  border: 0;
}

.tile.dim { opacity: 0.45; }

/* Highlight for the most recent discard across the table */
.tile.last-discard {
  filter: drop-shadow(0 0 5px rgba(194, 58, 34, 0.75)) drop-shadow(0 2px 2.5px rgba(0, 0, 0, 0.25));
  transform: translateY(-2px);
}

/* Newly drawn 14th tile separated by a gap */
.tile.tile-drawn {
  margin-left: 12px;
}

/* Interactive hand tiles: tap once to select, again to play, or drag to reorder. */
.tile.pick {
  cursor: grab;
  transition: transform 0.12s cubic-bezier(0.2, 0, 0.2, 1), filter 0.12s ease;
}
.tile.pick:active {
  cursor: grabbing;
}
.tile.pick:hover {
  transform: translateY(-4px);
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.24));
}
.tile.pick.selected {
  transform: translateY(-14px);
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.32)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.2));
  outline: none;
}
.tile.pick.dragging {
  opacity: 0.35;
  transform: scale(0.92) translateY(-4px);
}
.tile.pick.drag-over {
  transform: translateY(-10px) scale(1.06);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
  outline: 2px dashed rgba(27, 77, 54, 0.6);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- claim bar */

/* ---------------------------------------------------------------- claim bar / game acts */

/* Located directly above the player's hand, matching mahbar.my.id */
.game-acts {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 6px 0;
  margin: 2px 0 6px;
  animation: gameActsFadeIn 0.15s ease-out;
}

@keyframes gameActsFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.act-buttons-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ffffff;
  padding: 6px 14px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.act-buttons-wrap::-webkit-scrollbar {
  display: none;
}

.act-prompt-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-right: 4px;
  white-space: nowrap;
}

/* Base pill action button */
.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 13px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
  position: relative;
  outline: none;
  text-decoration: none;
}

.act-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.act-btn:active {
  transform: translateY(1px);
  filter: brightness(0.97);
}

.act-label {
  display: inline;
}

.act-sub {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 600;
}

/* 1. HU! button - golden/amber rounded button matching mahbar */
.act-btn.hu {
  background: #e5a720;
  color: #2b1f06;
  font-weight: 800;
  padding: 9px 20px;
  box-shadow: 0 2px 8px rgba(229, 167, 32, 0.35);
}
.act-btn.hu:hover {
  background: #efb025;
  box-shadow: 0 3px 12px rgba(229, 167, 32, 0.5);
}

/* 2. Kong button - crisp pearl/white rounded button with border */
.act-btn.kong {
  background: #ffffff;
  color: var(--ink);
  border: 1.5px solid #ded5c2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.act-btn.kong:hover {
  background: #fdfcfa;
  border-color: #cbbeaa;
}

/* 3. Pong button - vermilion red rounded button */
.act-btn.pong {
  background: #c23a22;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(194, 58, 34, 0.35);
}
.act-btn.pong:hover {
  background: #d4432a;
  box-shadow: 0 3px 12px rgba(194, 58, 34, 0.5);
}

/* 4. Chi button - jade green rounded button */
.act-btn.chi {
  background: #1f7a4a;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(31, 122, 74, 0.35);
}
.act-btn.chi:hover {
  background: #278f58;
  box-shadow: 0 3px 12px rgba(31, 122, 74, 0.5);
}

/* 5. Pass / Discard button - muted neutral rounded button */
.act-btn.pass {
  background: #ede6d8;
  color: #7d7265;
  font-weight: 600;
}
.act-btn.pass:hover {
  background: #e3dcce;
  color: #554d42;
}

/* 6. Discard button - prominent vermilion action button */
.act-btn.discard {
  background: #c23a22;
  color: #ffffff;
  font-weight: 800;
  padding: 8px 18px;
  box-shadow: 0 2px 8px rgba(194, 58, 34, 0.35);
  cursor: pointer;
}
.act-btn.discard:hover:not(:disabled) {
  background: #d4432a;
  box-shadow: 0 4px 14px rgba(194, 58, 34, 0.5);
  transform: translateY(-1px);
}
.act-btn.discard:active:not(:disabled) {
  transform: translateY(1px);
}
.act-btn.discard:disabled,
.act-btn.discard.disabled {
  background: #ede6d8;
  color: #9c9285;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

/* Timer badge sitting cleanly beside action buttons */
.act-timer {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--vermilion);
  background: #fff3ee;
  border: 1px solid rgba(194, 58, 34, 0.25);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

.foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.status { color: var(--ink-soft); font-size: 13px; }
.countdown { font-weight: 800; font-size: 13px; color: var(--vermilion); font-variant-numeric: tabular-nums; }

.selected-inspector {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.inspector-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #231f1d;
  color: #fff9f0;
  border: 1px solid rgba(217, 97, 47, 0.45);
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.inspector-badge b {
  color: #fbbf24;
}
.inspector-badge i {
  color: #38bdf8;
  font-style: normal;
  font-weight: 800;
}
.inspector-hint {
  color: var(--vermilion);
  font-weight: 800;
  font-size: 13px;
}
.wall-hint, .reorder-tip {
  color: var(--ink-soft);
  font-size: 12.5px;
}
.status-claim-prompt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--vermilion);
  font-weight: 700;
}
.claim-tile-glyph {
  font-size: 16px;
  font-weight: 900;
  color: #b45309;
}

/* ------------------------------------------------------------------ results */

.result { gap: 8px; }
.result-sub { color: var(--ink-soft); font-size: 13px; }
.fan-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.fan-list li { display: flex; justify-content: space-between; font-size: 13.5px; }
.fan-list b { color: var(--vermilion); }

.deltas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin-top: 6px;
}
.delta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.03);
  padding: 5px 8px;
  border-radius: 6px;
}
.delta.won {
  background: rgba(31, 107, 74, 0.08);
}
.delta.won .delta-pts {
  color: var(--jade);
  font-weight: 800;
}
.delta .player-name {
  font-weight: 600;
  max-width: 90px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.delta-pts {
  font-weight: 700;
  margin-left: auto;
}
.score-total {
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.score-total b {
  color: var(--ink);
  font-weight: 800;
}

.result-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}
.btn-next-game {
  width: 100%;
  max-width: 260px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
  background: linear-gradient(135deg, #25835b 0%, #175a3e 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(31, 107, 74, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-next-game:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(31, 107, 74, 0.45);
}
.btn-next-game:active {
  transform: translateY(0);
}
.btn-next-game:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

@keyframes pulse-btn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); box-shadow: 0 0 14px rgba(31, 107, 74, 0.6); }
}
.btn-next-game.pulse,
#btn-next.pulse {
  animation: pulse-btn 1.2s infinite ease-in-out;
}

/* -------------------------------------------------- 19.5:9 Mobile Phone Layout */
@media (max-width: 480px) {
  #app {
    padding: 6px 6px 14px;
    max-width: 100%;
  }

  .top {
    padding: 4px 2px 8px;
  }
  .brand {
    font-size: 17px;
  }

  h1 {
    font-size: 20px;
    margin: 4px 0 2px;
  }
  .sub {
    font-size: 12.5px;
    margin-bottom: 12px;
  }

  .card {
    padding: 11px 10px;
    gap: 8px;
    border-radius: 12px;
  }
  .card-head b {
    font-size: 14px;
  }
  .card-head span {
    font-size: 12px;
  }

  .mode-section {
    gap: 6px;
    margin-top: 2px;
  }
  .mode-pick {
    gap: 6px;
  }
  .mode-card {
    padding: 8px 8px;
    border-radius: 10px;
  }
  .mode-title {
    font-size: 13px;
  }
  .mode-desc {
    font-size: 11px;
    line-height: 1.35;
  }

  .create-row input,
  .join-row input {
    padding: 8px 10px;
    font-size: 13.5px;
  }
  #btn-create {
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 800;
  }

  /* Compact room header when in active game */
  #screen-room h1#room-title {
    font-size: 16px;
    margin: 2px 0;
  }
  #screen-room p.sub#room-sub {
    font-size: 11.5px;
    margin: 0 0 6px;
  }

  .table {
    gap: 8px;
    margin-top: 4px;
  }

  .opponents {
    gap: 4px;
  }
  .opponent {
    padding: 4px 6px;
    gap: 6px;
    border-radius: 10px;
  }
  .opp-info {
    flex: 0 0 76px;
    gap: 1px;
  }
  .opp-head b {
    font-size: 11px;
    max-width: 48px;
  }
  .opp-head .wind {
    font-size: 9.5px;
    padding: 0 3px;
    border-radius: 3px;
  }
  .opp-meta {
    font-size: 10px;
    gap: 4px;
  }
  .opp-cards {
    gap: 4px;
  }
  .tile-row.backs,
  .tile-row.revealed {
    gap: 1.5px;
  }

  .pool {
    padding: 7px 9px;
    min-height: 44px;
    max-height: 110px;
    overflow-y: auto;
    border-radius: 10px;
  }
  .pool-sequence {
    gap: 2px;
  }
  .pool-empty {
    font-size: 11.5px;
  }

  /* Player console pinned cleanly at bottom */
  .mine {
    padding: 7px 4px 8px;
    gap: 5px;
    border-radius: 12px;
  }
  .my-info {
    gap: 6px;
    font-size: 11.5px;
  }
  .wind-badge {
    padding: 1px 6px;
    font-size: 10.5px;
  }
  .my-score {
    font-size: 12px;
  }

  .hand {
    padding: 12px 0 2px;
    gap: 1px;
    justify-content: center;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .tile.tile-drawn {
    margin-left: clamp(4px, 1.4vw, 7px);
  }

  .game-acts {
    padding: 2px 0;
  }
  .act-buttons-wrap {
    gap: 4px;
    justify-content: center;
  }
  .act-prompt-text {
    width: 100%;
    text-align: center;
    font-size: 11.5px;
    margin-bottom: 2px;
  }
  .act-btn {
    padding: 6px 10px;
    font-size: 12px;
    min-height: 33px;
    border-radius: 8px;
    gap: 2px;
  }
  .act-btn.discard {
    min-width: 80px;
  }

  .foot {
    margin-top: 4px;
    font-size: 11.5px;
  }

  /* Result banner on mobile */
  .card.result {
    padding: 10px 10px;
    border-radius: 12px;
  }
  .deltas {
    grid-template-columns: 1fr;
    gap: 3.5px;
  }
  .delta {
    padding: 4px 6px;
    font-size: 11.5px;
  }
  .btn-next-game {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
  }
}


/* ------------------------------------------------------- optional login + friends */

.account {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.account-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(36, 31, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 60px rgba(36, 31, 26, 0.24);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.auth-tabs { display: inline-flex; gap: 6px; }
.auth-tabs .btn.on { background: var(--ink); color: var(--paper); }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-soft); font-size: 12.5px; margin: 0; }

.card.friends { margin-top: 12px; }
.friends-guest { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.friends-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.friends-controls input { flex: 1 1 160px; }
.friends-section { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.friend-row.invite { border-color: var(--vermilion-soft); background: #fff7f3; }
.friend-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.friend-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.friends-results { display: flex; flex-direction: column; gap: 6px; }
.btn.danger { color: var(--vermilion); }
