/* Spades — 파트너십 트릭테이킹. 폰 세로 한 손 기준. */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #0a0a0a; color: #f5f5f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
main {
  height: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px;
  padding: max(60px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
}
.score-bar { display: flex; gap: 6px; flex: 0 0 auto; }
.score-box {
  flex: 1; background: #161616; border: 1px solid #2a2a2a; border-radius: 12px; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0;
}
.score-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #a0a0a0; }
.score-val, .best-val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.new-btn {
  flex: 0 0 auto; font: inherit; color: #0a0a0a; background: #4f9eff; border: none;
  border-radius: 12px; padding: 0 14px; min-height: 56px; cursor: pointer; font-weight: 700; font-size: 14px;
}
.new-btn:active { background: #3d8ae8; }

.sp-totals {
  flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 700; padding: 0 4px;
}
.sp-us { color: #52d97f; } .sp-them { color: #ff8a8a; } .sp-bag { color: #a0a0a0; font-weight: 600; }
.status { margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: #a0a0a0; min-height: 18px; flex: 0 0 auto; }
.status.ok { color: #52d97f; } .status.bad { color: #ff8a8a; }

#game { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }

/* 트릭 테이블 — 네 자리를 십자로 */
.sp-table { position: relative; width: 100%; height: 100%; max-height: 260px; }
.sp-slot { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sp-slot.s { left: 50%; bottom: 0; transform: translateX(-50%); }
.sp-slot.n { left: 50%; top: 0; transform: translateX(-50%); }
.sp-slot.w { left: 0; top: 50%; transform: translateY(-50%); }
.sp-slot.e { right: 0; top: 50%; transform: translateY(-50%); }
.sp-tag { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-slot.mine .sp-tag { color: #52d97f; }   /* 나 + 파트너 */
.sp-slot.foe  .sp-tag { color: #ff8a8a; }   /* 상대 둘 */
.sp-slot.mine .sp-empty { border-color: #2f5f42; }
.sp-slot.foe  .sp-empty { border-color: #5f3030; }

.sp-card {
  width: 46px; height: 64px; border-radius: 8px; background: #f4f1ea; color: #16181d;
  border: 1px solid #cfc9bb; display: flex; flex-direction: column; align-items: center;
  justify-content: center; line-height: 1.05; font-weight: 800; font-size: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.sp-card.red { color: #c62828; }        /* 카드 바탕 대비 4.98:1 */
.sp-empty { width: 46px; height: 64px; border-radius: 8px; border: 1px dashed #2f3947; }

/* 비딩 */
.sp-bids { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; background: rgba(10,10,10,.86); border-radius: 14px; }
.sp-bids[hidden] { display: none; }
.sp-bid-q { font-size: 15px; font-weight: 700; }
.sp-bid-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: 100%; max-width: 320px; }
.sp-bid {
  font: inherit; font-weight: 800; font-size: 15px; min-height: 46px; border-radius: 10px;
  border: 1px solid #2a2a2a; background: #1c1c1c; color: #f5f5f5; cursor: pointer;
}
.sp-bid:active { background: #2a2a2a; }

/* 내 손패 — 13장이 겹쳐 들어간다 */
.sp-hand { flex: 0 0 auto; display: flex; justify-content: center; height: 78px; padding-top: 6px; }
.sp-card.hand {
  width: 44px; height: 64px; margin-right: -18px; padding: 0; cursor: pointer; flex: 0 0 auto;
  transition: transform .1s ease, box-shadow .1s ease; touch-action: manipulation;
}
.sp-card.hand:last-child { margin-right: 0; }
.sp-card.hand.ok { box-shadow: 0 0 0 2px #4f9eff, 0 1px 3px rgba(0,0,0,.5); transform: translateY(-8px); }
.sp-card.hand:focus-visible { outline: 2px solid #4f9eff; outline-offset: 2px; }

.home-link, .hof-link {
  position: fixed; top: max(12px, env(safe-area-inset-top)); z-index: 10;
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: rgba(0,0,0,.35); color: #fff; text-decoration: none;
  font-size: 20px; font-weight: 600; line-height: 1; border: none; cursor: pointer; font-family: inherit;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.home-link { left: max(12px, env(safe-area-inset-left)); }
.hof-link { right: max(12px, env(safe-area-inset-right)); }
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; z-index: 20; padding: 20px; backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: #161616; border: 1px solid #2a2a2a; border-radius: 18px; padding: 24px 22px;
  display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center;
  min-width: 240px; max-width: 320px; width: 100%;
}
.overlay-card h2 { margin: 0; font-size: 22px; font-weight: 800; }
.overlay-score { margin: 0; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.overlay-sub { margin: -4px 0 0; font-size: 14px; font-weight: 600; color: #a0a0a0; }
.overlay-card button {
  font: inherit; color: #fff; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px; padding: 12px 20px; min-height: 44px; cursor: pointer; font-weight: 600;
  font-size: 14px; width: 100%;
}
.overlay-card .save-btn { background: #4f9eff; border-color: #4f9eff; color: #0a0a0a; }
