:root {
  --bg: #0b0e13;
  --panel: #151a22;
  --panel-2: #1d232d;
  --line: #2b333f;
  --text: #e8ecf2;
  --muted: #94a1b2;
  --accent: #f5b301;
  --accent-2: #1f6feb;
  --danger: #c62828;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The drawing buffer is sized in JS to the window, so the rink is drawn as
   large as it can be rather than being scaled down by the browser. */
canvas#rink {
  display: block;
  position: absolute;
  inset: 0;
  background: #0b0e13;
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 13, 0.86);
  backdrop-filter: blur(3px);
  z-index: 10;
  padding: 24px;
}

.screen.hidden { display: none; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 32px;
  width: min(560px, 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.panel.wide { width: min(940px, 100%); }
.panel.scroll { max-height: 86vh; overflow-y: auto; }

h1 {
  margin: 0 0 6px;
  font-size: 40px;
  line-height: 1.05;
  letter-spacing: -0.5px;
}

h2 { margin: 0 0 4px; font-size: 26px; }
h3 { margin: 18px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.accent { color: var(--accent); }

.sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.foot { color: #667382; font-size: 12px; margin: 18px 0 0; }
.note { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 18px; }

/* ---------- buttons ---------- */
.menu-buttons { display: flex; flex-direction: column; gap: 10px; }
.menu-buttons.row { flex-direction: row; flex-wrap: wrap; margin-top: 22px; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover:not(:disabled) { background: #27303c; border-color: #3b4756; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #16181d;
  font-weight: 700;
}
.btn.primary:hover:not(:disabled) { background: #ffc42b; border-color: #ffc42b; }

.btn.danger { border-color: #5a2626; color: #ff9a9a; }
.btn.danger:hover:not(:disabled) { background: #35191a; }

/* ---------- team select ---------- */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.team-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  transition: border-color 0.12s, background 0.12s;
}

.team-card:hover { background: #27303c; }
.team-card.selected { border-color: var(--accent); background: #2a2718; }

.team-card canvas {
  flex: 0 0 auto;
  display: block;
}

.team-card .tname { font-size: 14px; font-weight: 600; line-height: 1.2; }
.team-card .tcity { font-size: 11px; color: var(--muted); }

/* ---------- options ---------- */
.options-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.options-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- tables ---------- */
.league-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 26px; }
.table-wrap { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #222a34; white-space: nowrap; }
th { background: var(--panel-2); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tr.is-user td { background: rgba(245, 179, 1, 0.09); font-weight: 600; }
td.num, th.num { text-align: right; }
td.played { color: #667382; }

/* ---------- controls list ---------- */
.controls-grid {
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr;
  gap: 10px 20px;
  align-items: center;
  font-size: 14px;
}
.controls-grid > div:nth-child(even) { color: var(--muted); }

kbd {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 7px;
  font: inherit;
  font-size: 12px;
  margin-right: 2px;
}

/* ---------- rules body ---------- */
#rules-body { font-size: 14px; line-height: 1.7; color: #cbd4e0; }
#rules-body h4 { margin: 20px 0 6px; font-size: 14px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
#rules-body ul { margin: 0; padding-left: 20px; }
#rules-body li { margin-bottom: 5px; }
#rules-body em { color: var(--muted); font-style: normal; }

/* ---------- break screen ---------- */
.break-score { font-size: 46px; font-weight: 700; text-align: center; margin: 10px 0 6px; letter-spacing: 1px; }
.break-stats { display: grid; grid-template-columns: 1fr auto 1fr; gap: 4px 18px; font-size: 13px; color: var(--muted); margin-top: 14px; }
.break-stats .mid { text-align: center; text-transform: uppercase; font-size: 11px; letter-spacing: 1px; }
.break-stats .l { text-align: right; color: var(--text); }
.break-stats .r { text-align: left; color: var(--text); }

/* ---------- in-match controls ---------- */
.match-controls {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 15;
}
.match-controls.hidden { display: none; }
.btn.small { padding: 7px 13px; font-size: 13px; border-radius: 7px; }

/* ---------- toast ---------- */
.toast {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 16, 22, 0.94);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 20;
  pointer-events: none;
  max-width: 70%;
}
.toast.hidden { display: none; }

/* While a menu panel is open the toast moves out from behind its buttons */
.toast.top { bottom: auto; top: 18px; }

@media (max-width: 820px) {
  .league-layout { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
}
