@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Lora:ital,wght@0,400;0,600;1,400&family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg-dark: #1a1610;
  --bg-card: #242018;
  --bg-chalk: #2a2520;
  --chalk-white: #e8dcc8;
  --chalk-dim: #8a7e6c;
  --amber: #d4a029;
  --amber-glow: #e8b84d;
  --amber-deep: #9a7420;
  --red-chalk: #c45c4a;
  --green-chalk: #6b9a5c;
  --blue-chalk: #5c7a9a;
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: 'Lora', Georgia, serif;
  background: var(--bg-dark);
  color: var(--chalk-white);
  min-height: 100vh;
  line-height: 1.6;
}

/* Chalkboard noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Header ── */
header {
  text-align: center;
  padding: 2.5rem 0 2rem;
  border-bottom: 2px solid var(--amber-deep);
  margin-bottom: 2.5rem;
  position: relative;
}

header::after {
  content: '🍺';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  opacity: 0.5;
}

h1 {
  font-family: 'Permanent Marker', cursive;
  font-size: 2.8rem;
  color: var(--amber);
  text-shadow: 0 0 30px rgba(212,160,41,0.3);
  letter-spacing: 2px;
}

h1 small {
  display: block;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  color: var(--chalk-dim);
  font-weight: 400;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

h2 {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.6rem;
  color: var(--amber-glow);
  margin-bottom: 1rem;
}

h3 {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.2rem;
  color: var(--chalk-white);
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(212,160,41,0.15);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber), var(--amber-deep));
}

/* ── Forms ── */
.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: end;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--chalk-dim);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

input[type="text"],
input[type="number"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-chalk);
  border: 1px solid rgba(212,160,41,0.2);
  border-radius: var(--radius);
  color: var(--chalk-white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(212,160,41,0.15);
}

input[type="number"] {
  width: 80px;
  text-align: center;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

button {
  font-family: 'Permanent Marker', cursive;
  font-size: 0.95rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--amber);
  color: var(--bg-dark);
}
.btn-primary:hover {
  background: var(--amber-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212,160,41,0.3);
}

.btn-danger {
  background: var(--red-chalk);
  color: var(--chalk-white);
}
.btn-danger:hover {
  background: #d4685a;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--chalk-white);
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.14);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Sessions List ── */
.session-list {
  list-style: none;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  background: var(--bg-chalk);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  border-left: 3px solid var(--amber);
  transition: background 0.2s, transform 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.session-item:hover {
  background: rgba(212,160,41,0.08);
  transform: translateX(4px);
}

.session-item .name {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.1rem;
}

.session-item .meta {
  font-size: 0.8rem;
  color: var(--chalk-dim);
}

/* ── Badge ── */
.badge {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badge-active {
  background: rgba(107,154,92,0.2);
  color: var(--green-chalk);
  border: 1px solid rgba(107,154,92,0.3);
}

.badge-finished {
  background: rgba(196,92,74,0.2);
  color: var(--red-chalk);
  border: 1px solid rgba(196,92,74,0.3);
}

/* ── Leaderboard Table ── */
.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.leaderboard th {
  font-family: 'Permanent Marker', cursive;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--chalk-dim);
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--amber-deep);
  letter-spacing: 1px;
}

.leaderboard th:last-child,
.leaderboard td:last-child {
  text-align: right;
}

.leaderboard td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.leaderboard tr:hover td {
  background: rgba(212,160,41,0.05);
}

.leaderboard .rank {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.3rem;
  color: var(--amber);
  width: 50px;
}

.leaderboard .rank-1 { color: #ffd700; text-shadow: 0 0 10px rgba(255,215,0,0.4); }
.leaderboard .rank-2 { color: #c0c0c0; }
.leaderboard .rank-3 { color: #cd7f32; }

.leaderboard .team-name {
  font-weight: 600;
}

.leaderboard .total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--amber-glow);
}

/* ── Round Scoring ── */
.round-block {
  background: var(--bg-chalk);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border-left: 3px solid var(--blue-chalk);
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.round-header h3 {
  color: var(--blue-chalk);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.75rem;
  align-items: center;
}

.score-grid .team-label {
  font-size: 0.9rem;
}

/* ── Teams List (session view) ── */
.team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.team-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  padding: 0.35rem 0.8rem;
  background: rgba(92,122,154,0.15);
  border: 1px solid rgba(92,122,154,0.3);
  border-radius: 100px;
  color: var(--blue-chalk);
}

/* ── Messages ── */
.error-msg {
  color: var(--red-chalk);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  font-style: italic;
}

.empty-state {
  text-align: center;
  color: var(--chalk-dim);
  padding: 2rem;
  font-style: italic;
}

/* ── Section spacing ── */
section {
  margin-bottom: 2rem;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card, .round-block, .session-item {
  animation: fadeIn 0.3s ease-out both;
}

/* Stagger session items */
.session-item:nth-child(1) { animation-delay: 0.05s; }
.session-item:nth-child(2) { animation-delay: 0.1s; }
.session-item:nth-child(3) { animation-delay: 0.15s; }
.session-item:nth-child(4) { animation-delay: 0.2s; }
.session-item:nth-child(5) { animation-delay: 0.25s; }

/* ── Responsive ── */
@media (max-width: 600px) {
  h1 { font-size: 2rem; }
  .container { padding: 1rem; }
  .form-row { flex-direction: column; }
  .score-grid { grid-template-columns: 1fr 80px; }
}
