/* ================================================================
   Oh Hell — UI Polish
   Mobile-first, 360px minimum width, portrait + landscape
   ================================================================ */

:root {
  --red:     #c62828;
  --red-bg:  #ffebee;
  --dark:    #1a1a2e;
  --primary: #1a237e;
  --primary-light: #e8eaf6;
  --gold:    #f9a825;
  --green:   #2e7d32;
  --border:  #e0e0e0;
  --surface: #ffffff;
  --bg:      #f0f2f5;
  --muted:   #757575;
  --shadow:  0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius:  12px;
  --radius-sm: 8px;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 360px;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: #212121;
  overflow-x: hidden;
  /* iPhone safe area — home indicator / notch */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ── App shell ──────────────────────────────────────────────── */
.mud-appbar {
  background: linear-gradient(135deg, var(--dark) 0%, var(--primary) 100%) !important;
}

/* ── Page wrapper ───────────────────────────────────────────── */
.game-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* ── Cards ──────────────────────────────────────────────────── */
.playing-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 101px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface, #ffffff);
  font-family: 'Georgia', serif;
  font-size: 1.32rem;
  font-weight: 700;
  cursor: default;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.playing-card.red        { color: var(--red); }
.playing-card.black-suit { color: #1a1a1a; }

.playing-card.playable {
  cursor: pointer;
  border-color: transparent;
  touch-action: manipulation;
}
.playing-card.playable:hover {
  transform: translateY(-8px) scale(1.04);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  z-index: 2;
}
.playing-card.playable:active {
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
  z-index: 2;
}
.playing-card.playable.red:hover,
.playing-card.playable.red:active { border-color: var(--red); }

.playing-card.illegal {
  opacity: 0.35;
  cursor: not-allowed;
}
.playing-card.illegal:hover {
  transform: none;
  box-shadow: var(--shadow);
  border-color: var(--border);
}

/* Suit corner labels */
.playing-card .corner {
  position: absolute;
  font-size: 0.69rem;
  line-height: 1;
}
.playing-card .corner.top-left  { top: 5px; left: 6px; }
.playing-card .corner.bot-right { bottom: 5px; right: 6px; transform: rotate(180deg); }

.playing-card .center { font-size: 1.73rem; line-height: 1; }

/* Hand layout — fan effect on desktop, wrap on mobile */
.hand-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 4px 0 8px;
}

@media (min-width: 600px) {
  .hand-container {
    gap: 0;
  }
  .hand-container .playing-card {
    margin-left: -14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, margin 0.15s ease;
  }
  .hand-container .playing-card:first-child { margin-left: 0; }
  .hand-container .playing-card.playable:hover {
    margin-left: -14px;
    margin-right: 8px;
    z-index: 3;
  }
}

/* ── Trick area ──────────────────────────────────────────────── */
.trick-area {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 8px 4px;
  min-height: 130px; /* matches one row of cards (101px card + label + gap) */
  align-items: center;
}

.trick-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.trick-play .player-label {
  font-size: 0.7rem;
  color: var(--muted);
  max-width: 72px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trick-play .winner-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Player seats ────────────────────────────────────────────── */
.player-seat {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  min-height: 80px; /* stable height — prevents bounce when turn indicators change */
}

.player-seat.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(26,35,126,0.15);
}

.player-seat.me { border-style: dashed; }

/* Your box when it's your turn — high-visibility */
.player-seat.me.active {
    border-color: #2e7d32;
    border-style: solid;
    border-width: 2.5px;
    background: #e8f5e9;
    box-shadow: 0 0 0 3px rgba(46,125,50,0.18);
}

.player-seat .seat-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-seat .seat-stats {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.player-seat .seat-bid-made {
  font-weight: 700;
  color: var(--green);
}
.player-seat .seat-bid-miss {
  font-weight: 700;
  color: var(--red);
}

.player-seat .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  margin-right: 6px;
}

.away-badge {
  font-size: 0.65rem;
  background: #fff3e0;
  color: #e65100;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}

/* ── Stepper buttons (replace sliders on mobile) ─────────────── */
.stepper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.stepper-controls {
  display: flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stepper-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: var(--surface);
  color: var(--primary);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s, color 0.1s;
}
.stepper-btn:active { background: var(--primary); color: white; }
.stepper-val {
  min-width: 40px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0 4px;
  line-height: 44px;
  color: #212121;
}

/* ── Bid buttons ─────────────────────────────────────────────── */
.bid-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.bid-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--primary);
  background: var(--surface);
  color: var(--primary);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s, color 0.1s, transform 0.1s, box-shadow 0.1s;
  font-family: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.bid-btn:hover:not(:disabled),
.bid-btn:active:not(:disabled) {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.bid-btn:active:not(:disabled) {
  transform: translateY(0);
}

.bid-btn.forbidden {
  border-color: var(--border);
  color: #bdbdbd;
  cursor: not-allowed;
  opacity: 0.5;
}

/* ── Action timer ────────────────────────────────────────────── */
.action-timer-wrap {
  position: relative;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.action-timer-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.9s linear, background 0.5s;
}

/* ── Info bar ────────────────────────────────────────────────── */
.game-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  gap: 8px;
  flex-wrap: wrap;
}

.trump-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  animation: trump-pop 0.35s ease;
}

