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

:root {
  --bg-dark: #1a3a2a;
  --bg-felt: #2d5a3d;
  --bg-felt-light: #3a7050;
  --water: #2a5080;
  --water-light: #3a6a9a;
  --gold: #d4a843;
  --gold-light: #e8c468;
  --card-white: #f5f0e8;
  --card-back: #2255aa;
  --red: #cc3333;
  --text: #f0ead6;
  --text-dim: #a0b8a8;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Menu */
.menu-container {
  background: var(--bg-felt);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.menu-container h1 {
  font-size: 2.5rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 24px;
}

.menu-section {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
}

.menu-section h3 {
  margin-bottom: 10px;
  color: var(--gold-light);
}

input, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 10px;
}

input::placeholder {
  color: var(--text-dim);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: left;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.1s, box-shadow 0.1s;
  width: 100%;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--gold);
  color: #1a1a1a;
}

.btn-secondary {
  background: var(--water);
  color: var(--text);
}

.error-msg {
  color: #ff6b6b;
  margin-top: 10px;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* Lobby */
.lobby-container {
  background: var(--bg-felt);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  text-align: center;
}

.game-code {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--gold);
  letter-spacing: 4px;
  user-select: all;
}

.lobby-players {
  margin: 20px 0;
  text-align: left;
}

.lobby-player {
  padding: 10px 16px;
  margin: 6px 0;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lobby-player .tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--water);
}

.lobby-player .tag.host {
  background: var(--gold);
  color: #1a1a1a;
}

.lobby-controls {
  display: flex;
  gap: 10px;
}

.lobby-controls .btn {
  flex: 1;
}

.lobby-wait {
  color: var(--text-dim);
  display: none;
}

/* Game Screen */
#game-screen.active {
  display: block;
}

.game-layout {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  grid-template-columns: 1fr 240px;
  gap: 0;
  background: var(--bg-felt);
}

/* Opponents */
.opponents {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 10px 20px;
  background: rgba(0,0,0,0.15);
}

.opponent {
  text-align: center;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  min-width: 120px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}

.opponent:hover {
  border-color: var(--gold);
}

.opponent.active-turn {
  border-color: var(--gold-light);
  background: rgba(212, 168, 67, 0.15);
}

.opponent.selectable {
  border-color: var(--water-light);
  animation: pulse 1.5s infinite;
}

.opponent .opp-name {
  font-weight: bold;
  margin-bottom: 4px;
}

.opponent .opp-cards {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin: 4px 0;
}

.mini-card {
  width: 14px;
  height: 20px;
  background: url('/images/rod_baksida.png') center/cover;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.2);
}

.opponent .opp-sets {
  font-size: 0.8rem;
  color: var(--gold-light);
}

/* Lake */
.lake {
  grid-column: 1;
  position: relative;
  background: radial-gradient(ellipse at center, var(--water-light) 0%, var(--water) 60%, #1d3d5f 100%);
  border-radius: 50%;
  margin: 10px 20px;
  min-height: 200px;
  overflow: hidden;
}

.lake-label {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  z-index: 1;
  pointer-events: none;
}

.lake-cards {
  position: absolute;
  inset: 0;
}

.lake-card {
  position: absolute;
  width: 40px;
  height: 56px;
  background: url('/images/rod_baksida.png') center/cover;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: default;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.3);
}

.lake-card.fishable {
  cursor: pointer;
  animation: bob 3s ease-in-out infinite;
}

.lake-card.fishable:hover {
  transform: scale(1.3) !important;
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.6);
  z-index: 10;
}

/* Game Log */
.game-log {
  grid-column: 2;
  grid-row: 2 / 5;
  background: rgba(0,0,0,0.25);
  padding: 12px;
  overflow-y: auto;
  font-size: 0.85rem;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.game-log .log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-dim);
}

.game-log .log-entry:last-child {
  color: var(--text);
  font-weight: bold;
}

/* Action Panel */
.action-panel {
  grid-column: 1;
  padding: 10px 20px;
  background: rgba(0,0,0,0.2);
  text-align: center;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-prompt {
  font-size: 1rem;
  color: var(--gold-light);
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.rank-btn {
  padding: 6px 14px;
  background: var(--card-white);
  color: #1a1a1a;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.15s;
}

.rank-btn:hover {
  border-color: var(--gold);
  transform: scale(1.1);
}

.rank-btn.selected {
  border-color: var(--gold);
  background: var(--gold-light);
}

/* Player Hand */
.player-hand {
  grid-column: 1;
  padding: 10px 20px 16px;
  background: rgba(0,0,0,0.3);
}

.hand-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.hand-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.card {
  width: 60px;
  height: 84px;
  background: var(--card-white);
  border-radius: 6px;
  border: 2px solid #ccc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform 0.15s, border-color 0.15s;
  user-select: none;
  font-weight: bold;
}

.card .card-rank {
  font-size: 1.3rem;
  line-height: 1;
}

.card .card-suit {
  font-size: 1.1rem;
  line-height: 1;
}

.card.red {
  color: var(--red);
}

.card.black {
  color: #1a1a1a;
}

.card.fished {
  border-color: #4ae04a;
  box-shadow: 0 0 12px rgba(74, 224, 74, 0.6);
  transform: translateY(-8px);
  animation: fished-glow 1.5s ease-in-out infinite;
}

.card.selectable {
  cursor: pointer;
  border-color: var(--gold);
}

.card.selectable:hover {
  transform: translateY(-8px);
  border-color: var(--gold-light);
  box-shadow: 0 4px 12px rgba(212, 168, 67, 0.4);
}

/* Player Sets */
.player-sets {
  grid-column: 1;
  padding: 4px 20px 8px;
  background: rgba(0,0,0,0.3);
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.set-badge {
  background: var(--gold);
  color: #1a1a1a;
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: bold;
}

/* Game Over */
.game-over-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.game-over-overlay.active {
  display: flex;
}

.game-over-content {
  background: var(--bg-felt);
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.game-over-content h2 {
  color: var(--gold);
  font-size: 1.8rem;
  margin-bottom: 20px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.score-row.winner {
  color: var(--gold);
  font-weight: bold;
}

.game-over-content .btn {
  margin-top: 20px;
}

/* Animations */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(58, 106, 154, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(58, 106, 154, 0); }
}

@keyframes fished-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(74, 224, 74, 0.4); }
  50% { box-shadow: 0 0 16px rgba(74, 224, 74, 0.8); }
}

@keyframes bob {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -3px; }
}

/* Responsive */
@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto auto auto;
  }

  .game-log {
    grid-column: 1;
    grid-row: auto;
    max-height: 80px;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .lake {
    margin: 10px;
    min-height: 150px;
  }

  .card {
    width: 50px;
    height: 70px;
  }

  .card .card-rank {
    font-size: 1.1rem;
  }
}
