/* Gin Rummy — Playnesta original (MIT). Felt, cards, piles, buttons. */
:root {
  --pn-vh: 1vh;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  background: radial-gradient(circle at 50% 10%, #1c4a34, #0d2117 78%);
  color: #eaf6ee;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--pn-vh, 1vh) * 100);
  max-width: 620px;
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  gap: 8px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.brand small {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.65;
  margin-left: 6px;
  text-transform: lowercase;
}
.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.hud {
  font-size: 13px;
  opacity: 0.95;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 999px;
  padding: 4px 10px;
}
.hud b {
  color: #ffd166;
}
.table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: space-between;
}
.opponent {
  display: flex;
  align-items: center;
  gap: 10px;
}
.opponent .who {
  font-size: 14px;
  font-weight: 700;
  opacity: 0.9;
}
.badge {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 999px;
  padding: 3px 9px;
}
.piles {
  display: flex;
  gap: 26px;
  justify-content: center;
}
.pilebox {
  position: relative;
  width: 74px;
  height: 100px;
  cursor: pointer;
  touch-action: manipulation;
}
.pilebox .pile-label {
  position: absolute;
  left: 50%;
  bottom: -20px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #9fd3b6;
  white-space: nowrap;
}
.pilebox.disabled {
  opacity: 0.45;
  cursor: default;
}
.card {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
}
.card.back {
  background: repeating-linear-gradient(45deg, #2f5a44 0 5px, #27503b 5px 10px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  position: relative;
}
.card.back::after {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
}
.card.face {
  background: linear-gradient(160deg, #fdfdf7, #eceada);
  color: #1d2433;
  border: 1px solid #c9c6b4;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  font-size: 20px;
}
.card.face .rank {
  font-size: 22px;
  line-height: 1;
}
.card.face .suit {
  font-size: 18px;
  line-height: 1;
}
.card.face.red {
  color: #c0392b;
}
.hidden {
  display: none !important;
}
.msg {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  min-height: 22px;
}
.handinfo {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  min-height: 104px;
  padding-bottom: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.hand .card.face {
  width: 62px;
  height: 88px;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform 120ms ease-out;
}
.hand .card.face.melded {
  background: linear-gradient(160deg, #f0f8e8, #ddefd0);
  outline: 2px solid #7ec96f;
  outline-offset: -2px;
}
.hand .card.face.sel {
  transform: translateY(-14px);
  outline: 3px solid #ffd166;
  outline-offset: 0;
}
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid #4e9d6d;
  background: #1d3f2e;
  color: #eaf6ee;
  cursor: pointer;
}
.btn.primary {
  background: #ffd166;
  color: #3a2c05;
  border-color: #ffe7a8;
}
.btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 16, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.overlay.hidden {
  display: none;
}
.panel {
  background: #12291d;
  border: 1px solid #4e9d6d;
  border-radius: 16px;
  padding: 18px;
  max-width: 440px;
  width: 100%;
  max-height: 86vh;
  overflow: auto;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 20px;
}
.panel p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
}
.panel-wide {
  max-width: 540px;
}
.rules-list {
  margin: 0 0 14px;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.55;
}
.rules-list li {
  margin-bottom: 8px;
}
.rules-list b {
  color: #ffd166;
}
@media (max-width: 480px) {
  .hand .card.face {
    width: 52px;
    height: 76px;
  }
  .card.face .rank {
    font-size: 18px;
  }
}
