/* Whot table. Plain CSS, no frameworks. */

:root {
  --cw: 84px;
  --ch: 120px;
  --felt-1: #135e38;
  --felt-2: #07351f;
  --felt-3: #042416;
  --card-bg: #fafafa;
  --card-ink: #18181b;
  --accent: #fbbf24;
  --your-turn: #34d399;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: #f4f4f5;
  background:
    radial-gradient(1100px 700px at 50% 18%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 8px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #1c1917;
  font-weight: 700;
}

.brand-name { font-weight: 700; letter-spacing: .06em; }
.brand-sub { font-size: 12px; color: rgba(244, 244, 245, .55); }

.scores { display: flex; gap: 8px; }

.score {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .1);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
}
.score span { color: rgba(244, 244, 245, .6); }
.score b { font-size: 14px; }

.top-actions { display: flex; gap: 8px; }

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #1c1917;
  background: var(--accent);
  border: 0;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: rgba(0, 0, 0, .3);
  color: #f4f4f5;
  border: 1px solid rgba(255, 255, 255, .16);
}
.btn.wide { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- start.ng footer ---------- */

.ng-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 14px;
  padding: 2px 12px 0;
  font-size: 12px;
  color: rgba(244, 244, 245, .66);
}

.ng-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  margin: -12px 0 -10px;
  color: var(--accent);
  text-decoration: none;
}

.ng-link:hover,
.ng-link:focus-visible { text-decoration: underline; }

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

.table {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0 6px;
}

.foe { text-align: center; }

.foe-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: rgba(244, 244, 245, .75);
  margin-bottom: 8px;
}

.count {
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
}

.think { display: inline-flex; gap: 3px; }
.think i {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(244, 244, 245, .7);
  animation: blink 1s infinite alternate;
}
.think i:nth-child(2) { animation-delay: .2s; }
.think i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { from { opacity: .25; } to { opacity: 1; } }

.foe-hand {
  display: flex;
  justify-content: center;
  padding-left: 18px;
  max-width: 100%;
  overflow: hidden;
}
.foe-hand .card + .card { margin-left: -34px; }

/* middle row */

.mid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
}

.center-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 130px;
  order: -1;
  flex-basis: 100%;
}

.pill {
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .14);
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 13px;
}
.pill.turn-your { border-color: rgba(52, 211, 153, .6); color: var(--your-turn); font-weight: 500; }
.pill.turn-foe { border-color: rgba(251, 191, 36, .55); color: var(--accent); font-weight: 500; }
.pill.call { text-transform: capitalize; }

.pile {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: 11px;
  border: 0;
  padding: 0;
  background: transparent;
}

.pile.market { cursor: pointer; }
.pile.market:disabled { cursor: default; }

.pile-face {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background:
    repeating-linear-gradient(45deg, #1e3a8a 0 7px, #172f6e 7px 14px);
  border: 3px solid #e4e4e7;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, .3), 7px 9px 0 rgba(0, 0, 0, .16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #dbeafe;
}

.pile.market:hover .pile-face { filter: brightness(1.12); }
.pile.market:disabled .pile-face { filter: none; opacity: .85; }

.market-count { font-weight: 700; font-size: 17px; }
.pile-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }

.pile.discard {
  box-shadow: 4px 5px 0 rgba(0, 0, 0, .3);
  filter: drop-shadow(0 0 0 transparent);
}
.pile.discard:empty::before {
  content: '?';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255, 255, 255, .35);
  border-radius: 11px;
  color: rgba(255, 255, 255, .45);
  font-size: 30px;
}

/* log */

.log {
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 13px;
  text-align: center;
  color: rgba(244, 244, 245, .8);
}
.log div:nth-child(1) { opacity: 1; }
.log div:nth-child(2) { opacity: .6; }
.log div:nth-child(3) { opacity: .32; }
.log div { max-width: 100%; padding: 0 10px; }

/* ---------- hand ---------- */

.mine { display: flex; flex-direction: column; gap: 10px; }

.prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(251, 191, 36, .13);
  border: 1px solid rgba(251, 191, 36, .55);
  color: #fde68a;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  text-align: center;
}
.prompt .btn { padding: 6px 13px; }

