:root {
  --bg: #121212;
  --surface: #1f1f1f;
  --surface-alt: #232323;
  --text: #f5f5f5;
  --muted: #b8b8b8;
  --accent: #8ab4f8;
  --border: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  background: linear-gradient(180deg, #11141a 0%, #181b22 100%);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.7rem;
}

.beta-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-layout {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 320px;
  gap: 16px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  background: rgba(26, 28, 34, 0.95);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

.board-card {
  position: relative;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(26, 28, 34, 0.95);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

.board-container {
  width: min(100%, 520px);
  height: min(100vw - 64px, 520px);
  min-height: 320px;
  max-height: 520px;
}

.arrow-overlay {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 520px);
  height: min(100vw - 64px, 520px);
  min-height: 320px;
  max-height: 520px;
  pointer-events: auto;
}

.moves-card,
.comment-card,
.info-card {
  min-height: 220px;
}

.card-title {
  font-weight: 700;
  margin-bottom: 10px;
}

textarea#pgn-input,
textarea#comment-editor {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 14px;
  min-height: 220px;
}

textarea#comment-editor {
  min-height: 120px;
}

.row,
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  background: rgba(138, 180, 248, 0.18);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

button:hover {
  background: rgba(138, 180, 248, 0.26);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.small {
  padding: 10px 12px;
}

.notice {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.tags-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tags-grid .tag-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tags-grid strong {
  display: block;
  color: var(--accent);
  margin-bottom: 3px;
}

.eval-board {
  margin-top: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.eval-bar-outer {
  width: 100%;
  height: 18px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.eval-bar-inner {
  width: 50%;
  height: 100%;
  transition: width 0.2s ease, background 0.2s ease;
  background: linear-gradient(180deg, #e3f2fd 0%, #90caf9 100%);
}

.moves-list {
  max-height: 440px;
  overflow: auto;
  padding-right: 6px;
}

.move-node,
.variant-node {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.move-node.active,
.variant-node.active {
  border: 1px solid rgba(138, 180, 248, 0.45);
  background: rgba(138, 180, 248, 0.14);
}

.move-node button,
.variant-node button {
  background: transparent;
  color: var(--text);
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.95rem;
  text-align: left;
}

.move-info {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.move-info strong {
  color: var(--accent);
}

.nag {
  color: #ffca28;
  font-weight: 700;
}

.comment-meta {
  margin-bottom: 10px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .board-container,
  .arrow-overlay {
    width: min(100%, 92vw);
    height: min(92vw, 520px);
  }
}
