@font-face {
  font-family: 'RuneScape';
  src: url('fonts/runescape.ttf') format('truetype');
  font-weight: normal;
}

@font-face {
  font-family: 'RuneScapeBold';
  src: url('fonts/runescape_bold.ttf') format('truetype');
  font-weight: bold;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --stone-0: #110d0a;
  --stone-1: #1a1410;
  --stone-2: #221a14;
  --stone-3: #2b2118;
  --stone-4: #3a2e22;
  --iron: #5e4a32;
  --iron-hi: #8a7048;
  --iron-lo: #43352a;
  --ink: #f0e0bc;
  --ink-dim: #8a7a5a;
  --gold: #ff981f;
  --gold-dim: #a86820;
  --hp-green: #00ff00;
  --hp-yellow: #ffff00;
  --hp-red: #ff0000;
  --magic: #6040a0;
  --magic-hi: #9070d0;
  --slot: #2a2218;
  --font: 'RuneScape', monospace;
  --font-bold: 'RuneScapeBold', monospace;
  --bevel-light: #6a6050;
  --bevel-dark: #1a1410;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--stone-0);
  background-image:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(255, 152, 31, 0.05), transparent 55%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, var(--stone-1), var(--stone-0));
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  image-rendering: pixelated;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

::-webkit-scrollbar {
  width: 10px;
  background: var(--stone-1);
}

::-webkit-scrollbar-thumb {
  background: var(--iron);
  border: 1px solid var(--bevel-dark);
}

.osrs-frame {
  border-bottom: 2px solid var(--bevel-dark);
  box-shadow:
    inset 0 1px 0 var(--bevel-light),
    0 2px 8px rgba(0, 0, 0, 0.45);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, var(--stone-4), var(--stone-3) 40%, var(--stone-2));
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: min(220px, 42vw);
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}

.tag {
  font-size: 1rem;
  color: var(--ink-dim);
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.board-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  background: var(--stone-2);
  border-bottom: 2px solid var(--bevel-dark);
  text-shadow: 1px 1px 0 #000;
}

.board-controls output {
  margin-right: auto;
  font-family: var(--font-bold);
  color: var(--gold);
}

.board-controls label {
  color: var(--ink-dim);
}

.board-controls select {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  background: var(--stone-0);
  border: 1px solid var(--iron);
  padding: 0.2rem 0.4rem;
}

.conn {
  font-size: 0.85rem;
  color: var(--ink-dim);
  margin-right: 0.35rem;
  text-shadow: 1px 1px 0 #000;
}

.conn.ok { color: var(--hp-green); }
.conn.bad { color: var(--hp-red); }

.osrs-btn {
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  color: var(--ink);
  background: linear-gradient(180deg, var(--stone-4), var(--stone-3));
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  text-shadow: 1px 1px 0 #000;
}

.osrs-btn:hover {
  background: linear-gradient(180deg, var(--iron-lo), var(--stone-3));
  color: var(--gold);
}

.osrs-btn.primary {
  color: var(--gold);
}

.osrs-btn:active {
  border-color: var(--bevel-dark) var(--bevel-light) var(--bevel-light) var(--bevel-dark);
}

.workspace {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 3px solid var(--bevel-dark);
}

.panel-active {
  flex: 2;
}

.panel-done {
  border-bottom: none;
}

.panel-done:not([open]) {
  flex: 0 0 auto;
}

.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
}

.panel-toggle::-webkit-details-marker {
  display: none;
}

.panel-toggle:hover {
  color: var(--hp-yellow);
}

.panel-toggle:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.done-chevron {
  transition: transform 0.15s ease;
}

.panel-done[open] .done-chevron {
  transform: rotate(180deg);
}

.osrs-bar,
.panel-head {
  flex: 0 0 auto;
  padding: 0.25rem 0.85rem;
  font-family: var(--font-bold);
  font-size: 1rem;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
  background: linear-gradient(180deg, #2a2420, var(--stone-2));
  border-bottom: 2px solid var(--bevel-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel .board-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.04) 0 1px, transparent 1px 32px),
    var(--stone-1);
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  min-height: 100%;
  align-content: start;
  align-items: stretch;
}

.column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: linear-gradient(180deg, var(--stone-4), var(--stone-3));
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.column.standing-by {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, #2a3228, var(--stone-3));
  border-color: #5a7050 var(--bevel-dark) var(--bevel-dark) #5a7050;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
}