.my-hand {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 4px 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  justify-content: flex-start;
  justify-content: safe center;
  min-height: calc(var(--ch) + 24px);
}
.my-hand::-webkit-scrollbar { display: none; }
.my-hand.centered { justify-content: center; }

/* ---------- cards ---------- */

.card {
  position: relative;
  flex: 0 0 auto;
  width: var(--cw);
  height: var(--ch);
  border-radius: 11px;
  background: var(--card-bg);
  color: var(--card-ink);
  border: 0;
  padding: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
  font-family: inherit;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.card .corner {
  position: absolute;
  top: 5px;
  left: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  gap: 2px;
}
.card .corner .mini { width: 11px; height: 11px; }

.card .glyph {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52%;
  height: 52%;
  transform: translate(-50%, -50%);
}

.card .tag {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  background: #18181b;
  color: #fafafa;
}
.card .tag.hot { background: #b91c1c; color: #fee2e2; }
.card .tag.gold { background: #b45309; color: #fef3c7; }
.card .tag.call { background: #1d4ed8; color: #dbeafe; }

.card.suit-circles .glyph, .card.suit-circles .mini { color: #dc2626; }
.card.suit-triangles .glyph, .card.suit-triangles .mini { color: #2563eb; }
.card.suit-crosses .glyph, .card.suit-crosses .mini { color: #16a34a; }
.card.suit-squares .glyph, .card.suit-squares .mini { color: #9333ea; }
.card.suit-stars .glyph, .card.suit-stars .mini { color: #d97706; }
.card.suit-whot { background: #111827; color: #f9fafb; }
.card.suit-whot .glyph { color: var(--accent); width: 70%; height: auto; }
.card.suit-whot .corner { color: var(--accent); }

button.card.legal {
  cursor: pointer;
  transition: transform .13s ease, box-shadow .13s ease;
  outline: 2px solid rgba(52, 211, 153, 0);
}
button.card.legal:hover {
  transform: translateY(-10px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, .45);
  outline-color: rgba(52, 211, 153, .85);
}
button.card.legal:active { transform: translateY(-4px); }

button.card.illegal {
  opacity: .38;
  filter: grayscale(.5);
  cursor: default;
}

.card.back {
  background: repeating-linear-gradient(45deg, #1e3a8a 0 8px, #172f6e 8px 16px);
  border: 3px solid #e4e4e7;
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 20, 12, .72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
}

.panel {
  background: #0b2c1d;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  padding: 22px;
  width: min(430px, 100%);
  max-height: 86dvh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.panel h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: rgba(244, 244, 245, .6); font-size: 14px; margin: 0; }

.suit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.suit-btn {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 13px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #f4f4f5;
  cursor: pointer;
  font-size: 13px;
  text-transform: capitalize;
  transition: background .12s ease, transform .12s ease;
}
.suit-btn:hover { background: rgba(255, 255, 255, .13); transform: translateY(-2px); }
.suit-btn svg { width: 34px; height: 34px; }

.round-scores {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.round-scores div {
  flex: 1;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.round-scores b { display: block; font-size: 24px; margin-top: 3px; }
.round-scores .win { border-color: rgba(52, 211, 153, .6); }

.rules-body { font-size: 14px; line-height: 1.55; color: rgba(244, 244, 245, .82); }
.rules-body ul { padding-left: 18px; }
.rules-body li { margin-bottom: 4px; }
.rules-body p { margin: 10px 0; }

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #7f1d1d;
  color: #fee2e2;
  border: 1px solid #ef4444;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  max-width: calc(100vw - 28px);
  text-align: center;
}

.hidden { display: none !important; }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  :root { --cw: 64px; --ch: 92px; }
  .brand-sub { display: none; }
  .mid { gap: 16px; }
  .foe-hand .card + .card { margin-left: -30px; }
  .card .corner { font-size: 11px; top: 4px; left: 5px; }
  .card .tag { font-size: 7px; padding: 2px 5px; }
  .topbar { justify-content: center; gap: 8px; row-gap: 8px; }
  .table { gap: 10px; padding-top: 12px; }
  .log { font-size: 12px; min-height: 38px; }
  .panel { padding: 18px; }
  .suit-grid { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); }
}

/* small phones: iPhone SE, compact Androids */
@media (max-width: 380px) {
  :root { --cw: 56px; --ch: 82px; }
  .brand-name { display: none; }
  .score { padding: 4px 9px; gap: 5px; font-size: 12px; }
  .score b { font-size: 13px; }
  .btn { padding: 7px 11px; font-size: 12px; }
  .top-actions { gap: 6px; }
  .mid { gap: 13px; }
  .foe-hand .card + .card { margin-left: -28px; }
  .my-hand { gap: 6px; }
  .prompt { font-size: 13px; padding: 8px 10px; gap: 8px; }
  .wait-code { font-size: 25px; letter-spacing: .2em; padding: 12px 6px 12px 18px; }
  .join-row input { letter-spacing: .12em; }
  .round-scores b { font-size: 20px; }
  .panel h2 { font-size: 18px; }
  .rules-body { font-size: 13px; }
}

/* short landscape: phone sideways, half-height windows */
@media (max-height: 540px) and (orientation: landscape) {
  :root { --cw: 60px; --ch: 86px; }
  .app { padding-top: 8px; padding-bottom: 8px; }
  .table { gap: 6px; padding: 8px 0 4px; }
  .foe-info { margin-bottom: 4px; font-size: 13px; }
  .center-info {
    flex-direction: row;
    flex-basis: auto;
    order: -1;
    gap: 10px;
    min-width: 0;
  }
  .mid { gap: 20px; }
  .log { min-height: 18px; font-size: 12px; }
  .log div:nth-child(n+2) { display: none; }
  .mine { gap: 4px; }
  .my-hand { padding-top: 6px; min-height: calc(var(--ch) + 12px); }
  .prompt { padding: 6px 12px; font-size: 13px; }
  .brand-sub { display: none; }
  .panel { max-height: 92dvh; }
}

/* roomy desktop */
@media (min-width: 900px) {
  :root { --cw: 92px; --ch: 132px; }
  .foe-hand .card + .card { margin-left: -36px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- online lobby ---------- */

.field { margin: 12px 0; }

.field input,
.join-row input {
  font: inherit;
  width: 100%;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .18);
  color: #f4f4f5;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
}
.field input::placeholder,
.join-row input::placeholder { color: rgba(244, 244, 245, .4); }
.field input:focus,
.join-row input:focus { border-color: rgba(251, 191, 36, .7); }

.join-row { display: flex; gap: 8px; margin-top: 14px; margin-bottom: 10px; }
.join-row input {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 700;
}
.join-row .btn { flex: 0 0 auto; }

.center { text-align: center; margin-top: 10px; min-height: 18px; }
#lobbyMsg { color: #fde68a; }

.waiting { text-align: center; padding-top: 4px; }
.wait-code {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: .3em;
  background: rgba(0, 0, 0, .35);
  border: 1px dashed rgba(251, 191, 36, .65);
  color: var(--accent);
  border-radius: 12px;
  padding: 14px 8px 14px 22px;
  margin: 14px 0 12px;
  user-select: all;
  -webkit-user-select: all;
}

.pill.room {
  border-color: rgba(251, 191, 36, .55);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: .1em;
}

.pill.rules-pill {
  border-color: rgba(251, 191, 36, .55);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 11px;
}

/* ---------- table setup ---------- */

.setup-label {
  margin: 18px 0 8px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(244, 244, 245, .55);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .14);
}

.seg {
  font: inherit;
  font-size: 13px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(244, 244, 245, .72);
  cursor: pointer;
}

.seg.is-on {
  background: var(--accent);
  color: #1c1917;
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  font: inherit;
  font-size: 12.5px;
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .07);
  color: #f4f4f5;
  cursor: pointer;
}

.chip:hover,
.chip:focus-visible,
.seg:focus-visible {
  border-color: rgba(251, 191, 36, .7);
  outline: none;
}

.chip.off {
  opacity: .45;
  text-decoration: line-through;
  background: rgba(0, 0, 0, .3);
}

.setup-note {
  margin: 7px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(244, 244, 245, .5);
}
