:root {
  font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  color: #193b51;
  background: #f2f7fa;
  font-size: 16px;
  font-synthesis: none;
  --navy: #092b46;
  --blue: #0086c4;
  --muted: #567183;
  --line: #d7e5ed;
  --ice: #f0f8fd;
  --error: #a42042;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
p { line-height: 1.55; }
h1, h2, h3 { overflow-wrap: anywhere; letter-spacing: -.035em; }
button, input, textarea { font: inherit; }
button {
  min-height: 44px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px;
  cursor: pointer; touch-action: manipulation; background: #e8f2f8; color: #193b51;
  font-size: .875rem; font-weight: 700;
}
button:hover { background: #dcedf6; }
button:disabled { opacity: .58; cursor: wait; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #0086c454; outline-offset: 2px;
}
.primary { background: #007bb3; color: #fff; }
.primary:hover { background: #006c9e; }
.muted { color: var(--muted); font-size: .875rem; }
.error { color: var(--error); font-size: .875rem; margin-top: 8px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px max(22px, calc((100% - 1280px) / 2)); min-height: 82px;
  background: var(--navy); color: white;
}
.brand, .top-actions { display: flex; align-items: center; gap: 16px; }
.brand { gap: 10px; }
.brand img { flex: none; object-fit: contain; }
.brand strong { font-size: 1.28rem; letter-spacing: -.045em; }
.guild-logo {
  display: block; width: 144px; height: 44px; flex: none;
  background: url("/guild-logo.png") -13px -26px / 173px 105px no-repeat;
  mix-blend-mode: screen;
}
.connection {
  display: flex; gap: 7px; align-items: center; border: 1px solid #ffffff2b; border-radius: 999px;
  padding: 6px 10px; font-size: .875rem; font-weight: 650; white-space: nowrap; color: #d5eaf5;
}
.connection::before { content: ""; width: 7px; height: 7px; flex: none; background: #ffd48f; border-radius: 50%; }
.connection[data-state="live"]::before { background: #82e6b0; }
.connection[data-state="offline"]::before { background: #ff9aab; }
.layout {
  max-width: 1324px; margin: auto; padding: 32px 22px 60px;
  display: grid; grid-template-columns: 244px minmax(0, 1fr); gap: 25px; align-items: start;
}
.sidebar, .panel { background: white; border: 1px solid var(--line); border-radius: 18px; }
.sidebar { padding: 16px; }
.sidebar-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sidebar-head h2 { font-size: 1rem; margin: 0; }
.add { padding-inline: 10px; }
.sidebar .muted { margin-top: 15px; }
#guild-list { display: grid; gap: 6px; margin-top: 12px; }
#guild-list:empty { margin-top: 0; }
.guild-button {
  text-align: left; background: #f5f9fc; border-color: #edf3f7; overflow: hidden;
  overflow-wrap: anywhere; padding-inline: 10px;
}
.guild-button[aria-current] { color: #00638e; background: #e5f5fc; border-color: #a5d5e8; box-shadow: inset 3px 0 var(--blue); }
main { min-width: 0; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 18px; }
h1 { font-size: clamp(1.45rem, 3.2vw, 2rem); }
.count {
  flex: none; padding: 6px 11px; border-radius: 999px; background: #e0f1f8;
  color: #155778; font-weight: 700; font-size: .875rem;
}
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile {
  min-height: 112px; display: flex; flex-direction: column; gap: 7px; align-items: flex-start;
  text-align: left; background: white; border-color: #cadde8; border-radius: 14px;
}
.tile:hover { background: #ecf8ff; border-color: #7ac2e0; }
.tile[data-empty="true"] { border-style: dashed; background: #f8fbfd; }
.tile[data-empty="true"]:hover { background: #ebf8ff; }
.tile-number { font-size: .8125rem; color: #506f80; font-variant-numeric: tabular-nums; }
.tile-name { font-size: 1rem; max-width: 100%; overflow-wrap: anywhere; }
.tile[data-empty="true"] .tile-name { color: #527184; }
.tile-progress { color: #31657c; font-size: .8125rem; margin-top: auto; }
.tile-progress.complete { color: #216348; }
.empty { min-height: 350px; padding: 32px 18px; display: grid; justify-items: center; align-content: center; gap: 12px; text-align: center; }
.empty p { color: var(--muted); word-break: keep-all; }
.empty button { margin-top: 4px; }
.empty-mark { display: grid; grid-template-columns: repeat(2, 12px); gap: 4px; margin-bottom: 3px; }
.empty-mark i { height: 12px; background: #d8effa; border: 1px solid #74bad8; border-radius: 3px; }
dialog {
  max-width: min(94vw, 760px); max-height: 90dvh; padding: 0; border: 1px solid var(--line);
  border-radius: 20px; color: #193b51; background: white; box-shadow: 0 22px 80px #092b4645;
}
dialog::backdrop { background: #092b468c; }
body:has(dialog[open]) { overflow: hidden; }
#guild-dialog { width: 430px; padding: 20px; }
#slot-dialog { width: 760px; }
#slot-dialog[open] { display: flex; flex-direction: column; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.dialog-head h2 { font-size: 1.25rem; }
.dialog-head p { margin-top: 2px; }
.close { width: 44px; padding: 0; flex: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.editor-head, .editor-body, .editor-foot { padding-inline: 20px; }
.editor-head { flex: none; margin: 0; padding-block: 14px; border-bottom: 1px solid var(--line); }
.editor-body { overflow: auto; padding-block: 18px; }
.editor-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line); padding-block: 12px;
}
.editor-foot[data-error] p { color: var(--error); }
.editor-foot button { min-width: 74px; }
.field { display: block; color: #3d6278; font-size: .875rem; font-weight: 700; margin-bottom: 6px; }
input, textarea {
  width: 100%; min-width: 0; padding: 9px 10px; min-height: 44px; border: 1px solid #9cb9ca;
  border-radius: 9px; background: var(--ice); color: #163d57;
}
textarea { display: block; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--error); }
.dragon-intro { margin: 20px 0 10px; }
.dragon-intro h3 { font-size: 1rem; margin-bottom: 3px; }
#dragon-editor { display: grid; gap: 10px; }
.dragon {
  min-width: 0; border: 1px solid var(--line); background: #f8fbfd; border-radius: 12px;
  padding: 12px; display: grid; gap: 10px;
}
.dragon h4 { font-size: .9375rem; margin: 0; }
.stat-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { min-width: 0; border: 0; padding: 0; margin: 0; }
.stat legend { padding: 0; margin: 0 0 3px; }
.stat-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 4px; align-items: end; }
.stat-pair label span { display: block; font-size: .8125rem; color: var(--muted); margin-bottom: 3px; }
.stat-pair input { font-variant-numeric: tabular-nums; padding-inline: 5px; }
.stat-plus { display: grid; place-items: center; min-height: 44px; color: #315a73; font-weight: 750; }
.scores { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin: 0; gap: 8px; }
.scores div { background: #e4f2fa; border-radius: 8px; padding: 6px 9px; line-height: 1.35; }
.scores dt { color: #315a73; font-size: .875rem; font-weight: 700; }
.scores dd { color: #0b547b; font-size: 1.1rem; margin: 1px 0 0; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.average { margin-top: 14px; }
.average div { padding: 9px 12px; background: #d8edf9; border: 1px solid #b3d8ed; }
.notes-label { margin-top: 18px; }
@media (min-width: 690px) {
  .dragon { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); align-items: end; }
  .dragon h4, .scores { grid-column: 1 / -1; }
}
@media (max-width: 730px) {
  .layout { grid-template-columns: 1fr; padding: 16px 14px 32px; gap: 20px; }
  #guild-list { display: flex; flex-wrap: wrap; }
  .guild-button { max-width: 100%; }
}
@media (max-width: 450px) {
  .topbar { padding: 11px 14px; min-height: 70px; gap: 8px; }
  .top-actions { gap: 6px; }
  .brand { gap: 6px; }
  .brand img { width: 29px; height: 29px; }
  .brand strong { font-size: 1.12rem; }
  .guild-logo { display: none; }
  .connection { padding-inline: 8px; }
  .board-head { align-items: flex-start; flex-wrap: wrap; }
  .grid { gap: 6px; }
  .tile { padding: 8px 5px; border-radius: 10px; min-height: 95px; gap: 5px; }
  .tile-name { font-size: .875rem; }
  .tile-progress { font-size: .75rem; }
  .editor-head, .editor-body, .editor-foot { padding-inline: 12px; }
  .dragon { padding: 9px; }
  .stat-inputs { grid-template-columns: 1fr; gap: 9px; }
  .stat-pair { gap: 8px; }
  .stat-pair input { padding-inline: 9px; }
}
