/* ─── Reset & base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #1a6b2e;
  color: #fff;
  min-height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

button {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #d4a017;
  color: #1a1a1a;
  transition: background 0.15s, transform 0.1s;
}
button:hover  { background: #e8b520; transform: translateY(-1px); }
button:active { transform: translateY(0); }

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255,255,255,0.1);
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
input[type="text"]::placeholder { color: rgba(255,255,255,0.4); }
input[type="text"]:focus { border-color: #d4a017; }

/* ─── Lobby ────────────────────────────────────────────────────────────────── */

#lobby {
  max-width: 380px;
  margin: 60px auto;
  padding: 32px 28px;
  background: rgba(0,0,0,0.45);
  border-radius: 16px;
  text-align: center;
}

#lobby h1 {
  font-size: 2.8rem;
  letter-spacing: 2px;
  margin-bottom: 28px;
  color: #f0c84a;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.lobby-section {
  padding: 18px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  text-align: left;
}

.lobby-section h2 { font-size: 1rem; margin-bottom: 12px; color: #f0c84a; }

.lobby-section button { width: 100%; }

.lobby-divider {
  text-align: center;
  margin: 6px 0;
  color: rgba(255,255,255,0.4);
  font-size: 0.85rem;
}

#lobby-error {
  margin-top: 12px;
  color: #ff7070;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ─── Waiting room ─────────────────────────────────────────────────────────── */

#waiting {
  max-width: 360px;
  margin: 60px auto;
  padding: 32px;
  background: rgba(0,0,0,0.45);
  border-radius: 16px;
  text-align: center;
}

#waiting h1 { font-size: 2rem; color: #f0c84a; margin-bottom: 20px; }

.room-code-display {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.room-code-display strong {
  font-size: 2rem;
  letter-spacing: 6px;
  color: #f0c84a;
}

.waiting-hint {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 24px;
}

#players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.waiting-slot {
  padding: 10px 16px;
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 8px;
  color: rgba(255,255,255,0.3);
  font-size: 0.95rem;
}

.waiting-slot.filled {
  border-style: solid;
  border-color: #f0c84a;
  color: #fff;
  background: rgba(240,200,74,0.1);
}

#waiting-status { font-size: 0.9rem; color: rgba(255,255,255,0.5); }

/* ─── Game layout ──────────────────────────────────────────────────────────── */

#game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Score bar */
#score-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 6px 16px;
  background: rgba(0,0,0,0.4);
  gap: 8px;
  min-height: 44px;
}

.score-team {
  display: flex;
  flex-direction: column;
}
#score-team0 { align-items: flex-start; }
#score-team1 { align-items: flex-end; }

.team-name  { font-size: 0.75rem; color: rgba(255,255,255,0.6); }
.team-score { font-size: 0.9rem;  font-weight: bold; }

#trump-display {
  font-size: 1.3rem;
  font-weight: bold;
  text-align: center;
  min-width: 80px;
}
#trump-display.red   { color: #ff5555; }
#trump-display.black { color: #fff; }

/* Table */
#table {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 8px 12px;
  gap: 6px;
  overflow: hidden;
}

/* Top */
#top-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Middle row */
#middle-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  overflow: hidden;
}

#left-area, #right-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Center */
#center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

/* Bottom */
#bottom-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ─── Player labels ─────────────────────────────────────────────────────────── */

.player-label {
  font-size: 0.8rem;
  font-weight: bold;
  padding: 2px 10px;
  background: rgba(0,0,0,0.35);
  border-radius: 12px;
  white-space: nowrap;
  text-align: center;
}

/* ─── Opponent hands ────────────────────────────────────────────────────────── */

.opp-hand { display: flex; }

.opp-hand.horiz {
  flex-direction: row;
}
.opp-hand.horiz .card { margin-right: -16px; }
.opp-hand.horiz .card:last-child { margin-right: 0; }

.opp-hand.vert {
  flex-direction: column;
}
.opp-hand.vert .card { margin-bottom: -40px; }
.opp-hand.vert .card:last-child { margin-bottom: 0; }

