html, body { margin: 0; min-height: 100%; font-family: 'Segoe UI', Arial, sans-serif; }
body { background: linear-gradient(180deg, #1d3320, #25422a); color: #eaf5e2; }
body.game-page { height: 100%; overflow: hidden; }
#app { position: fixed; inset: 0; }

a { color: #9ccb8a; }
button:disabled { opacity: .5; cursor: default; }

/* --- панели поверх 3D-сцены --- */
.panel {
  position: fixed; top: 16px; left: 16px; z-index: 10;
  background: rgba(20, 35, 20, 0.55); color: #fff;
  padding: 14px 18px; border-radius: 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  user-select: none;
}
.panel h1 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: .5px; }
#turn { font-size: 15px; opacity: .95; }
#status { font-size: 15px; font-weight: 600; color: #ffd86b; min-height: 20px; margin-top: 2px; }
#players { font-size: 13px; opacity: .9; margin-bottom: 4px; line-height: 1.6; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.on { background: #6cd07a; } .dot.off { background: #d06c6c; }
.clock {
  font-family: monospace; font-size: 15px; font-weight: 700; margin-left: 8px;
  padding: 1px 7px; border-radius: 6px; background: rgba(0,0,0,0.3);
}
.clock.low { color: #ff8a7a; }
.clock.active { background: #3c5f33; }
.panel-btns { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.panel-btns button, .panel-btns a {
  padding: 7px 14px; border: 0; border-radius: 8px; color: #fff; font-size: 13px;
  cursor: pointer; text-decoration: none; display: inline-block;
}
#resignBtn { background: #b5572f; } #resignBtn:hover { background: #cc6a3e; }
.btn-grey { background: #4a6a4a; } .btn-grey:hover { background: #5d8159; }
#undoBtn { background: #4a5a8a; } #undoBtn:hover { background: #5b6da3; }

.hint {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(20, 35, 20, 0.45); color: #eaf5e2;
  padding: 8px 16px; border-radius: 20px; font-size: 13px;
  backdrop-filter: blur(6px); user-select: none; white-space: nowrap;
}

/* --- запись партии (справа) --- */
#movesPanel {
  position: fixed; top: 16px; left: auto; right: 16px; z-index: 10; width: 176px;
  background: rgba(20, 35, 20, 0.55); color: #fff;
  padding: 12px 14px; border-radius: 14px; backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.25); user-select: none;
}
#movesPanel h2 { margin: 0 0 8px; font-size: 14px; font-weight: 600; opacity: .9; }
.moves-list {
  margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.7;
  max-height: 40vh; overflow-y: auto; font-variant-numeric: tabular-nums;
}
.moves-list li { display: flex; gap: 6px; }
.moves-list .no { opacity: .55; width: 24px; flex: 0 0 auto; text-align: right; }
.moves-list .mv { width: 54px; flex: 0 0 auto; border-radius: 4px; padding: 0 3px; }
.moves-list .mv.sel { background: #5a9e3f; }
.moves-list .mv.clickable { cursor: pointer; }
.moves-list .mv.clickable:hover { background: rgba(255,255,255,0.15); }
.moves-list .empty { opacity: .55; justify-content: center; }

/* --- оверлеи и карточки --- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(12, 24, 14, 0.55); backdrop-filter: blur(4px);
}
.overlay[hidden] { display: none; }
.card {
  background: rgba(24, 40, 26, 0.92); color: #eaf5e2; border-radius: 16px;
  padding: 26px 28px; width: min(440px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.card h2 { margin: 0 0 16px; font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.card h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; opacity: .85; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 8px; border: 0; border-radius: 8px; cursor: pointer; font-size: 14px;
  background: rgba(255,255,255,0.08); color: #cfe3c8;
}
.tabs button.active { background: #5a9e3f; color: #fff; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; opacity: .8; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 9px; background: rgba(0,0,0,0.25); color: #fff; font-size: 14px;
}
.field select option { background: #25422a; }
.field input:focus, .field select:focus { outline: none; border-color: #6cb84e; }
.btn-primary {
  width: 100%; padding: 11px; border: 0; border-radius: 9px; background: #5a9e3f; color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.btn-primary:hover { background: #6cb84e; }
.btn-secondary { background: #4a5a8a; } .btn-secondary:hover { background: #5b6da3; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.err { color: #ff9a8a; font-size: 13px; min-height: 18px; margin-top: 8px; }
.muted { font-size: 12px; opacity: .7; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.link { background: none; border: 0; color: #9ccb8a; cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline; }
.code-badge {
  font-family: monospace; font-size: 16px; letter-spacing: 2px; background: rgba(0,0,0,0.3);
  padding: 6px 12px; border-radius: 8px; display: inline-block; user-select: all;
}

/* --- списки столов и партий --- */
.tables { list-style: none; margin: 8px 0 0; padding: 0; max-height: 230px; overflow-y: auto; }
.tables li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.06); margin-bottom: 7px;
}
.tables li .meta { font-size: 13px; }
.tables li .meta b { font-weight: 600; }
.tables li button, .tables li a.btn {
  padding: 6px 14px; border: 0; border-radius: 8px; background: #5a9e3f; color: #fff;
  cursor: pointer; font-size: 13px; text-decoration: none; white-space: nowrap;
}
.tables .empty { justify-content: center; opacity: .6; font-size: 13px; }
.badge {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,0.12); margin-left: 6px; vertical-align: middle;
}
.badge.win { background: #3c6f33; } .badge.loss { background: #8a3c2f; } .badge.draw { background: #5a5a3c; }

/* --- обычные страницы (лобби, мои партии) --- */
.page { max-width: 720px; margin: 0 auto; padding: 28px 18px 60px; }
.page header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-bottom: 22px;
}
.page header h1 { margin: 0; font-size: 24px; }
.page header nav { display: flex; gap: 14px; align-items: center; font-size: 14px; }
.who { font-size: 14px; }
.who .rating { font-weight: 700; color: #ffd86b; }
.section {
  background: rgba(0,0,0,0.18); border-radius: 14px; padding: 18px 20px; margin-bottom: 18px;
}
.section h2 { margin: 0 0 12px; font-size: 17px; }

/* --- модалка результата --- */
#resultTitle { font-size: 26px; margin: 0 0 6px; }
#resultReason { opacity: .85; margin-bottom: 6px; }
#resultRating { font-weight: 700; color: #ffd86b; margin-bottom: 14px; min-height: 18px; }
#resultMoves {
  text-align: left; background: rgba(0,0,0,0.25); border-radius: 10px;
  padding: 10px 14px; max-height: 140px; overflow-y: auto; margin-bottom: 16px;
  font-size: 13px; line-height: 1.7;
}

/* --- выбор фигуры превращения --- */
#promo .choices { display: flex; gap: 10px; justify-content: center; }
#promo .choices button {
  width: 60px; height: 60px; font-size: 34px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
}
#promo .choices button:hover { background: #5a9e3f; }

/* --- панель анализа --- */
#analysisControls {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; gap: 8px; align-items: center;
  background: rgba(20, 35, 20, 0.55); padding: 10px 14px; border-radius: 14px;
  backdrop-filter: blur(6px);
}
#analysisControls button {
  width: 44px; height: 36px; border: 0; border-radius: 8px; background: rgba(255,255,255,0.12);
  color: #fff; font-size: 16px; cursor: pointer;
}
#analysisControls button:hover:not(:disabled) { background: #5a9e3f; }
#plyLabel { font-size: 13px; min-width: 70px; text-align: center; opacity: .9; }

/* --- список «мои доски» на странице игры --- */
#boardsPanel {
  position: fixed; bottom: 14px; left: 16px; z-index: 10; width: 230px;
  background: rgba(20, 35, 20, 0.7); padding: 12px 14px; border-radius: 14px;
  backdrop-filter: blur(6px); font-size: 13px;
}
#boardsPanel h2 { margin: 0 0 8px; font-size: 14px; }
#boardsPanel ul { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow-y: auto; }
#boardsPanel li { margin-bottom: 6px; }
#boardsPanel a { text-decoration: none; }
#boardsPanel .your-turn { color: #ffd86b; font-weight: 600; }
#boardsToggle {
  position: fixed; bottom: 14px; left: 16px; z-index: 11;
  padding: 8px 14px; border: 0; border-radius: 10px; background: rgba(20,35,20,0.7);
  color: #fff; cursor: pointer; font-size: 13px; backdrop-filter: blur(6px);
}
#boardsPanel[hidden] { display: none; }
