:root {
  --ink: #123; --teal: #0b6b6b; --teal-dark: #084f4f; --sand: #f4f1ea;
  --line: #dcd8cf; --sky: #eaf4f4; --white: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--sand); line-height: 1.5; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
a { color: var(--teal); }

/* Header */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.crest { color: var(--teal); font-size: 32px; line-height: 1; }
.brand strong { display: block; font-size: 20px; letter-spacing: .3px; }
.tagline { font-size: 13px; color: #667; text-transform: uppercase; letter-spacing: 2px; }
.site-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-nav a { text-decoration: none; font-weight: 600; font-size: 15px; }

/* Hero */
.hero { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; padding: 56px 0; }
.hero h1 { margin: 0 0 10px; font-size: 34px; }
.hero p { margin: 0 0 22px; max-width: 640px; font-size: 18px; opacity: .95; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-block; background: #fff; color: var(--teal-dark); padding: 11px 20px;
  border-radius: 6px; font-weight: 700; text-decoration: none; }
.btn-ghost { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,.7); }

/* Cards */
.columns { padding: 40px 20px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.card h3 { margin: 0 0 8px; color: var(--teal-dark); }
.card p { margin: 0; color: #556; }

/* Footer */
.site-footer { background: #fff; border-top: 1px solid var(--line); padding: 28px 0; margin-top: 20px; }
.site-footer p { margin: 4px 0; color: #667; font-size: 14px; }
.fine { font-size: 12px; color: #99a; }

/* Chat toggle */
.chat-toggle { position: fixed; bottom: 22px; right: 22px; z-index: 20;
  background: var(--teal); color: #fff; border: none; border-radius: 999px;
  padding: 14px 22px; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.chat-toggle:hover { background: var(--teal-dark); }

/* Chat panel */
.chat-panel { position: fixed; bottom: 22px; right: 22px; z-index: 30;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 44px));
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.chat-header { display: flex; align-items: center; justify-content: space-between;
  background: var(--teal); color: #fff; padding: 12px 16px; }
.chat-header strong { font-size: 16px; }
.chat-sub { display: block; font-size: 12px; opacity: .85; }
.chat-close { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; background: var(--sky); display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 3px; }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg.sys { align-self: center; background: transparent; color: #889; font-size: 13px; font-style: italic; }
.msg.win { align-self: center; background: #e8f6ec; border: 1px solid #9ed2ae; color: #17502c;
  font-size: 13px; font-weight: 700; text-align: center; max-width: 95%; }

/* Challenge tiers */
.tier-bar { display: flex; gap: 6px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.tier-chip { flex: 1; background: var(--sky); color: var(--teal-dark); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 8px; font-size: 12px; font-weight: 700; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-chip.is-current { background: var(--teal); color: #fff; border-color: var(--teal); }
.tier-chip.is-beaten { border-color: #9ed2ae; }
.tier-chip.is-beaten:not(.is-current) { background: #e8f6ec; color: #17502c; }
.tier-chip.is-locked { opacity: .45; cursor: not-allowed; }
.tier-objective { margin: 0; padding: 0 14px 10px; font-size: 13px; color: #556;
  border-bottom: 1px solid var(--line); }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.chat-send { background: var(--teal); color: #fff; border: none; border-radius: 8px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.chat-send:disabled { opacity: .5; cursor: default; }

.chat-tools { display: flex; gap: 8px; padding: 0 12px 12px; }
.tool-btn { background: #fff; color: var(--teal-dark); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tool-btn:hover { background: var(--sky); }
.tool-btn-claim { margin-left: auto; }
.tool-btn-quiet { color: #889; }

@media (max-width: 520px) {
  .site-nav { display: none; }
  .hero h1 { font-size: 28px; }
}