/* ─── My hand ───────────────────────────────────────────────────────────────── */

#my-hand {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: center;
}

/* ─── Trick area ─────────────────────────────────────────────────────────────── */

#trick-area {
  display: grid;
  grid-template-areas:
    ".    top   ."
    "left  .   right"
    ".   bottom .";
  grid-template-columns: 76px 76px 76px;
  grid-template-rows:    106px 106px 106px;
}

.trick-slot { display: flex; align-items: center; justify-content: center; }
.trick-slot.trick-top    { grid-area: top;    }
.trick-slot.trick-left   { grid-area: left;   }
.trick-slot.trick-right  { grid-area: right;  }
.trick-slot.trick-bottom { grid-area: bottom; }

/* ─── Kitty display ──────────────────────────────────────────────────────────── */

#kitty-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kitty-label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
}

/* ─── Status message ─────────────────────────────────────────────────────────── */

#status-msg {
  font-size: 0.85rem;
  text-align: center;
  background: rgba(0,0,0,0.4);
  padding: 5px 14px;
  border-radius: 10px;
  max-width: 280px;
  min-height: 28px;
}

/* ─── Action buttons ─────────────────────────────────────────────────────────── */

#action-area {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.bid-btn {
  min-width: 110px;
}

/* Suit colours on bid buttons */
.bid-btn.suit-hearts,
.bid-btn.suit-diamonds {
  background: #fff;
  color: #cc0000;
}
.bid-btn.suit-hearts:hover,
.bid-btn.suit-diamonds:hover { background: #f5f5f5; }

.bid-btn.suit-clubs,
.bid-btn.suit-spades {
  background: #fff;
  color: #111;
}
.bid-btn.suit-clubs:hover,
.bid-btn.suit-spades:hover { background: #f5f5f5; }

.bid-btn.pass-btn {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.bid-btn.pass-btn:hover { background: rgba(255,255,255,0.25); }

.stuck-note {
  font-size: 0.8rem;
  color: #ffcc55;
  align-self: center;
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  width: 66px;
  height: 96px;
  border-radius: 7px;
  border: 1.5px solid #aaa;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  user-select: none;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.35);
}

/* Rank + suit in corners */
.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  font-weight: bold;
}
.card-corner.top-left { top: 4px;  left: 5px;  }
.card-corner.bot-right {
  bottom: 4px; right: 5px;
  transform: rotate(180deg);
}
.card-corner .cr { font-size: 0.75rem; }
.card-corner .cs { font-size: 0.7rem; }

/* Large center suit symbol */
.card-center {
  font-size: 1.6rem;
  line-height: 1;
}

/* Suit colours */
.card-hearts  .card-corner,
.card-hearts  .card-center,
.card-diamonds .card-corner,
.card-diamonds .card-center { color: #cc0000; }

.card-clubs  .card-corner,
.card-clubs  .card-center,
.card-spades .card-corner,
.card-spades .card-center  { color: #111; }

/* Card back */
.card-back {
  background:
    repeating-linear-gradient(
      45deg,
      #1a3a6c,
      #1a3a6c 4px,
      #2455a4 4px,
      #2455a4 9px
    );
  border-color: #888;
}

/* Clickable cards */
.card.clickable {
  cursor: pointer;
  transition: transform 0.12s;
}
.card.clickable:hover { transform: translateY(-10px); }

/* Highlight hints */
.card.playable {
  box-shadow: 0 0 0 3px #7ef77e, 1px 2px 4px rgba(0,0,0,0.35);
}

.card.invalid {
  opacity: 0.45;
  cursor: not-allowed;
}
.card.invalid:hover { transform: none; }

/* ─── Overlay ────────────────────────────────────────────────────────────────── */

#overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 10;
}

#overlay-content {
  background: rgba(10,40,15,0.95);
  border: 2px solid #f0c84a;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.8;
}

#overlay-content h2 {
  font-size: 1.8rem;
  color: #f0c84a;
  margin-bottom: 12px;
}
