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

:root {
  --bg: #0d1117;
  --lc: #60a5fa;
  --rc: #f87171;
  --lbg: rgba(37,99,235,.13);
  --rbg: rgba(185,28,28,.13);
  --lbg-active: rgba(37,99,235,.22);
  --rbg-active: rgba(185,28,28,.22);
  --gold: #ffd700;
  --border: rgba(255,255,255,.07);
  --muted: rgba(255,255,255,.4);
  --card-bg: rgba(255,255,255,.03);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: #fff;
  font-family: system-ui, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#app {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* ---- Nav ---- */
#nav {
  display: flex;
  flex-shrink: 0;
  background: rgba(0,0,0,.3);
  border-top: 1px solid var(--border);
}

.nav-btn {
  flex: 1;
  padding: 13px 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s;
}

.nav-btn.active { color: var(--lc); }
.nav-btn:hover  { color: #fff; }

/* ---- Scoreboard ---- */
.board {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: calc(100svh - 50px);
  position: relative;
  overflow: hidden;
}

.board-scores {
  display: flex;
  flex: 1;
  min-height: 0;
}

.board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  gap: 12px;
  background: rgba(0,0,0,.25);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  padding: 16px;
  gap: 6px;
  transition: background .12s;
}

.side.left  { background: var(--lbg); border-right: 1px solid var(--border); }
.side.right { background: var(--rbg); }
.side.left:active  { background: var(--lbg-active); }
.side.right:active { background: var(--rbg-active); }

.s-name {
  font-size: clamp(14px,2.5vw,22px);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color .15s, opacity .15s;
  padding-bottom: 1px;
}
.s-name:hover { border-bottom-color: currentColor; opacity: .85; }

.name-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid currentColor;
  color: inherit;
  font-size: clamp(14px,2.5vw,22px);
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  width: min(200px, 80%);
  outline: none;
  padding: 2px 4px;
}

.dots { display: flex; gap: 8px; margin: 2px 0; }
.dot  { width: 11px; height: 11px; border-radius: 50%; border: 2px solid; background: transparent; }

.score {
  font-size: clamp(72px,16vw,160px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -3px;
}

.hint { font-size: 10px; color: rgba(255,255,255,.18); letter-spacing: 2px; text-transform: uppercase; }

.undo-btn {
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.52);
  padding: 5px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  transition: all .15s;
}
.undo-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---- Footer controls ---- */
.small-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.38);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: .3px;
  white-space: nowrap;
  transition: all .15s;
}
.small-btn:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); }
.small-btn.danger { border-color: rgba(239,68,68,.2); color: rgba(239,68,68,.45); }
.small-btn.danger:hover { background: rgba(239,68,68,.1); color: rgba(239,68,68,.8); }

.win-label {
  color: rgba(255,255,255,.32);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  transition: color .15s;
}
.win-label:hover { color: rgba(255,255,255,.6); }
.win-label strong { color: rgba(255,255,255,.6); font-weight: 600; }

.win-input {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  width: 52px;
  text-align: center;
  padding: 2px 4px;
  outline: none;
  vertical-align: baseline;
}
.win-input:focus { border-color: rgba(99,210,255,.6); }

/* ---- Overlay ---- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  padding: 32px;
  backdrop-filter: blur(6px);
}

.ov-badge {
  font-size: 12px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255,215,0,.8);
  font-weight: 700;
  border: 1px solid rgba(255,215,0,.35);
  padding: 4px 16px;
  border-radius: 20px;
}

.ov-title  { font-size: clamp(24px,5vw,44px); font-weight: 800; text-align: center; letter-spacing: -1px; }
.ov-sub    { font-size: clamp(14px,2.5vw,20px); color: rgba(255,255,255,.5); text-align: center; }
.ov-score  { font-size: clamp(20px,3.5vw,32px); font-weight: 700; color: var(--gold); letter-spacing: 4px; }
.ov-games  { font-size: 14px; color: rgba(255,255,255,.5); letter-spacing: .5px; }

.ov-btn {
  background: var(--gold);
  color: var(--bg);
  border: none;
  padding: 14px 44px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 4px 24px rgba(255,215,0,.35);
  transition: transform .1s;
}
.ov-btn:hover { transform: scale(1.03); }

/* ---- History card ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-title { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }

.tw { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th {
  padding: 6px 8px;
  text-align: left;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap;
}

td { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.025); }

.dc  { color: rgba(255,255,255,.38); font-size: 14px; white-space: nowrap; }
.nc  { font-size: 15px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc  { color: rgba(255,255,255,.22); font-size: 13px; text-align: center; padding: 0 2px; }
.sc  { font-size: 14px; color: rgba(255,255,255,.55); text-align: center; min-width: 46px; }
.ac  { padding: 4px 2px; white-space: nowrap; }

.wb {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(255,215,0,.18);
  color: var(--gold);
  letter-spacing: 1px;
  vertical-align: middle;
  margin-left: 3px;
}

.empty-cell { padding: 28px; text-align: center; color: rgba(255,255,255,.22); font-style: italic; }

.ab {
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.45);
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  transition: all .15s;
}
.ab.edit:hover { background: rgba(99,210,255,.1); border-color: rgba(99,210,255,.3); color: #63d2ff; }
.ab.del:hover  { background: rgba(239,68,68,.1);  border-color: rgba(239,68,68,.3);  color: #f87171; }

/* ---- History edit form ---- */
.erow td   { padding: 0; }
.eform     { padding: 12px 8px; background: rgba(255,255,255,.04); }
.efields   { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.eg        { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 120px; }
.el        { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: rgba(255,255,255,.4); }
.ebtns     { display: flex; gap: 8px; }

.einp {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px;
  color: #fff;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.einp:focus { border-color: rgba(99,210,255,.5); }

/* ---- General buttons ---- */
.btn {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
  color: rgba(255,255,255,.62);
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.btn:hover   { background: rgba(255,255,255,.12); color: #fff; }
.btn.primary { background: rgba(99,210,255,.12); border-color: rgba(99,210,255,.3); color: #63d2ff; }
.btn.primary:hover { background: rgba(99,210,255,.2); }
.btn.danger  { background: rgba(239,68,68,.07); border-color: rgba(239,68,68,.2); color: rgba(239,68,68,.8); }
.btn.danger:hover  { background: rgba(239,68,68,.15); }