.column.standing-by .column-body {
  flex: 0 0 auto;
  flex-direction: row;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.column.standing-by .member {
  flex: 0 0 145px;
}

.column.standing-by .column-header {
  color: #a0c080;
}

.column.standing-by .column-title {
  flex: 1 1 auto;
}

.column.standing-by .column-count {
  margin-right: 0;
}

.column.state-idle {
  background: linear-gradient(180deg, var(--stone-3), var(--stone-2));
  border-color: var(--iron) var(--bevel-dark) var(--bevel-dark) var(--iron);
  opacity: 0.92;
}

.column.state-ongoing {
  background: linear-gradient(180deg, #3a3020, #2a2418);
  border-color: var(--gold) var(--gold-dim) var(--gold-dim) var(--gold);
  box-shadow: 0 0 12px rgba(255, 152, 31, 0.15);
}

.column.state-ongoing .column-header {
  color: var(--hp-yellow);
  text-shadow: 1px 1px 0 #000, 0 0 6px rgba(255, 255, 0, 0.25);
}

.column.state-ongoing.state-mine {
  background: linear-gradient(180deg, #243a20, #182a18);
  border-color: var(--hp-green) #168016 #168016 var(--hp-green);
}

.column.state-ongoing.state-mine .column-header {
  color: var(--hp-green);
  text-shadow: 1px 1px 0 #000, 0 0 6px rgba(0, 255, 0, 0.3);
}

.column.state-done {
  background: linear-gradient(180deg, #2a2040, #1a1428);
  border-color: var(--magic-hi) var(--magic) var(--magic) var(--magic-hi);
}

.column.state-done .column-header {
  color: #c0a0ff;
  text-shadow: 1px 1px 0 #000;
}

.column-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.45rem;
  min-height: 2rem;
  border-bottom: 2px solid var(--bevel-dark);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  text-shadow: 1px 1px 0 #000;
}

.column-title {
  flex: 1 0 100%;
  min-width: 0;
  font-family: var(--font-bold);
  font-size: 1.05rem;
  word-break: break-word;
}

.column-title input {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  background: var(--stone-0);
  border: 2px solid var(--gold);
  color: var(--ink);
  padding: 0.1rem 0.3rem;
}

.column-count {
  font-size: 0.85rem;
  color: var(--ink-dim);
  min-width: 1rem;
  margin-right: auto;
  text-align: right;
  text-shadow: 1px 1px 0 #000;
}

.column-delete,
.column-complete,
.column-reopen,
.column-info {
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  color: var(--ink-dim);
  background: var(--stone-2);
  border: 1px solid var(--iron-lo);
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}

.column-delete:hover {
  color: var(--hp-red);
  border-color: var(--hp-red);
}

.column-info:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.column-complete:hover {
  color: #c0a0ff;
  border-color: var(--magic-hi);
}

.column-reopen {
  color: #c0a0ff;
  border-color: var(--magic-hi);
}

.column-reopen:hover {
  background: var(--magic);
}

.column-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.35rem 0.45rem;
  border-bottom: 1px solid var(--bevel-dark);
  background: rgba(0, 0, 0, 0.12);
}

.tag-chip {
  padding: 0.08rem 0.35rem;
  border: 1px solid var(--iron-lo);
  color: var(--gold);
  background: var(--stone-2);
  font-size: 0.8rem;
  text-shadow: 1px 1px 0 #000;
}

.task-progress {
  display: grid;
  gap: 0.35rem;
  padding: 0.45rem;
  border-bottom: 1px solid var(--bevel-dark);
  background: rgba(0, 0, 0, 0.16);
}

.progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.progress-heading span {
  min-width: 0;
}

.task-progress progress {
  width: 100%;
  height: 0.85rem;
  accent-color: var(--gold);
}

.state-done .task-progress progress {
  accent-color: var(--magic-hi);
}

.progress-update.osrs-btn {
  flex-shrink: 0;
  padding: 0.1rem 0.45rem;
  font-size: 0.85rem;
}

.column-body {
  flex: 1;
  padding: 0.4rem;
  min-height: 90px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.column-body.read-only {
  min-height: 50px;
}

.column-body.drag-over {
  outline: 2px dashed var(--gold);
  outline-offset: -3px;
  background: rgba(255, 152, 31, 0.08);
}

.member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  background: var(--slot);
  border: 2px solid;
  border-color: var(--iron-lo) var(--bevel-dark) var(--bevel-dark) var(--iron-lo);
  cursor: grab;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.member:active {
  cursor: grabbing;
}

.member.self {
  border-color: var(--gold) var(--gold-dim) var(--gold-dim) var(--gold);
  background: #3a3020;
}

.member.dragging {
  opacity: 0.65;
  transform: scale(1.04) rotate(-1deg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.member-name {
  font-size: 1rem;
  color: var(--ink);
  text-shadow: 1px 1px 0 #000;
}

.member-remove {
  font-family: var(--font);
  padding: 0 0.35rem;
  font-size: 1.1rem;
  line-height: 1;
  border: 1px solid var(--iron-lo);
  background: var(--stone-2);
  color: var(--ink-dim);
  cursor: pointer;
  flex-shrink: 0;
}

.member-remove:hover {
  color: var(--hp-red);
}

.empty-col,
.empty-panel {
  padding: 0.75rem 0.4rem;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.9rem;
  text-shadow: 1px 1px 0 #000;
}

.empty-panel {
  padding: 1.25rem;
  grid-column: 1 / -1;
}

.osrs-dialog {
  border: none;
  padding: 0;
  max-width: 340px;
  width: calc(100% - 2rem);
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.osrs-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.osrs-dialog form,
.dialog-panel {
  background: linear-gradient(180deg, var(--stone-4), var(--stone-2));
  border: 2px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.dialog-bar {
  padding: 0.35rem 0.85rem;
  font-family: var(--font-bold);
  font-size: 1.05rem;
  color: var(--gold);
  text-shadow: 1px 1px 0 #000;
  background: linear-gradient(180deg, #2a2420, var(--stone-2));
  border-bottom: 2px solid var(--bevel-dark);
}

.dialog-body {
  padding: 0.85rem;
}

.osrs-dialog input {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.35rem 0.5rem;
  background: var(--stone-0);
  border: 2px solid var(--iron);
  color: var(--ink);
  text-shadow: 1px 1px 0 #000;
}

.osrs-dialog input:focus {
  outline: none;
  border-color: var(--gold);
}

.osrs-dialog input::placeholder {
  color: var(--ink-dim);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.dialog-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--ink-dim);
}

.dialog-hint {
  margin: 0.4rem 0 0;
  color: var(--ink-dim);
  font-size: 0.85rem;
}

.prompt-message {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
  color: var(--ink);
  text-shadow: 1px 1px 0 #000;
  word-break: break-word;
}

/* ── Animations ─────────────────────────────────────────────────────────── */

.column {
  transition:
    background 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    opacity 0.35s ease;
}

.column.state-ongoing {
  animation: ongoing-pulse 2.4s ease-in-out infinite;
}

.column.state-ongoing.state-mine {
  animation-name: mine-pulse;
}

.member {
  transition:
    transform 0.18s ease,
    border-color 0.25s ease,
    background 0.25s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.member.self:active {
  cursor: grabbing;
}

.member.self.dragging {
  opacity: 0.65;
  transform: scale(1.04) rotate(-1deg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.member:hover:not(.dragging) {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.column-body.drag-over {
  animation: drop-target 0.55s ease-in-out infinite;
}

.osrs-btn {
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    transform 0.08s ease;
}

.osrs-btn:hover {
  transform: translateY(-1px);
}

.osrs-btn:active {
  transform: translateY(1px);
}

.conn.ok {
  animation: live-pulse 2s ease-in-out infinite;
}

.conn.connecting {
  animation: blink 1s step-end infinite;
}

.conn.bad {
  animation: shake 0.45s ease;
}

.osrs-dialog[open] {
  animation: dialog-in 0.24s cubic-bezier(0.34, 1.35, 0.64, 1) both;
}

.osrs-dialog[open]::backdrop {
  animation: fade-in 0.2s ease both;
}

.anim-enter {
  animation: column-in 0.32s cubic-bezier(0.34, 1.25, 0.64, 1) both;
}

.anim-complete {
  animation: complete-drop 0.55s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

.anim-pop {
  animation: member-pop 0.38s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

.anim-slide {
  animation: member-slide 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes column-in {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes complete-drop {
  0% {
    opacity: 0;
    transform: translateY(-48px) scale(0.92);
    filter: brightness(1.8);
  }
  55% {
    opacity: 1;
    transform: translateY(6px) scale(1.02);
    filter: brightness(1.3);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes member-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes member-slide {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ongoing-pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 152, 31, 0.12);
  }
  50% {
    box-shadow: 0 0 18px rgba(255, 152, 31, 0.28);
  }
}

@keyframes mine-pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.14);
  }
  50% {
    box-shadow: 0 0 18px rgba(0, 255, 0, 0.3);
  }
}

@keyframes drop-target {
  0%, 100% {
    outline-color: var(--gold);
    background: rgba(255, 152, 31, 0.06);
  }
  50% {
    outline-color: var(--hp-yellow);
    background: rgba(255, 255, 0, 0.08);
  }
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 600px) {
  .header {
    flex-wrap: wrap;
  }

  .board {
    gap: 0.4rem;
    padding: 0.4rem;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  }

  .brand-logo {
    height: 36px;
    max-width: 55vw;
  }

  .tag {
    font-size: 0.85rem;
  }
}
