:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e5e7eb;
  --score-bg: #eef2ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.banner-error {
  width: 100%;
  max-width: 40rem;
  margin: 1rem;
  padding: 0.85rem 1.1rem;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  text-align: center;
  font-size: 1.05rem;
}

.site-header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

.title {
  margin: 0;
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
  color: var(--muted);
  font-weight: 500;
}

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem 1rem 5rem;
}

.board {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow);
}

.cell-name {
  flex: 1 1 120px;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  line-height: 1.25;
  color: var(--text);
}

.cell-name--left {
  order: 1;
}

.cell-name--right {
  order: 6;
}

.cell-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
}

.cell-logo--left {
  order: 2;
}

.cell-logo--right {
  order: 5;
}

.cell-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cell-logo--empty {
  background: repeating-linear-gradient(
    -45deg,
    var(--border),
    var(--border) 2px,
    transparent 2px,
    transparent 6px
  );
  opacity: 0.5;
}

.score {
  min-width: 2.85rem;
  padding: 0.5rem 0.85rem;
  font-size: clamp(1.75rem, 6vw, 2.45rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: var(--score-bg);
  color: var(--text);
  border-radius: 8px;
  border: none;
  cursor: default;
  font-family: inherit;
  line-height: 1;
}

.board[data-logged-in="1"] .score {
  cursor: pointer;
  user-select: none;
}

.board[data-logged-in="1"] .score:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.score--1 {
  order: 3;
}

.score--2 {
  order: 4;
}

.panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.panel > * {
  pointer-events: auto;
}

.panel-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.55rem 1.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: var(--accent);
}

.panel-toggle:hover {
  background: var(--bg);
}

.panel-body {
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 1rem 1.25rem;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.panel-section {
  margin-bottom: 1.25rem;
}

.panel-section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.stack label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 1rem;
  font-weight: 500;
}

.stack input,
.line-form select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.05rem;
}

.stack button[type="submit"],
.line-form button {
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.stack button[type="submit"]:hover,
.line-form button:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  padding: 0.6rem 1.1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--bg);
}

.edit-club-wrap {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.edit-club-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.edit-club-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.clubs-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.club-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.club-thumb {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--bg);
  flex-shrink: 0;
}

.club-thumb--empty {
  display: inline-block;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    -45deg,
    var(--border),
    var(--border) 2px,
    transparent 2px,
    transparent 6px
  );
  opacity: 0.45;
}

.club-row-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.club-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn-edit-club,
.btn-delete-club {
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  color: var(--accent);
}

.btn-edit-club:hover {
  background: var(--bg);
}

.btn-delete-club {
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-delete-club:hover {
  background: #fef2f2;
}

.msg {
  min-height: 1.25rem;
  font-size: 0.95rem;
  margin: 0;
}

.msg--ok {
  color: #047857;
}

.msg--err {
  color: #b91c1c;
}

.line-forms {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.line-form {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr auto;
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-size: 0.95rem;
}

.line-form .ln {
  font-weight: 700;
  color: var(--muted);
}

.panel-footer {
  margin: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.linkish {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 1rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 1.65rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.modal-box h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

@media (max-width: 640px) {
  .line-form {
    grid-template-columns: 1fr;
  }

  .line-form .ln {
    grid-column: 1 / -1;
  }
}
