:root {
  --bg: #faf8f3;
  --ink: #1a1a1a;
  --muted: #555;
  --line: #999;
  --left: #115cff;
  --right: #d8002f;
  --accent: #c79a2c;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

header, main, footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

header { padding-top: 1.5rem; }

.title-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

h1 {
  font-family: "Noto Serif SC", serif;
  font-weight: 900;
  font-size: 2.4rem;
  letter-spacing: 0.4rem;
  margin: 0;
  background: linear-gradient(135deg, var(--left), var(--right));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  letter-spacing: 0.05em;
}

hr {
  border: none;
  border-top: 1px solid var(--ink);
  margin: 1rem 0 0;
}

.intro p {
  margin: 1rem 0;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  background: white;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); box-shadow: none; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: linear-gradient(135deg, var(--left), var(--right));
  color: white;
  border-color: transparent;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.corners {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
  font-family: "Noto Serif SC", serif;
  font-size: 1.5rem;
}

.corner {
  padding: 0.4rem 1rem;
  border-radius: 8px;
  border: 2px solid;
}
.corner.left  { color: var(--left);  border-color: var(--left); }
.corner.right { color: var(--right); border-color: var(--right); }
.arrow { color: var(--muted); font-size: 1.2rem; }

#word-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

#word-input {
  flex: 1;
  min-width: 200px;
  font-family: inherit;
  font-size: 1.1rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: white;
}

.counter {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.message {
  min-height: 1.4em;
  margin: 0.25rem 0 0.5rem;
  font-size: 0.95rem;
}
.message.error   { color: var(--right); }
.message.success { color: #1a8a36; }
.message.info    { color: var(--muted); }

.graph {
  width: 100%;
  height: 500px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
  position: relative;
  overflow: hidden;
}

.graph svg { width: 100%; height: 100%; display: block; }

.info {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px dashed #bbb;
  border-radius: 8px;
}
.info h3 {
  margin: 0 0 0.4rem;
  font-family: "Noto Serif SC", serif;
}
.info ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-family: "Noto Serif SC", serif;
}
.result.win  { background: #e8f7e8; color: #136d2f; border: 1px solid #56b170; }
.result.lose { background: #fce8e8; color: #9a1a1a; border: 1px solid #d57676; }

footer {
  margin-top: 2rem;
  padding-bottom: 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
footer a { color: var(--muted); }
footer code {
  font-size: 0.8rem;
  background: #eee;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* graph node + edge styles */
.node { cursor: pointer; }
.node circle {
  stroke: var(--ink);
  stroke-width: 1.5px;
}
.node text {
  font-family: "Noto Serif SC", serif;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  fill: var(--ink);
}
.node.left  circle { fill: var(--left);  }
.node.right circle { fill: var(--right); }
.node.left  text,
.node.right text { fill: white; }
.node.middle circle { fill: #fff8e3; }

.link {
  stroke: var(--accent);
  stroke-opacity: 0.7;
}

.node.selected circle {
  stroke: var(--accent);
  stroke-width: 3px;
}