.trump-indicator .trump-suit-sym {
  font-size: 1.5rem;
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Georgia', serif;
}

.trump-indicator .trump-suit-sym.red  { color: #e53935; }
.trump-indicator .trump-suit-sym.dark { color: #1a1a1a; }

.trump-indicator .trump-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  align-self: flex-end;
  padding-bottom: 2px;
}

.trump-indicator.no-trump {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Bid trump hint ───────────────────────────────────────────── */
.bid-trump-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.bid-trump-hint .red  { color: #e53935; font-size: 1rem; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Georgia', serif; }
.bid-trump-hint .dark { color: #1a1a1a;    font-size: 1rem; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Georgia', serif; }

/* ── Trick trump indicator ────────────────────────────────────── */
.trick-trump-indicator {
  font-size: 1.1rem;
  line-height: 1;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Georgia', serif;
}

.trick-trump-indicator.red  { color: #e53935; opacity: 0.85; }
.trick-trump-indicator.dark { color: #1a1a1a; opacity: 0.45; }

@keyframes trump-pop {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1);   opacity: 1; }
}

/* ── Scoring table ───────────────────────────────────────────── */
.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.score-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--dark);
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.score-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.score-table tr:last-child td { border-bottom: none; }
.score-table tr:nth-child(even) td { background: #fafafa; }
.score-table .made { color: var(--green); font-weight: 700; }
.score-table .miss { color: var(--red); }
.score-table .delta-pos { color: var(--green); font-weight: 600; }
.score-table .delta-neg { color: var(--red); }

/* ── Phase banners ───────────────────────────────────────────── */
.phase-banner {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.phase-banner.waiting {
  background: #e3f2fd;
  color: #0d47a1;
  border-left: 4px solid #1565c0;
}
.phase-banner.your-turn {
  background: #e8f5e9;
  color: #1b5e20;
  border-left: 4px solid #2e7d32;
  font-weight: 600;
}
.phase-banner.error {
  background: #ffebee;
  color: var(--red);
  border-left: 4px solid var(--red);
}

/* ── Chat ────────────────────────────────────────────────────── */
.chat-box {
  max-height: 130px;
  overflow-y: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg {
  font-size: 0.83rem;
  padding: 3px 0;
  border-bottom: 1px solid #f5f5f5;
}

.chat-msg .chat-author { font-weight: 600; color: var(--primary); }

/* ── Home / Lobby ────────────────────────────────────────────── */
.room-code-display {
  font-family: 'Courier New', monospace;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--primary);
  text-align: center;
  padding: 10px;
  background: var(--primary-light);
  border-radius: var(--radius);
  margin: 8px 0;
}

.player-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  background: var(--surface);
  transition: background 0.15s;
}

/* ── Game Over ───────────────────────────────────────────────── */
.podium-card {
  text-align: center;
  padding: 20px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.podium-card.first  { border-top: 4px solid var(--gold); }
.podium-card.second { border-top: 4px solid #9e9e9e; }
.podium-card.third  { border-top: 4px solid #8d6e63; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.slide-in   { animation: slideInUp 0.25s ease both; }
.fade-in    { animation: fadeIn 0.3s ease both; }
.pulse-anim { animation: pulse 1.2s ease infinite; }

@keyframes throwToCenter {
  0%   { transform: scale(1);    opacity: 1; }
  75%  { transform: scale(0.6);  opacity: 1; }
  100% { transform: scale(0.45); opacity: 0; }
}

.trick-area.trick-complete .trick-play .playing-card {
  animation: throwToCenter 0.45s ease-in forwards;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .playing-card {
    width: 62px;
    height: 85px;
    font-size: 1.09rem;
  }
  .playing-card .center { font-size: 1.38rem; }
  .bid-btn { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .room-code-display { font-size: 1.7rem; }
  .score-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .score-table th, .score-table td { padding: 7px 8px; font-size: 0.82rem; }
  .trump-indicator .trump-suit-sym { font-size: 1.15rem; }
  .game-info-bar { font-size: 0.75rem; padding: 6px 10px; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .hand-container { max-height: 38vh; overflow-y: auto; }
  .game-page { gap: 6px; }
}

/* ── Their-turn status badge (read-only, non-interactive) ────── */
/* .their-turn-badge removed */

/* ── Bid-made checkmark (scoring phase) ──────────────────────── */
.bid-made-checkmark {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--green);
  line-height: 1;
  pointer-events: none;
}

/* ── Settings gear button ────────────────────────────────────── */
.settings-gear-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.settings-gear-btn:hover,
.settings-gear-btn.open {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ── Settings panel ──────────────────────────────────────────── */
.settings-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.settings-panel-row:last-child { border-bottom: none; }
.settings-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 700;
}
.settings-toggle-btn button {
  border: none;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  transition: background 0.1s, color 0.1s;
}
.settings-toggle-btn button.active {
  background: var(--primary);
  color: white;
}

/* ─── Static pages (Rules, Terms, Privacy) ─── */
.static-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 32px 16px 64px;
    line-height: 1.7;
    color: #222;
}

.static-page h1 {
    font-size: 2rem;
    font-weight: 900;
    margin: 0 0 8px;
}

.static-page .lead {
    font-size: 1.1rem;
    color: #555;
    margin: 0 0 32px;
}

.static-page h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 32px 0 8px;
    border-bottom: 2px solid #e50914;
    padding-bottom: 4px;
}

.static-page h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 20px 0 6px;
}

.static-page p, .static-page li { margin-bottom: 10px; }

.static-page ul, .static-page ol {
    padding-left: 24px;
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.rules-table th, .rules-table td {
    padding: 10px 14px;
    border: 1px solid #ddd;
    text-align: left;
}

.rules-table th {
    background: #1a1a1a;
    color: #fff;
    font-weight: 600;
}

.rules-table tr:nth-child(even) td { background: #f9f9f9; }

.rules-cta {
    margin-top: 40px;
    text-align: center;
}

/* ─── Site footer ─── */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    font-size: 0.8rem;
    color: #888;
    border-top: 1px solid #eee;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.site-footer a {
    color: #888;
    text-decoration: none;
}

.site-footer a:hover { color: #e50914; }

/* ─── Rules/Glossary CTA links ─── */
.play-now-link {
    display: inline-block;
    padding: 10px 24px;
    background: #e50914;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: background 0.15s;
}

.play-now-link:hover { background: #c40710; color: #fff; }

.play-now-link--secondary {
    background: #1a1a1a;
}

.play-now-link--secondary:hover { background: #333; }

/* ─── Glossary ─── */
.glossary-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 6px;
}

.glossary-nav a {
    color: #e50914;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
}

.glossary-nav a:hover { text-decoration: underline; }

.glossary-list {
    margin: 0;
    padding: 0;
}

.glossary-list dt {
    font-size: 1.15rem;
    font-weight: 800;
    color: #111;
    margin: 36px 0 6px;
    scroll-margin-top: 80px;
}

.glossary-list dt::before {
    content: '';
    display: block;
    height: 2px;
    width: 32px;
    background: #e50914;
    margin-bottom: 8px;
}

.glossary-list dd {
    margin: 0 0 0 0;
    color: #444;
    line-height: 1.75;
}

.glossary-list dd a {
    color: #e50914;
    text-decoration: none;
    font-style: italic;
}

.glossary-list dd a:hover { text-decoration: underline; }

/* ─── Sticky footer ─── */
html, body { height: 100%; }

.mud-layout {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.mud-main-content {
    flex: 1 1 auto !important;
}

/* Trick area placeholder — keeps height stable before first card is played */
.trick-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    color: var(--muted);
    font-size: 0.8rem;
    font-style: italic;
    opacity: 0.5;
}

.settings-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin: 10px 0 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
