:root {
  --bg: #050b18;
  --panel-bg: #0f1729;
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent: #ff4d6a;
  --text: #f5f7ff;
  --muted: rgba(245, 247, 255, 0.7);
  --success: #4ade80;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #16213f, #050b18 60%);
  color: var(--text);
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
strong {
  color: var(--text);
}

p {
  color: var(--muted);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.connection-status {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-panel .status-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

.status-panel strong {
  font-size: 1.1rem;
}

.message-bar {
  margin-top: 0.75rem;
  min-height: 1.5rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.join-panel form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.join-panel input {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 11, 24, 0.7);
  color: var(--text);
}

.join-panel button {
  padding: 0.7rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(120deg, #ff4d6a, #ff9d4c);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.join-panel button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.muted {
  font-size: 0.85rem;
}

.bets-grid,
.totals-grid {
  display: grid;
  gap: 0.8rem;
}

.bet-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem;
  border-radius: 10px;
}

.bet-row label {
  font-weight: 600;
}

.bet-row input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--text);
}

.bet-row button {
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.bet-row button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bet-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.totals-grid .total-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.canvas-panel {
  grid-column: 1 / -1;
}

#cubeCanvas {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 3 / 2;
  height: auto;
  max-height: 420px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.4));
  display: block;
  margin-top: 1rem;
}

.history-panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-panel li {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-panel li .result-colors {
  font-weight: 600;
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }

  .bet-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bet-row label {
    grid-column: span 2;
  }
}
