@font-face {
  font-family: KKPlex;
  src: url("fonts/IBMPlexMono-Medium.woff") format("woff");
  font-weight: 600;
  font-display: swap;
}

:root {
  /* UI kit scales (docs/reviews/kk-ui-audit-20261202/AUDIT.md): spacing, type and motion. */
  --kk-gap-1: 4px; --kk-gap-2: 6px; --kk-gap-3: 8px; --kk-gap-4: 12px; --kk-gap-5: 14px; --kk-gap-6: 24px;
  --kk-type-badge: 11px; --kk-type-meta: 12px; --kk-type-body: 14px; --kk-type-title: 16px; --kk-type-value: 22px;
  --kk-ease-pop: cubic-bezier(.34, 1.56, .64, 1); --kk-ease-out: cubic-bezier(.2, .8, .2, 1);
  --kk-ink: #182125;
  --kk-board: #203337;
  --kk-paper: #f4ead3;
  --kk-muted: #becac1;
  --kk-copper: #f2a271;
  --kk-red: #9c392c;
  --kk-blue: #24565d;
  --kk-lime: #d8ed62;
  --kk-cyan: #a1ece1;
  --kk-mono: KKPlex, "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--kk-ink);
  color: var(--kk-paper);
  font: 600 14px/1.4 var(--kk-mono);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
#game-container { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--kk-ink); }
#kk-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
:is(button, a, input, select):focus-visible { outline: 2px solid var(--kk-lime); outline-offset: 3px; }

/* Navigation uses the arcade shell's existing handlers and state. */
.arcade-web body[data-arcade=krazkraft] {
  --arcade-ink: var(--kk-ink);
  --arcade-accent: var(--kk-lime);
  --arcade-panel: var(--kk-board);
  --color-border-light: #637770;
  --color-text-primary: var(--kk-paper);
  --color-text-secondary: var(--kk-paper);
  --color-warning: #ffd09b;
  gap: 0;
  background: var(--kk-ink);
  font-family: var(--kk-mono);
}
.arcade-web [data-arcade=krazkraft] .arcade-toolbar {
  display: flex !important;
  flex-wrap: wrap;
  min-height: 0;
  padding: 2px clamp(5px, 1vw, 14px);
  gap: 0 7px;
  background: var(--kk-ink);
  border-bottom: 1px solid #526760;
}
.arcade-web [data-arcade=krazkraft] .arcade-toolbar :is(button, a, img) { border-radius: 0; box-shadow: none; font-family: inherit; }
.arcade-web [data-arcade=krazkraft] .arcade-toolbar :is(button, a) { width: auto; min-width: 38px; min-height: 32px; padding: 2px 9px; }
.arcade-web [data-arcade=krazkraft] .arcade-toolbar #kk-pause-btn { height: auto; }
.arcade-web [data-arcade=krazkraft] .arcade-toolbar #arcade-fullscreen[data-game-fullscreen] { min-height: 32px; }
.arcade-web [data-arcade=krazkraft] .arcade-back .kk-back-label { font-size: 12px; }
.arcade-web [data-arcade=krazkraft] .arcade-identity { flex: none; gap: 7px; }
.arcade-web [data-arcade=krazkraft] .arcade-tools { margin-left: auto; }
.arcade-web [data-arcade=krazkraft] .arcade-identity img { width: 28px; height: 28px; }
.arcade-web [data-arcade=krazkraft] .arcade-tools { width: auto; flex: none; gap: 5px; }
.arcade-web [data-arcade=krazkraft] #arcade-fullscreen { display: inline-flex; }
.arcade-web:fullscreen [data-arcade=krazkraft] #arcade-fullscreen { color: var(--kk-lime); border-color: var(--kk-lime); }
.arcade-web [data-arcade=krazkraft] #arcade-sound[aria-pressed="false"] { color: var(--kk-muted); background: var(--kk-ink); }
.arcade-web body[data-arcade=krazkraft] > #game-container { margin: 0; padding: 0; border: 0; border-radius: 0; }

/* Wide browser layouts share one rail. Narrow screens keep a full row for status. */
.arcade-toolbar > #kk-readouts { flex: 1; padding-inline: 5px; border-bottom: 0; }
.arcade-toolbar:has(> #kk-readouts:not([hidden])) { box-shadow: inset 0 -2px var(--kk-copper); }
.arcade-toolbar:has(> #kk-readouts[data-realm="1"]:not([hidden])) { box-shadow: inset 0 -2px var(--kk-cyan); }
@media (max-width: 1040px) {
  .arcade-toolbar > #kk-readouts {
    flex: 1 1 100%; order: 3; margin-top: 2px; padding-inline: 0;
    border-top: 1px solid #53665f;
  }
}

#kk-hud button, .kk-card button, #kk-tip button { touch-action: manipulation; }
#kk-hud { position: absolute; inset: 0 0 auto; z-index: 5; pointer-events: none; }
#kk-readouts {
  font-size: var(--kk-text, 14px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 0;
  padding: 3px clamp(5px, 1vw, 14px);
  background: var(--kk-ink);
  border-bottom: 2px solid var(--kk-copper);
  font-variant-numeric: tabular-nums;
}
#kk-readouts[data-realm="1"] { border-color: var(--kk-cyan); }
.kk-hud-group { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 6px; padding: 0 9px; border-left: 1px solid #53665f; }
.kk-hud-group:first-of-type, #kk-readouts[data-campaign="true"] :is(.kk-clock, .kk-memory) { border-left: 0; padding-left: 0; }
.kk-vitals { gap: 3px 10px; }
.kk-label { display: block; color: var(--kk-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .045em; }
.kk-integrity, .kk-mana { display: flex; align-items: center; gap: 6px; }
#kk-seals { color: var(--kk-lime); white-space: nowrap; letter-spacing: .07em; font-size: 14px; line-height: 1; }
#kk-mana { min-width: 14px; width: min(100%, 70px); height: 9px; flex: 1; appearance: none; accent-color: var(--kk-cyan); }
#kk-mana::-webkit-meter-bar { border: 0; border-radius: 0; background: #344b50; }
#kk-mana::-webkit-meter-optimum-value { background: var(--kk-cyan); }
#kk-mana::-moz-meter-bar { background: var(--kk-cyan); }
#kk-mana-value { font-size: 11px; }
#kk-clock { font-size: max(16px, 1em); line-height: 1.15; }
#kk-readouts[data-urgent="true"] #kk-clock { color: #ff9d87; }
.kk-memory > div { display: flex; flex-wrap: wrap; column-gap: 8px; }
.kk-memory > div span { white-space: nowrap; }
.kk-memory > div span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; background: currentColor; transform: rotate(45deg); vertical-align: 1px; }
#kk-folio-count, #kk-realm { color: var(--kk-copper); }
#kk-blueprint-count, #kk-readouts[data-realm="1"] #kk-realm { color: var(--kk-cyan); }
#kk-coach {
  width: fit-content;
  max-width: min(680px, calc(100% - 16px - var(--kk-coach-reserve, 0px)));
  margin: 7px auto 0;
  transform: translateX(calc(var(--kk-coach-reserve, 0px) / -2));
  padding: 6px 10px;
  background: var(--kk-ink);
  border-left: 3px solid var(--kk-lime);
  color: var(--kk-paper);
  font-size: 13px;
}
#kk-coach[data-alert="true"] { border-color: #ff9d87; }
#kk-sector-intro {
  position: absolute;
  z-index: 4;
  left: 8px;
  width: max-content;
  max-width: var(--intro-width, 45%);
  padding: 2px 8px;
  color: var(--kk-paper);
  background: linear-gradient(90deg, #12252bcc, transparent);
  border-left: 1px solid var(--kk-copper);
  text-shadow: 0 1px 4px #000, 0 1px 2px #000;
  pointer-events: none;
  overflow: hidden;
  transform: translateX(var(--intro-slide, 0px));
}
#kk-sector-intro strong { display: block; font-size: clamp(16px, 2.4vw, 26px); line-height: 1.1; overflow-wrap: anywhere; }
#kk-sector-intro span { display: block; font-size: 11px; line-height: 1.2; color: var(--kk-paper); }
@media (prefers-reduced-motion: reduce) {
  #kk-sector-intro { transform: none; }
}
@media (orientation: landscape) and (max-height: 480px) and (min-width: 620px) {
  .arcade-web [data-arcade=krazkraft] .arcade-toolbar { min-height: 0; padding-block: 0; }
  #kk-readouts { padding-block: 1px; }
  #kk-sector-intro:not([hidden]) { display: flex; align-items: baseline; gap: 8px; padding-block: 1px; }
  #kk-sector-intro strong { font-size: 16px; }
  #game-container:has(#kk-sector-intro:not([hidden])) #kk-coach { margin-top: 25px; }
}
#kk-pause-btn {
  position: relative;
  pointer-events: auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #637770;
  background: var(--kk-board);
  color: var(--kk-paper);
  cursor: pointer;
}
#kk-pause-btn::before { content: ""; display: block; width: 12px; height: 16px; margin: auto; border-inline: 4px solid currentColor; }
.arcade-web #kk-pause-btn { display: none; }

/* Menus and result cards use the same copper edge and casing. */
#kk-overlay { position: absolute; inset: 0; display: flex; padding: 12px; overflow: auto; overscroll-behavior: contain; background: #132023d9; z-index: 20; }
#kk-overlay.kk-campaign-closing[hidden] { display: flex !important; pointer-events: none; background: transparent; }
#kk-overlay.kk-campaign-closing #kk-campaign[hidden] { display: block !important; }
#kk-overlay[data-screen="title"] { background: #132023b8; }
.kk-card {
  --card-rule: #a89d83;
  width: min(100%, 530px);
  margin: auto;
  padding: clamp(14px, 3vw, 24px);
  background: var(--kk-paper);
  color: var(--kk-ink);
  border: 1px solid #a89d83;
  border-top: 4px solid var(--kk-copper);
  box-shadow: 6px 6px #111a1e;
}
.kk-card h1, .kk-card h2 { margin: 0; font-weight: 600; line-height: 1.1; letter-spacing: -.035em; }
.kk-card h1 { font-size: clamp(33px, 7vw, 65px); }
.kk-card h2 { font-size: clamp(27px, 6vw, 39px); }
.kk-title-lockup { display: flex; align-items: center; gap: 9px; }
.kk-title-lockup img { width: clamp(40px, 7vw, 55px); height: auto; flex: none; }
.kk-sub { margin: 3px 0 0; color: var(--kk-blue); font-size: 12px; letter-spacing: .055em; text-transform: uppercase; }
.kk-card p { margin: 10px 0; line-height: 1.5; }
#kk-title .kk-title-lockup .kk-sub { margin: 4px 0 0; font-size: 14px; font-weight: 600; letter-spacing: normal; text-transform: none; }
.kk-card button {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 8px 10px;
  border: 2px solid var(--kk-ink);
  border-radius: 0;
  color: var(--kk-paper);
  background: var(--kk-ink);
  font: inherit;
  cursor: pointer;
}
.kk-card button[data-primary]:not(.kk-card-btn) { color: var(--kk-ink); background: var(--kk-lime); }
.kk-card .kk-quiet { color: var(--kk-ink); background: transparent; }
.kk-card button:hover { color: white; background: var(--kk-red); border-color: var(--kk-red); }
.kk-card button[data-primary]:not(.kk-card-btn):hover { color: var(--kk-paper); background: var(--kk-ink); }
.kk-card :is(button, a, input, select):focus-visible,
[data-kk-input="pad"] .kk-card :is(button, a, input, select):focus {
  outline: 2px solid var(--kk-red);
  outline-offset: 2px;
}
.kk-rule { height: 1px; margin: 10px 0; background: var(--card-rule); }
#kk-title { padding: 0; width: min(100%, 810px); display: grid; grid-template-columns: minmax(220px, 1fr) minmax(305px, 1.18fr); }
.kk-title-art { position: relative; overflow: hidden; min-height: 365px; background: #1b3439; }
#kk-cover {
  position: absolute;
  inset: 0 auto 0 50%;
  width: 190.48%;
  height: 100%;
  transform: translateX(-50%);
  object-fit: cover;
  object-position: 50% 48%;
}
.kk-title-body { min-width: 0; padding: clamp(14px, 3vw, 26px); align-self: center; }
.kk-title-actions, .kk-end-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kk-title-primary-actions { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
@media (min-width: 620px) {
  .kk-title-primary-actions { column-gap: 12px; }
}
.kk-title-actions button { padding-inline: 6px; line-height: 1.25; }
.kk-arcade-options { margin: 12px 0 8px; padding-top: 12px; border-top: 1px solid var(--card-rule); }
.kk-hero-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 7px 0 10px;
  padding: 4px 8px;
  border-left: 2px solid var(--kk-blue);
  background: rgba(25, 70, 84, .08);
  font-size: .93em;
}
.kk-hero-summary span { color: var(--kk-blue); font-weight: 700; }
.kk-hero-summary #kk-hero-skills { min-width: 0; margin: 0; font-size: inherit; line-height: 1.35; }
#kk-how { margin: 12px 0 0; padding-top: 7px; border-top: 1px solid var(--card-rule); font-size: 13px; }
#kk-how-device { display: flex; gap: 5px; margin: 0; padding: 0; border: 0; }
#kk-how-device legend { margin-bottom: 4px; padding: 0; }
#kk-how-device label { display: grid; flex: 1; cursor: pointer; }
#kk-how-device input { grid-area: 1 / 1; width: 1px; height: 1px; opacity: 0; }
#kk-how-device label span { grid-area: 1 / 1; display: grid; place-items: center; min-height: 44px; border: 2px solid var(--kk-ink); }
#kk-how-device label:hover span { color: var(--kk-paper); background: var(--kk-red); }
#kk-how-device input:checked + span { color: var(--kk-paper); background: var(--kk-blue); }
#kk-how-device input:focus-visible + span,
[data-kk-input="pad"] #kk-how-device input:focus + span { outline: 2px solid var(--kk-red); outline-offset: 2px; }
#kk-how dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0; }
#kk-how dt { color: var(--kk-red); }
#kk-how dd { margin: 0; }
#kk-ledger { border-top: 1px solid var(--card-rule); margin-top: 12px; padding-top: 6px; font-size: 12px; }
#kk-ledger ol { margin: 4px 0 0; padding-left: 2.3em; }
#kk-ledger .kk-ledger-head { margin: 0; }
.kk-field { display: flex; align-items: center; gap: 9px; min-height: 44px; margin: 8px 0; }
.kk-field input { flex: 1; min-width: 0; height: 44px; accent-color: var(--kk-blue); }
.kk-field output { min-width: 4ch; text-align: right; }
#kk-pause > button + button { margin-top: 7px; }
.kk-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; margin: 8px 0 12px; }
/* Kit: "on" is lime everywhere. Every toggle keeps a check box in its label, so turning it on never moves the text. */
.kk-settings button[aria-pressed="true"]:not(:hover) { color: var(--kk-ink); background: var(--kk-lime); }
.kk-settings button[aria-pressed]::before {
  content: ""; display: inline-grid; place-content: center; width: 1.05em; height: 1.05em; margin-inline-end: .45em;
  vertical-align: -.15em; border: 2px solid currentColor; font-size: .95em; line-height: 1;
}
.kk-settings button[aria-pressed="true"]::before { content: "✓"; }
#kk-practice-status { color: var(--kk-blue); }
.kk-card table { width: 100%; border-collapse: collapse; margin: 7px 0; font-size: 13px; }
.kk-card th { text-align: left; font-weight: 600; padding: 3px 0; }
.kk-card td { text-align: right; padding: 3px 0 3px 7px; }
.kk-card tr + tr { border-top: 1px dotted var(--card-rule); }
#kk-upgrade-list { display: grid; gap: 6px; }
.kk-card .kk-card-btn { text-align: left; }
.kk-card-btn strong, .kk-card-btn span { display: block; }
.kk-card-btn span { margin-top: 1px; font-size: 12px; }
#kk-end[data-won="1"] { border-top-color: var(--kk-blue); }
#kk-end[data-won="1"] h2 { color: var(--kk-blue); }
#kk-end[data-won="0"] h2 { color: var(--kk-red); }
.kk-end-score-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kk-end-score-line .kk-label { color: var(--kk-blue); }
#kk-end-score { font-size: clamp(29px, 7vw, 42px); line-height: 1.1; }
#kk-end-best { font-size: 12px; }
.kk-stamp { color: var(--kk-red); border: 1px solid currentColor; padding: 3px 8px; }
#kk-end-kredits-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 9px; color: var(--kk-ink); background: var(--kk-lime); border-left: 3px solid var(--kk-blue); }
#kk-hof { display: inline-flex; align-items: center; min-height: 44px; color: var(--kk-blue); font-size: 13px; }

#kk-touch-stack { display: contents; }
html[data-kk-input="touch"] #kk-touch-stack:has(#kk-touch:not([hidden])) {
  position: absolute; right: var(--kk-actions-right, max(12px, env(safe-area-inset-right)));
  bottom: var(--kk-actions-bottom, max(12px, env(safe-area-inset-bottom)));
  left: 12px; z-index: 10; display: flex; flex-direction: column; align-items: flex-end;
  gap: 6px; pointer-events: none;
}
#kk-touch { display: none; gap: 9px; pointer-events: auto; }
html[data-kk-input="touch"] #kk-touch { display: flex; }
#kk-touch button {
  width: 74px;
  height: 54px;
  padding: 4px;
  border: 2px solid var(--kk-ink);
  border-radius: 0;
  box-shadow: 2px 2px var(--kk-ink);
  color: var(--kk-ink);
  background: var(--kk-paper);
  font: inherit;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
}
#kk-touch small { display: block; font-size: 10px; }
#kk-touch #kk-flip { background: var(--kk-lime); }
#kk-touch #kk-shard[data-low="true"] { color: var(--kk-paper); background: #425453; }
#kk-touch button:active { box-shadow: inset 0 0 0 2px currentColor; }
@media (pointer: coarse) { html:not([data-kk-input="pad"]):not([data-kk-input="keys"]) #kk-touch { display: flex; } }
#kk-touch button { min-width: 54px; }

@media (max-width: 620px) {
  #kk-title { display: block; max-width: 440px; }
  .kk-title-art { min-height: 0; height: clamp(112px, 24dvh, 200px); }

  .kk-hud-group { gap: 2px 4px; padding-inline: 5px; }
  .kk-vitals { gap: 3px 8px; }
  .kk-memory > div { column-gap: 5px; }
  .kk-memory > div span::before { width: 6px; height: 6px; margin-right: 3px; }
  .arcade-web [data-arcade=krazkraft] .arcade-back .kk-back-label { display: none; }
  .arcade-web [data-arcade=krazkraft] .arcade-toolbar button { padding: 6px; }
  .arcade-web [data-arcade=krazkraft] #arcade-fullscreen { font-size: 0; }
  .arcade-web [data-arcade=krazkraft] #arcade-fullscreen::before { content: ""; width: 14px; height: 14px; border: 2px dashed currentColor; }
  .arcade-web [data-arcade=krazkraft] #arcade-sound { font-size: 0; }
  .arcade-web [data-arcade=krazkraft] #arcade-sound::before { content: "Sound"; font-size: 11px; }
  .arcade-web [data-arcade=krazkraft] #arcade-sound[aria-pressed="false"]::before { text-decoration: line-through; }
  .arcade-web [data-arcade=krazkraft] .arcade-wallet { padding-inline: 5px; }
  .arcade-web [data-arcade=krazkraft] .arcade-tools { margin-inline-start: auto; }
}

@media (max-width: 440px) {
  .arcade-web [data-arcade=krazkraft] .arcade-identity strong { display: none; }
}

@media (max-height: 700px) and (max-width: 620px) and (orientation: portrait),
       (max-height: 460px) and (orientation: landscape) {
  html:not([data-kk-ui-scale="110"], [data-kk-ui-scale="125"]) #kk-title { --kk-touch-control: 44px; }
  .kk-title-body { padding: 8px 12px; }
  .kk-title-body > p { margin: 6px 0; }
  .kk-title-body .kk-arcade-options { margin: 6px 0; padding-top: 6px; }
  .kk-hero-summary { margin-block: 5px 7px; }
  .arcade-web #kk-home-title { display: none; }
}

@media (max-height: 700px) and (max-width: 620px) and (orientation: portrait) {
  .kk-title-art { height: clamp(80px, 17dvh, 120px); }
}

@media (max-height: 460px) and (orientation: landscape) {
  #kk-overlay #kk-title {
    --kk-cover-column: max(110px, 33%);
    position: relative;
    display: grid;
    max-width: 690px;
    grid-template-columns: var(--kk-cover-column) minmax(0, 1fr);
  }
  #kk-title .kk-title-art { height: auto; min-height: 0; }
  #kk-title .kk-title-body { padding: 8px 12px; }
  .kk-title-lockup { margin-bottom: 6px; }
  #kk-title .kk-title-lockup h1 { font-size: clamp(25px, 5dvh, 36px); }
  .kk-title-lockup img { width: 32px; }
  #kk-title .kk-title-lockup .kk-sub { font-size: 12px; }
  .kk-title-body > p:first-of-type { display: none; }
}

@media (max-height: 330px) and (orientation: landscape) {
  #kk-overlay[data-screen="title"] { padding-block: 4px; }
  #kk-title .kk-title-body { padding-block: 4px; }
  .kk-title-lockup { margin-bottom: 3px; }
  #kk-title .kk-title-lockup .kk-sub { margin-top: 2px; font-size: 11px; }
  .kk-title-body .kk-arcade-options { margin-block: 4px; padding-top: 4px; }
  .kk-hero-summary { margin-block: 2px 4px; padding-block: 0; }
}

@media (max-width: 374px) {
  #kk-mana-value { display: none; }
}

@media (max-height: 520px) and (min-width: 621px) {
  #kk-title { max-width: 690px; grid-template-columns: 1fr 1.35fr; }
  .kk-title-art { min-height: 0; }
  .kk-title-body { padding: 12px 16px; }
  .kk-card h1 { font-size: 45px; }
  .kk-card:not(#kk-title) { padding: 11px 15px; }
  #kk-upgrade { width: min(100%, 710px); }
  #kk-upgrade-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #kk-end { width: min(100%, 680px); display: grid; grid-template-columns: .9fr 1.1fr; column-gap: 18px; }
  #kk-end h2, #kk-end-cause, #kk-end .kk-end-score-line, #kk-end-kredits-row, #kk-hof { grid-column: 1; }
  #kk-end .kk-rule { display: none; }
  #kk-end-stats { grid-column: 2; grid-row: 1 / span 3; }
  #kk-end .kk-end-actions { grid-column: 2; }
}

.kk-hero-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px; }
.kk-hero-field select, .kk-field select { padding: 6px 8px; font: inherit; color: var(--kk-ink); background: var(--kk-paper); }
.kk-hero-field select { min-height: 44px; border: 2px solid var(--kk-ink); border-radius: 0; }
#kk-skill { background: #dba8ea; }
#kk-touch #kk-ammo, #kk-touch #kk-roll { background: #a7de9a; }
#kk-touch:has(#kk-ammo:not([hidden])) { flex-wrap: wrap; justify-content: flex-end; max-width: min(88%, 312px); }
@media (max-width: 500px) {
  #kk-touch:has(#kk-ammo:not([hidden])) { max-width: 245px; }
}
#kk-touch button:disabled { opacity: .65; }

#kk-campaign { width: min(100%, 580px); }
.kk-panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 9px; }
.kk-panel-head h2 { min-inline-size: 0; overflow-wrap: anywhere; }
/* Kit: Skip voice is a quiet text action, so Close stays the one clear button in the header. */
#kk-campaign #kk-dialog-skip, #kk-campaign .kk-skip-voice {
  min-width: 0; padding-inline: 6px; border-color: transparent; background: transparent; color: var(--kk-blue);
  font-size: 12px; text-decoration: underline; text-underline-offset: 3px;
}
#kk-campaign #kk-dialog-skip:hover, #kk-campaign .kk-skip-voice:hover { border-color: var(--kk-red); }
#kk-campaign .kk-panel-head #kk-dialog-skip { margin-inline-start: auto; }
#kk-characters .kk-panel-head { align-items: center; }
#kk-characters .kk-panel-head button { width: auto; flex: none; }
#kk-character-list { display: grid; gap: 8px; margin-top: 12px; }
#kk-new-hero { margin-top: 8px; }
#kk-character-list button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 70px;
  padding: 6px 8px;
  text-align: left;
}
#kk-character-list canvas {
  width: 44px;
  height: 44px;
  background: linear-gradient(145deg, #f4e8c6, #bcb090);
  border: 1px solid #8a765c;
}
#kk-character-list strong, #kk-character-list span span { display: block; }
#kk-character-list span span { font-size: 12px; }
.kk-character-action { font-size: 12px; font-weight: 700; white-space: nowrap; }
#kk-character-list button:focus-visible { outline-offset: 1px; }
@media (min-width: 620px), (orientation: landscape) and (min-width: 550px) {
  #kk-characters { width: min(100%, 810px); }
  #kk-character-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 355px) {
  #kk-character-list button { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 6px; }
  #kk-character-list canvas { width: 36px; height: 36px; }
}
#kk-campaign-nav, .kk-item-actions { display: flex; flex-wrap: wrap; gap: 5px; }
#kk-campaign-nav { margin: 10px 0; padding-bottom: 10px; border-bottom: 1px solid var(--card-rule); }
#kk-campaign-nav:empty { display: none; }
#kk-campaign-nav button[aria-current] { background: var(--kk-lime); }
.kk-town-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kk-town-actions small { flex-basis: 100%; }
#kk-campaign .kk-town-actions button, #kk-campaign-nav button { min-height: 44px; }
#kk-campaign .kk-town-actions button { text-align: start; }
#kk-campaign button:not(:disabled):active { box-shadow: inset 0 0 0 2px currentColor; }
#kk-campaign button { width: auto; min-height: 34px; padding: 6px 9px; }
#kk-campaign:has(#kk-party-live) button,
#kk-campaign-body:has(#kk-party-live) input,
#kk-campaign .kk-panel-head button { min-height: 44px; }
#kk-campaign-body:has(#kk-party-live) > input {
  max-width: 100%;
  margin: 3px 5px 3px 0;
  padding: 6px 9px;
  border: 2px solid var(--kk-ink);
  border-radius: 0;
  color: var(--kk-ink);
  background: var(--kk-paper);
  font: inherit;
}
#kk-campaign .kk-panel-head button { min-width: 65px; flex: none; }
#kk-campaign button[aria-pressed="true"] { background: var(--kk-lime); }
#kk-campaign button:disabled { opacity: .48; cursor: default; }
#kk-campaign button[data-locked]:disabled { opacity: .62; color: #b9b0a3; white-space: normal; }
#kk-campaign button[data-locked]::before {
  content: ""; display: inline-block; width: 10px; height: 12px; margin-right: 7px; vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M2.5 6V3.6a2.5 2.5 0 0 1 5 0V6' fill='none' stroke='%23221c22' stroke-width='2.6'/%3E%3Cpath d='M2.5 6V3.6a2.5 2.5 0 0 1 5 0V6' fill='none' stroke='%23c9cfd0' stroke-width='1.3'/%3E%3Crect x='.5' y='5.5' width='9' height='6' fill='%23e2b457' stroke='%23221c22'/%3E%3Crect x='4.4' y='7.3' width='1.2' height='2.4' fill='%23221c22'/%3E%3C/svg%3E") no-repeat center / contain;
}
#kk-campaign h3 { margin: 14px 0 7px; }
#kk-campaign small { display: block; line-height: 1.45; }
#kk-campaign-body > button { margin: 3px 5px 3px 0; }
#kk-campaign-status { border-top: 1px solid var(--card-rule); padding-top: 7px; }
.kk-item { margin: 6px 0; padding: 7px; border: 1px solid var(--card-rule); }
.kk-item-actions { margin-top: 4px; }

#kk-readouts[data-campaign="true"] .kk-clock { display: none; }

#kk-readouts[data-town="true"] .kk-memory { display: none; }
#kk-touch button { display: grid; place-content: center; min-height: 54px; height: auto; line-height: 1.1; }
#kk-touch :is(#kk-shard, #kk-skill) { width: max-content; min-width: 74px; max-width: 117px; }
#kk-touch button span { overflow-wrap: anywhere; text-wrap: balance; }
.kk-story-transcript { max-width: 60ch; padding: 0 0 6px; }
.kk-story-transcript p { line-height: 1.65; }


#kk-help { width: min(100%, 580px); }
#kk-help button { width: auto; min-height: 34px; padding: 6px 10px; }
#kk-help-devices, #kk-help-links { display: flex; flex-wrap: wrap; gap: 5px; }
#kk-help-links:not(:empty) { margin-top: 7px; }
#kk-help-devices button { background: transparent; color: var(--kk-ink); }
#kk-help-devices button[aria-pressed="true"] { background: var(--kk-lime); }
#kk-help-controls { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin-block: 12px; font-size: 13px; }
#kk-help-controls dt { font-weight: 700; }
#kk-help-controls dd { margin: 0; }
#kk-world-use, #kk-tour-marker {
  position: absolute; z-index: 6; width: 44px; height: 44px; transform: translate(-50%, -50%);
}
#kk-world-use {
  border: 1px solid transparent; border-radius: 50%; padding: 0; background: transparent;
  color: var(--kk-paper); font: 600 13px/1.2 KKPlex, monospace; cursor: pointer; touch-action: manipulation;
}
#kk-world-use:hover, #kk-world-use:focus-visible {
  border-color: var(--kk-lime); box-shadow: 0 0 8px #d3ee8a80; outline: none;
}
#kk-world-use span, #kk-world-use kbd {
  position: absolute; inset-inline-start: calc(50% + var(--kk-prompt-shift, 0px)); translate: -50% 0;
  white-space: nowrap; background: linear-gradient(#45343a, var(--kk-ink) 65%); border: 1px solid #a87959;
  border-radius: 4px; box-shadow: inset 0 1px #eed7a054, 0 2px 0 #19162080;
}
#kk-world-use span { bottom: calc(100% + 13px); padding: 4px 7px; }
#kk-world-use kbd { bottom: calc(100% - 3px); padding: 1px 6px; color: var(--kk-lime); font: inherit; }
#kk-world-use[data-below="true"] span { bottom: auto; top: calc(100% + 13px); }
#kk-world-use[data-below="true"] kbd { bottom: auto; top: calc(100% - 3px); }
#kk-world-use:hover span, #kk-world-use:focus-visible span { border-color: var(--kk-lime); }
/* Locked places (js/locks.js): dimmed plate with a padlock and the reason, wrapping instead of running off a phone. */
#kk-world-use[data-locked] span {
  white-space: normal; width: max-content; max-width: min(230px, calc(100vw - 24px)); text-align: center;
  color: #d8cdbd; border-color: #8d8478; background: linear-gradient(#3a353b, #26222a 65%);
}
#kk-world-use[data-locked] span::before {
  content: ""; display: inline-block; width: 10px; height: 12px; margin-right: 6px; vertical-align: -1px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M2.5 6V3.6a2.5 2.5 0 0 1 5 0V6' fill='none' stroke='%23221c22' stroke-width='2.6'/%3E%3Cpath d='M2.5 6V3.6a2.5 2.5 0 0 1 5 0V6' fill='none' stroke='%23c9cfd0' stroke-width='1.3'/%3E%3Crect x='.5' y='5.5' width='9' height='6' fill='%23e2b457' stroke='%23221c22'/%3E%3Crect x='4.4' y='7.3' width='1.2' height='2.4' fill='%23221c22'/%3E%3C/svg%3E") no-repeat center / contain;
}
#kk-world-use[data-locked]:hover span { border-color: #c9bfa9; }
#kk-tour-marker { pointer-events: none; border: 2px solid var(--kk-lime); border-radius: 50%; }
#kk-tour-marker::before {
  content: ""; position: absolute; top: -10px; left: 50%; translate: -50% 0;
  border: 7px solid transparent; border-top-color: var(--kk-lime);
}
#kk-tip {
  position: absolute; z-index: 7; bottom: 14px; left: 12px;
  max-width: min(440px, calc(100% - 24px)); display: flex; align-items: center; gap: 6px;
  background: var(--kk-ink); border-left: 3px solid var(--kk-lime); padding: 4px 6px 4px 9px; font-size: 13px;
}
#kk-tip-content { min-width: 0; overflow-wrap: anywhere; }
#kk-tip-key {
  display: inline-block; margin-inline-end: 6px; padding: 1px 5px;
  border: 1px solid var(--kk-muted); border-radius: 3px; color: var(--kk-lime); font: 600 12px KKPlex, monospace;
}
#game-container button[data-kk-discover] {
  outline: 1px solid var(--kk-lime); outline-offset: 2px; box-shadow: 0 0 10px #d3ee8a99;
}
#kk-control-hints-status:empty { display: none; }
#kk-tip button {
  flex: none; min-height: 34px; border: 1px solid var(--kk-muted); background: transparent;
  color: var(--kk-paper); font: inherit; cursor: pointer;
}
#kk-tip-close { min-width: 34px; }
#kk-tip button:hover, #kk-tip button:focus-visible { color: var(--kk-lime); }
.kk-item-hint { font-size: 13px; }
.kk-drop-zone { min-width: 0; padding: 4px 7px 7px; border: 1px dashed var(--card-rule); margin-block: 6px; }
.kk-drop-zone.kk-drop-ready { border-color: #52681c; background: #d9e3b1; }
#kk-campaign .kk-drop-zone h3 { margin-top: 4px; }
#kk-campaign [draggable="true"] { cursor: grab; }
#kk-campaign [draggable="true"]:active { cursor: grabbing; }
.kk-ingredient-tray p:empty { display: none; }
html[data-kk-input="touch"] #kk-touch-stack:has(#kk-touch:not([hidden])) #kk-tip {
  position: static; align-self: flex-start; max-width: 100%; pointer-events: auto;
}
@media (max-width: 620px) {
  #kk-help-controls { grid-template-columns: minmax(90px, 1fr) minmax(0, 1.8fr); }
}
#kk-campaign:is([data-panel="vendor"], [data-panel="stash"]) { width: min(100%, 780px); }
.kk-inventory-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.kk-inventory-section { min-width: 0; }
.kk-item-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
  padding: 5px;
  background: #172226;
  border: 1px solid #60645b;
}
#kk-campaign .kk-item-cell, #kk-campaign .kk-check-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  min-width: 0;
  width: 100%;
  aspect-ratio: 1.06;
  padding: 1px;
  border: 1px solid var(--item-color, #53605a);
  background: linear-gradient(145deg, #334044, #1a272b);
  color: #f4e6c8;
  touch-action: manipulation;
  user-select: none;
  -webkit-touch-callout: none;
}
#kk-campaign .kk-item-cell.kk-empty-cell { background: #1c272c; }
#kk-campaign .kk-item-cell:is(:hover, :focus-visible, .kk-drop-cell, [aria-pressed="true"]),
#kk-campaign .kk-check-cell:is(:hover, :has(input:checked), :has(input:focus-visible)) {
  border-color: #feedad;
  background: #47514b;
  box-shadow: inset 0 0 0 1px #d8bd7d;
}
.kk-item-cell.kk-empty-cell .kk-grid-icon { opacity: .42; }
#kk-campaign[data-panel="pack"] .kk-item-grid .kk-item-cell { max-height: 58px; }
.kk-grid-icon { display: block; width: min(100%, 46px); height: auto; pointer-events: none; }
.kk-cell-price, .kk-broken-mark {
  position: absolute;
  bottom: 1px;
  right: 2px;
  padding: 0 2px;
  background: #1e2224;
  color: #fff0ac;
  font: 700 11px/1.15 monospace;
}
.kk-broken-mark { right: auto; left: 2px; color: #ffc2ad; }
.kk-check-cell input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.kk-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.kk-paper-doll {
  display: grid;
  grid-template-areas: 'head head hero amulet amulet' 'weapon weapon hero offhand offhand'
    'gloves gloves hero body body' 'ring belt hero boots ring2';
  grid-template-columns: minmax(38px, 1fr) minmax(38px, 1fr) minmax(76px, 2fr) minmax(38px, 1fr) minmax(38px, 1fr);
  gap: 5px;
  padding: 9px;
  background: radial-gradient(ellipse at 50% 43%, #3c4f47, #1b272a 77%);
  border: 1px solid #60645b;
}
#kk-campaign .kk-paper-doll .kk-item-cell { aspect-ratio: auto; min-height: 52px; }
.kk-paper-doll [data-slot="helm"] { grid-area: head; }
.kk-paper-doll [data-slot="amulet"] { grid-area: amulet; }
.kk-paper-doll [data-slot="armor"] { grid-area: body; }
.kk-paper-doll [data-slot="weapon"] { grid-area: weapon; }
.kk-paper-doll [data-slot="offhand"] { grid-area: offhand; }
.kk-paper-doll [data-slot="gloves"] { grid-area: gloves; }
.kk-paper-doll [data-slot="belt"] { grid-area: belt; }
.kk-paper-doll [data-slot="boots"] { grid-area: boots; }
.kk-paper-doll [data-slot="ring"] { grid-area: ring; }
.kk-paper-doll [data-slot="ring2"] { grid-area: ring2; }
.kk-doll-hero {
  grid-area: hero;
  margin: 0;
  align-self: center;
  justify-self: center;
  text-align: center;
  color: #f6e4ba;
  font-weight: 700;
}
.kk-hero-portrait { display: block; width: 100%; max-width: 155px; height: auto; }
.kk-cell-caption { font-size: 10px; font-weight: 600; line-height: 1.1; margin-bottom: 3px; }
.kk-shopkeeper, .kk-repair-bench, .kk-expedition-charms span { display: flex; align-items: center; gap: 9px; }
.kk-shopkeeper { padding: 7px; border: 1px solid var(--card-rule); }
.kk-shopkeeper p { margin: 4px 0; }
.kk-shop-portrait { background: #283735; width: 78px; height: 78px; flex: none; }
.kk-shop-coins { font-weight: 700; }
/* Owner 2 Dec: selling never moves the shop. The keeper's line keeps a two-line box whether or not anything was said,
   and the status row keeps one line while empty, so a sale's message cannot grow or re-centre the card. */
.kk-shopkeeper p.kk-shop-line {
  height: 3em; line-height: 1.5; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
#kk-campaign:is([data-panel="vendor"], [data-panel="stash"]) #kk-campaign-status {
  display: block; height: calc(1.5em + 8px); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* The global [hidden] rule is !important, so the reserved row has to be too. */
#kk-campaign:is([data-panel="vendor"], [data-panel="stash"]) #kk-campaign-status[hidden] { display: block !important; visibility: hidden; }
@media (max-width: 650px) {
  /* A phone keeps two lines, so a long item name still reads in full. */
  #kk-campaign:is([data-panel="vendor"], [data-panel="stash"]) #kk-campaign-status {
    height: calc(3em + 8px); white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
  #kk-campaign:is([data-panel="vendor"], [data-panel="stash"]) #kk-campaign-status[hidden] { display: -webkit-box !important; }
}
.kk-repair-bench { margin-top: 10px; }
#kk-campaign .kk-repair-bench .kk-item-cell { max-width: 58px; }
.kk-repair-bench .kk-grid-icon { width: 34px; }
.kk-chest-icon { width: 48px; height: 38px; margin-inline-end: 6px; vertical-align: middle; }
.kk-chest-grid .kk-item-grid { max-height: 354px; overflow-y: auto; grid-auto-rows: minmax(45px, max-content); }
.kk-expedition-charms .kk-grid-icon { width: 24px; }
.kk-item-tooltip, .kk-item-inspector {
  box-sizing: border-box;
  padding: 10px 12px;
  color: #fcf5df;
  background: #18272b;
  border: 1px solid #b3a176;
  box-shadow: 0 4px 14px #0c1417aa;
  text-align: start;
  overflow-wrap: anywhere;
}
.kk-item-tooltip {
  position: fixed; z-index: 6; width: min(450px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
  overflow: auto; pointer-events: none;
}
.kk-item-inspector { position: sticky; z-index: 1; bottom: 0; margin-top: 8px; }
.kk-card table.kk-item-values {
  width: 100%; table-layout: fixed; margin: 0;
  color: inherit; font-size: max(14px, var(--kk-text, 14px)); line-height: 1.25;
}
.kk-item-values .kk-item-identity { width: 34%; vertical-align: middle; }
.kk-item-identity .kk-grid-icon { width: 44px; max-width: 100%; }
.kk-card .kk-item-values :is(th, td) { padding: 5px 4px; text-align: start; }
.kk-item-values thead th { vertical-align: top; }
.kk-item-values thead th:last-child:not(:nth-child(2)) { border-left: 1px solid #55635d; }
.kk-item-heading { display: grid; gap: 3px; }
.kk-item-heading .kk-grid-name { font-size: max(16px, 1.12 * var(--kk-text, 14px)); line-height: 1.15; }
.kk-item-kicker, .kk-item-tier { color: #e5d5ad; font-size: 12px; font-weight: 600; }
.kk-item-kicker { text-transform: uppercase; letter-spacing: .055em; }
.kk-item-tier { text-transform: capitalize; }
.kk-item-limit { color: #ffe18e; font-size: 13px; }
.kk-item-unmet { color: #ff8f80; }
.kk-item-values tbody tr { border-top: 1px solid #42524e; }
.kk-item-values tbody tr:nth-child(odd) { background: #ffffff08; }
.kk-item-values tbody td { font-variant-numeric: tabular-nums; font-weight: 700; }
.kk-item-symbol { display: inline-block; min-width: 1.35em; color: #e9c77d; }
.kk-item-values :is(.kk-gain, .kk-loss) { display: inline-block; margin-inline-start: .4em; font-size: .9em; }
.kk-item-note { border-top: 1px solid #55635d; padding: 6px 4px 1px; margin-top: 4px; font-size: 14px; line-height: 1.35; }
.kk-item-inspector .kk-item-actions { padding-top: 6px; }
.kk-grid-price { color: #fff0ac; }
#kk-campaign .kk-item-inspector button { color: var(--kk-ink); background: var(--kk-paper); }
#kk-campaign .kk-item-inspector button:hover { color: white; background: var(--kk-red); }
#kk-campaign .kk-item-inspector button:disabled:hover { color: var(--kk-ink); background: var(--kk-paper); }
/* A refused belt or gear change (the pack would not fit) shows its reason right above the disabled button. */
.kk-item-inspector .kk-item-refusal { color: #ffd9a0; font-weight: 600; overflow-wrap: break-word; }
.kk-combine-items { margin-bottom: 8px; }
@media (max-width: 650px) {
  .kk-inventory-columns { gap: 6px; }
  .kk-inventory-columns .kk-item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kk-chest-grid .kk-item-grid { max-height: 270px; }
  .kk-item-grid { gap: 2px; }
  #kk-campaign-nav:not(:empty) {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    margin-block: 8px;
  }
  #kk-campaign-nav button { padding-inline: 4px; }
  .kk-paper-doll { gap: 3px; padding: 5px; }
  .kk-paper-doll .kk-grid-icon { width: min(100%, 34px); }
}
@media (max-width: 355px) {
  #kk-campaign-nav:not(:empty) {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
#kk-campaign input:not([type=checkbox]) { border: 1px solid var(--card-rule); padding: 6px; font: inherit; max-width: 100%; }

/* The drawer lives below the status rail and above the touch actions. */
#kk-social { display: grid; justify-items: end; gap: 6px; margin: 6px 8px 0; }
#kk-social:has(> #kk-social-panel[hidden]) { display: none; }
#kk-social :is(button, input, select) {
  min-height: 32px;
  border: 1px solid #81978a;
  border-radius: 0;
  background: var(--kk-ink);
  color: var(--kk-paper);
  padding: 4px 8px;
  font: inherit;
}
#kk-social button { cursor: pointer; }
#kk-social button[aria-pressed="true"] { border-color: var(--kk-lime); color: var(--kk-lime); }
#kk-social-panel { pointer-events: auto; }
#kk-social-panel {
  width: min(100%, 390px);
  padding: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--kk-board);
  color: var(--kk-paper);
  border: 1px solid var(--kk-copper);
  box-shadow: 2px 2px 0 var(--kk-ink);
  scrollbar-color: #81978a var(--kk-ink);
  font-size: 13px;
}
#kk-social-panel :is(h3, p) { margin: 4px 0; }
#kk-social-panel h3 { font-size: 13px; color: var(--kk-cyan); }
#kk-social-panel[data-quick] #kk-social-messages { display: none; }
#kk-social-speech {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
#kk-social-speech > div {
  position: absolute;
  width: max-content;
  max-width: min(224px, calc(100% - 16px));
  padding: 5px 9px;
  border: 1px solid #b7dadd;
  border-radius: 7px;
  background: #142527f5;
  box-shadow: 0 2px 4px #071416b3;
  color: #fff4d9;
  font: 13px/1.25 system-ui, sans-serif;
  overflow-wrap: anywhere;
}
#kk-social-speech > div:not(.kk-speech-remote)::after {
  content: '';
  position: absolute;
  top: 100%;
  left: var(--speech-tail, 50%);
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #b7dadd;
}
#kk-social-speech strong { display: block; font-size: 11px; color: #c5d7dd; }
#kk-social-speech span { display: block; }
#kk-social-speech .kk-speech-team { color: #8fffc6; }
#kk-social-speech .kk-speech-remote { border-color: #8fffc6; }
.kk-social-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
#kk-social-close { margin-left: auto; }
#kk-social-messages { overflow: auto; max-height: min(28dvh, 260px); min-height: 56px; border: 1px solid #81978a; padding: 4px 6px; }
#kk-social-panel article { padding: 4px 0; overflow-wrap: anywhere; }
#kk-social-panel article + article { border-top: 1px solid #81978a66; }
#kk-social-panel small { color: var(--kk-cyan); }
#kk-social-panel details button { margin: 3px 3px 0 0; }
#kk-social-panel form { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
#kk-social-panel form input { flex: 1 1 145px; min-width: 0; }
#kk-social-target { max-width: 100%; }
#kk-social-panel ul { list-style: none; padding: 0; margin: 4px 0; }
#kk-social-panel li { padding: 4px 2px; border-bottom: 1px solid #81978a55; overflow-wrap: anywhere; }
#kk-social-panel li small { margin-left: 8px; }
#kk-social-panel li button { margin: 3px 3px 0 0; }
#kk-social-status:empty { display: none; }
#kk-social-status { color: var(--kk-lime); }
@media (pointer: coarse) {
  #kk-social :is(button, input, select) { min-height: 44px; }
  #kk-social :is(input, select) { font-size: 16px; }
  #kk-social summary { line-height: 2.4; }
}

/* Campaign combat dock */
#kk-skill-dock {
  position: absolute; z-index: 9; left: 50%; transform: translateX(-50%);
  bottom: max(7px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 7px; color: #f2dcb0;
  font: 600 12px var(--kk-mono, monospace); user-select: none;
}
#kk-skill-dock[hidden] { display: none; }
.kk-dock-center {
  padding: 7px 8px 5px; display: grid; gap: 5px;
  background: linear-gradient(#2e2423, #151720);
  border: 1px solid #9b7853; border-radius: 9px 9px 5px 5px; box-shadow: 0 4px 13px #090609aa;
}
.kk-dock-slots { display: flex; gap: 5px; }
#kk-skill-dock .kk-dock-slots button {
  position: relative; display: grid; place-content: center; padding: 0 0 4px;
  width: 39px; height: 39px; min-width: 0; min-height: 0; touch-action: none;
  color: inherit; background: linear-gradient(#392c2b, #1a1b25); border: 1px solid #71594a; border-radius: 5px;
}
.kk-dock-slots span, .kk-dock-slots strong { font-size: 17px; }
.kk-dock-slots small { position: absolute; bottom: 1px; right: 4px; font-size: 9px; color: #d8b78b; }
#kk-skill-dock .kk-dock-slots button:is(:hover, [data-dragging]) { border-color: #e4b679; }
#kk-skill-dock .kk-belt[data-type="heal"] { color: #ff9685; border-bottom: 3px solid #b8463b; }
#kk-skill-dock .kk-belt[data-type="mana"] { color: #84dfff; border-bottom: 3px solid #2f7fb8; }
#kk-hero-xp { width: 100%; height: 6px; border: 0; accent-color: #d6ab61; }
#kk-hero-xp::-webkit-progress-bar { background: #11131a; border-radius: 3px; }
#kk-hero-xp::-webkit-progress-value { background: linear-gradient(90deg, #8e5435, #f5d67d); border-radius: 3px; }
#kk-skill-dock .kk-vessel {
  position: relative; height: 83px; width: 55px; min-width: 0; min-height: 0;
  padding: 0; border: 0; background: none; touch-action: manipulation;
  filter: drop-shadow(0 2px 5px #090611);
}
.kk-vessel-art { position: absolute; inset: 2px 0; display: block; width: 100%; height: calc(100% - 4px); pointer-events: none; }
.kk-vessel-value {
  display: none; position: absolute; left: 50%; bottom: 23%; transform: translateX(-50%);
  white-space: nowrap; padding: 3px; border-radius: 3px; color: #fff2d4; background: #191321ee;
  font-size: calc(var(--kk-text, 14px) * .86);
}
.kk-vessel:is(:hover, :focus-visible, [aria-pressed="true"]) .kk-vessel-value { display: block; }
#kk-readouts[data-campaign="true"] .kk-vitals { display: none; }
#kk-readouts[data-town="true"] .kk-clock { display: flex; }
#kk-readouts[data-campaign="true"] .kk-score .kk-label { display: none; }
#game-container:has(#kk-skill-dock:not([hidden])) { --kk-actions-bottom: max(96px, env(safe-area-inset-bottom)); }
#game-container:has(#kk-skill-dock:not([hidden])) #kk-tip { bottom: 117px; }
#game-container:has(#kk-skill-dock:not([hidden])) #kk-touch :is(#kk-roll, #kk-skill) { display: none; }
.kk-respec-skills li { display: flex; align-items: center; gap: 9px; }
.kk-skill-icon {
  --branch-metal: #ce9a5c;
  box-sizing: border-box; display: inline-block; flex: none;
  inline-size: 38px; block-size: 38px; border: 2px solid var(--branch-metal); border-radius: 3px;
  background: #151922 var(--icon-atlas) var(--icon-x) var(--icon-y) / 800% 1400% no-repeat;
  image-rendering: pixelated;
}
.kk-skill-icon[data-branch="1"] { --branch-metal: #70a8b8; }
.kk-skill-icon[data-branch="2"] { --branch-metal: #889e6a; }
.kk-skill-icon[data-passive] { border-radius: 50%; }
.kk-skill-icon[data-locked] { filter: grayscale(1); }
/* Bonekraft borrows Ashkraft's ash blade, bleached to bone, until it has its own icon. */
.kk-skill-icon[data-tint] { position: relative; background: #151922; }
.kk-skill-icon[data-tint]::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: var(--icon-atlas) var(--icon-x) var(--icon-y) / 800% 1400% no-repeat; image-rendering: pixelated;
}
.kk-skill-icon[data-tint="bone"]::before { filter: grayscale(1) sepia(.35) brightness(1.55) contrast(1.1); }
.kk-bell-icon { background: #202426; }
.kk-bell-icon canvas { display: block; width: 100%; height: 100%; }
.kk-bar-select { display: flex; align-items: center; gap: 7px; min-height: 44px; }
.kk-bar-select select { margin-inline-start: auto; min-width: 0; max-width: 68%; min-height: 44px; }
.kk-bar-select .kk-skill-icon, .kk-sheet-passives .kk-skill-icon { inline-size: 31px; block-size: 31px; }
.kk-respec-skills { display: grid; gap: 6px; list-style: none; padding: 0; }
.kk-dock-slots button > .kk-skill-icon {
  inline-size: clamp(21px, 6.65vw, 29px); block-size: clamp(21px, 6.65vw, 29px);
  border-width: 1px;
}
.kk-dock-slots button::before, .kk-dock-slots button small { z-index: 1; }
.kk-dock-tooltip {
  position: fixed; z-index: 3; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  box-sizing: border-box; display: none; flex-direction: column; align-items: stretch; gap: 5px;
  width: min(270px, calc(100vw - 24px)); padding: 9px 12px;
  border: 1px solid #b9986b; border-radius: 4px; box-shadow: 0 3px 12px #0a0811a8;
  background: #191721; color: #f8ead0; text-align: start;
  line-height: 1.3; white-space: normal; overflow-wrap: anywhere; pointer-events: none;
}
.kk-dock-tooltip .kk-skill-icon { inline-size: 27px; block-size: 27px; }
.kk-dock-tooltip .kk-skill-tip-name { display: flex; align-items: center; gap: 8px; font-size: max(16px, 1.1 * var(--kk-text, 14px)); }
.kk-dock-tooltip .kk-skill-tip-stat {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 7px;
  padding-top: 4px; border-top: 1px solid #51454a; font-size: var(--kk-text, 14px);
}
.kk-skill-tip-stat canvas { max-width: 20px; max-height: 20px; }
.kk-skill-tip-stat b { color: #fff; font-variant-numeric: tabular-nums; }
.kk-dock-tooltip .kk-skill-tip-effect { font-size: var(--kk-text, 14px); }
.kk-dock-tooltip .kk-skill-tip-bind { color: #dfc79e; font-size: max(13px, .9 * var(--kk-text, 14px)); }
.kk-dock-slots button:focus-visible .kk-dock-tooltip { display: flex; }
@media (hover: hover) {
  .kk-dock-slots button:hover .kk-dock-tooltip { display: flex; }
}
@media (hover: none) {
  .kk-dock-slots button:focus .kk-dock-tooltip { display: flex; }
}
#kk-level-notice {
  position: absolute; z-index: 10; top: max(64px, calc(env(safe-area-inset-top) + 54px)); left: 50%;
  transform: translateX(-50%); display: flex; align-items: center; gap: 7px; min-height: 44px;
  background: #201923; color: #f9db9f; border: 1px solid #aa8056; padding: 5px 9px; white-space: nowrap;
}
#kk-level-notice[hidden] { display: none; }
#kk-level-notice .kk-skill-icon { inline-size: 29px; block-size: 29px; }
@media (max-width: 650px) {
  #kk-skill-dock { gap: 4px; width: max-content; max-width: 99%; }
  #kk-skill-dock .kk-vessel { height: 60px; width: clamp(30px, 10vw, 43px); }
  #kk-skill-dock .kk-dock-slots button { width: clamp(26px, 9vw, 41px); height: 39px; }
  .kk-dock-center { padding-inline: 3px; }
  .kk-dock-slots { gap: 3px; }


  #game-container:has(#kk-skill-dock:not([hidden])) { --kk-actions-bottom: 67px; }
}

html, body { overscroll-behavior: none; }
#game-container { -webkit-tap-highlight-color: transparent; }
#kk-overlay { touch-action: pan-y; }
#kk-overlay :is(input, textarea, select) { user-select: auto; }
#kk-canvas, #kk-touch { touch-action: none; }
#kk-campaign .kk-movable-cell:not(.kk-empty-cell) { touch-action: none; }
#kk-campaign .kk-touch-drag { opacity: .65; }
.kk-dock-slots button[data-hold] .kk-dock-tooltip { display: flex; }

@media (pointer: coarse) {
  #kk-overlay button, #kk-social button, #kk-world-use, #kk-hud button, #kk-tip button { min-height: 48px; }
  #kk-world-use, #kk-hud button, #kk-tip-close { min-width: 48px; }
  .arcade-web [data-arcade=krazkraft] .arcade-toolbar { padding-block: 0; }
  .arcade-web [data-arcade=krazkraft] .arcade-toolbar :is(button, a),
  .arcade-web [data-arcade=krazkraft] .arcade-toolbar #arcade-fullscreen[data-game-fullscreen] { min-width: 48px; min-height: 48px; }
  #kk-campaign :is(.kk-item-cell, .kk-check-cell) { min-height: 48px; }
  #kk-skill-dock { inset-inline: 0; left: 0; transform: none; justify-content: center; width: auto; max-width: none; }
  #kk-skill-dock .kk-dock-slots button { width: 48px; height: 48px; }
  #kk-skill-dock .kk-vessel { width: 48px; height: 67px; }
  #game-container:has(#kk-skill-dock:not([hidden])) {
    --kk-actions-bottom: calc(max(7px, env(safe-area-inset-bottom)) + 88px);
  }
  .kk-dock-slots { gap: 2px; }
  .kk-dock-center { padding-inline: 3px; }
  .kk-item-grid, #kk-campaign-body { overscroll-behavior: contain; }
  #kk-campaign input:not([type="checkbox"]), #kk-campaign select { font-size: 16px; }
}

@media (pointer: coarse) and (max-width: 465px) {
  #kk-skill-dock .kk-vessel { position: absolute; bottom: 70px; }
  /* Keep the vessels and their numbers off the screen edges (and out of rounded corners / notches). */
  #kk-life-vial { left: max(8px, env(safe-area-inset-left)); }
  #kk-mana-crystal { right: max(8px, env(safe-area-inset-right)); }
  #kk-life-vial .kk-vessel-value { left: 0; transform: none; padding-inline: 5px; }
  #kk-mana-crystal .kk-vessel-value { left: auto; right: 0; transform: none; padding-inline: 5px; }
  #game-container:has(#kk-skill-dock:not([hidden])) {
    /* Reserve room for the full mana value to the right of the actions. */
    --kk-actions-right: calc(max(8px, env(safe-area-inset-right)) + max(81px, var(--kk-text, 14px) * 5.4));
  }
  #kk-touch { max-width: 100%; flex-wrap: wrap; justify-content: flex-end; }
}

html[data-kk-text-size="115"] { --kk-text: 16.1px; }
html[data-kk-text-size="130"] { --kk-text: 18.2px; }
html[data-kk-ui-scale="110"] { --kk-control: 48.4px; --kk-touch-control: 52.8px; --kk-card-padding: 1.1; }
html[data-kk-ui-scale="125"] { --kk-control: 55px; --kk-touch-control: 60px; --kk-card-padding: 1.25; }
.kk-card { font-size: var(--kk-text, 14px); }
html:is([data-kk-ui-scale="110"], [data-kk-ui-scale="125"]) .kk-card:not(#kk-title) {
  padding: calc(clamp(11px, 3vw, 24px) * var(--kk-card-padding));
}
#kk-overlay .kk-card button { min-height: var(--kk-control, 44px); }
.kk-card :is(#kk-how, #kk-help-controls, #kk-hof, .kk-item-hint, table) { font-size: .93em; }
.kk-card :is(.kk-card-btn span, .kk-sub, #kk-ledger, #kk-end-best, #kk-character-list span span, .kk-character-action) { font-size: .86em; }
.kk-card :is(p, label, legend, dd, dt, button, select) { overflow-wrap: anywhere; }
.kk-card .kk-field { flex-wrap: wrap; }
.kk-card :is(select, input) { font: inherit; }
.kk-card select { min-height: 36px; min-width: 0; max-width: 100%; }
#kk-title select { min-height: var(--kk-control, 44px); }
#kk-bindings { min-width: 0; margin: 8px 0; border: 1px solid var(--card-rule); }
#kk-bind-status:empty { display: none; }
#kk-hud { font-size: var(--kk-text, 14px); }
#kk-caption {
  position: absolute; z-index: 8; bottom: 24%; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(78%, 54ch); margin: 0; padding: 5px 10px;
  background: #122025; color: var(--kk-paper); pointer-events: none; text-align: center;
  font-size: var(--kk-text, 14px);
}
[data-kk-reduce="true"] #game-container *, [data-kk-reduce="true"] #game-container *::after {
  animation-duration: 0.01ms !important; transition-duration: 0.01ms !important;
}
@media (pointer: coarse) {
  #kk-overlay .kk-card button, .kk-card select, #kk-title select { min-height: var(--kk-touch-control, 48px); }
  .kk-card select { font-size: max(16px, 1em); }
}
#kk-skill-dock .kk-dock-slots #kk-portal-belt {
  display: flex; align-items: center; justify-content: center; gap: 1px; color: #a2ece7;
}
#kk-portal-belt canvas { max-width: 47%; margin-inline-end: 0 !important; }
#kk-portal-belt strong { font-size: 12px; }
.kk-item-cell .kk-stack-count {
  position: absolute; inset: auto 4px 3px auto; color: #bdf5ee; font: 600 13px KKPlex, monospace;
  text-shadow: 0 1px 3px #000, 0 1px 3px #000;
}
@media (max-width: 650px) {
  #kk-skill-dock .kk-dock-slots button { width: clamp(25px, 7.7vw, 41px); }
}
@media (pointer: coarse) {
  #kk-skill-dock .kk-dock-slots button { width: 48px; }
}

/* More, conversations, and the character sheet */
#kk-pause-btn { width: auto; padding-inline: 12px; }
#kk-pause-btn::before { content: none; }
.arcade-web [data-arcade=krazkraft]:has(#kk-overlay[hidden]) #arcade-pause { display: none; }
.arcade-web #kk-pause-btn:not([hidden]) { display: block; }
.kk-more-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 12px; }
.kk-more-actions [data-primary] { grid-column: 1 / -1; }
#kk-settings-content { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--card-rule); }
#kk-campaign.kk-dialog { width: min(100%, 450px); }
.kk-dialog #kk-campaign-body { display: grid; justify-items: center; gap: 8px; }
.kk-npc-portrait { width: 112px; height: 112px; background: radial-gradient(ellipse at 50% 30%, #4a6156, #1b272a); }
#kk-campaign .kk-npc-line { margin: 2px 0 6px; min-height: 3em; text-align: center; }
.kk-npc-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 5px; width: 100%; }
.kk-npc-actions button { width: 100%; }
#kk-campaign .kk-npc-actions button:first-child:not(:last-child):enabled { background: var(--kk-lime); color: var(--kk-ink); }
#kk-campaign .kk-npc-actions button:first-child:not(:last-child):enabled:hover { background: var(--kk-ink); color: var(--kk-paper); }
#kk-dialog-skip { font-size: .8em; }
.kk-lore-archive { margin-top: 10px; }
.kk-lore-archive > button { margin: 3px; }

.kk-character-equipment { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 12px; align-items: start; }
.kk-character-equipment .kk-inventory-section { position: relative; }
#kk-campaign .kk-character-equipment .kk-inventory-section h3 { margin: 0 0 5px; }
.kk-filter-fit { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 3px; }
.kk-filter-fit:not(:has(button:not([hidden]))) { display: none; }
#kk-campaign .kk-filter-fit button { padding-inline: 8px; }
#kk-campaign .kk-active-slot { outline: 2px solid #feedad; outline-offset: -3px; }
#kk-campaign summary { cursor: pointer; }
.kk-gain { color: #bfffad; font-weight: 700; }
.kk-loss { color: #ffb5a5; font-weight: 700; }
#kk-campaign[data-panel="pack"] .kk-item-inspector { z-index: 3; }
#kk-campaign[data-panel="pack"] .kk-item-inspector .kk-close-item { margin-inline-start: auto; }

#kk-skill-dock .kk-vessel { pointer-events: auto; cursor: default; }
#kk-skill-dock .kk-dock-slots button:disabled:not(:hover) { opacity: .62; }
#kk-skill-dock .kk-dock-slots:not(:has([data-dragging])) button[data-slot]:disabled { visibility: hidden; }
#kk-skill-dock .kk-dock-slots small:empty { display: none; }
html[data-kk-input="pad"] .kk-dock-slots small { font-size: clamp(7px, 1vw, 10px); right: 2px; }
@media (pointer: coarse) {
  .kk-vessel .kk-vessel-value { display: block; }
  #kk-skill-dock .kk-dock-slots button { width: clamp(39px, 11.7vw, 48px); height: 44px; }
  #kk-campaign[data-panel="pack"] .kk-item-inspector {
    position: fixed; inset: auto 8px max(8px, env(safe-area-inset-bottom)); margin: 0 auto;
    max-width: 470px; max-height: min(80dvh, calc(100dvh - 16px)); overflow: auto;
  }
  #kk-campaign[data-panel="pack"] .kk-item-inspector button { min-height: 44px; }
}
@media (max-width: 670px), (pointer: coarse) and (max-height: 550px) {
  /* All four character tabs share the tight phone padding, so the tab row never jumps when switching. */
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) { padding: 8px; }
  .kk-character-equipment { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .kk-paper-doll {
    grid-template-areas: "head amulet weapon offhand gloves" "body belt boots ring ring2";
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 4px;
  }
  .kk-doll-hero { display: none; }
  #kk-campaign[data-panel="pack"] .kk-paper-doll .kk-item-cell { min-height: 44px; }
  #kk-campaign[data-panel="pack"] .kk-cell-caption { margin: 0; font-size: 10px; }
  .kk-paper-doll .kk-grid-icon { width: 28px; height: 28px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 550px) {
  #kk-overlay:has(#kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"])) { padding-block: 4px; }
  #kk-campaign .kk-character-equipment .kk-inventory-section h3 { font-size: 14px; line-height: 18px; margin-bottom: 2px; }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]):not([hidden]) {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 8px; padding: 8px;
  }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) .kk-panel-head { display: contents; }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) #kk-campaign-heading { align-self: center; font-size: 24px; grid-area: 1 / 1; }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) #kk-panel-close { grid-area: 1 / 3; align-self: center; }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) #kk-campaign-nav:not(:empty) {
    display: flex; grid-area: 1 / 2; justify-content: flex-end; margin: 0; padding: 0; border: 0;
  }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) :is(#kk-campaign-body, #kk-campaign-status) { grid-column: 1 / -1; }
  #kk-campaign[data-panel="pack"] .kk-paper-doll { gap: 2px; }
  .kk-paper-doll {
    grid-template-areas: "head amulet weapon offhand gloves body belt boots ring ring2";
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
  .kk-character-equipment .kk-item-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); padding: 3px; }
  #kk-campaign[data-panel="pack"] .kk-item-grid .kk-item-cell { aspect-ratio: auto; height: 44px; }
  #kk-campaign[data-panel="pack"] .kk-panel-head { align-items: center; }
}

/* Character tabs: Gear, Stats, Skills and Journal share one header with unspent-point badges. */
/* The four character tabs share one card: same width and height, so switching tabs never moves the title, tabs or Close. */
#kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) { width: min(100%, 870px); }
@media (min-height: 560px) {
  #kk-overlay > #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]):not([hidden]) { height: min(100%, 820px); }
  #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]) > #kk-campaign-body { flex: 1 1 auto; }
}
#kk-campaign-nav .kk-tab-badge {
  display: inline-grid; place-content: center; min-width: 21px; height: 21px; margin-inline-start: 5px; padding: 0 5px;
  align-self: center; border-radius: 11px; background: var(--kk-red); color: white; font-size: 12px; line-height: 1;
}
/* Narrow tabs: the count sits on the tab's corner so it never wraps the tab onto a taller second line. */
@media (max-width: 650px) {
  #kk-campaign-nav button:has(.kk-tab-badge) { position: relative; }
  /* The count sits on the tab's top-right corner, outside the label, so it never covers or wraps the text. */
  #kk-campaign-nav:not(:empty) { padding-top: 7px; overflow: visible; }
  #kk-campaign-nav .kk-tab-badge { position: absolute; top: -9px; right: -5px; min-width: 18px; height: 18px; margin: 0; padding: 0 4px; font-size: 11px; box-shadow: 0 0 0 2px var(--card-bg, #f3e7cf); }
}
.kk-points-left { margin: 0; padding: 6px 10px; border: 2px solid var(--card-rule); font-weight: 700; }
.kk-points-left.kk-has-points { border-color: var(--kk-ink); background: var(--kk-lime); }
#kk-campaign .kk-points-badge { min-height: 44px; border-color: var(--kk-ink); background: var(--kk-lime); font-weight: 700; }
#kk-campaign .kk-points-badge:hover { color: white; background: var(--kk-red); }

.kk-char-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.kk-char-level { display: grid; gap: 3px; flex: 1 1 200px; min-width: 0; }
.kk-xp { height: 8px; border: 1px solid var(--kk-ink); background: #d9ccad; }
.kk-xp span { display: block; height: 100%; background: var(--kk-blue); }
#kk-campaign .kk-xp-text { font-size: 12px; line-height: 1.2; }
.kk-char-vitals { display: flex; flex-wrap: wrap; gap: 2px 12px; flex-basis: 100%; font-size: var(--kk-text, 14px); }
.kk-char-vitals > span, .kk-attribute-label strong { display: flex; align-items: center; gap: 4px; }
.kk-char-vitals strong, .kk-attribute-effects dd, .kk-derived-row strong { font-variant-numeric: tabular-nums; }

/* Stats tab: attributes stacked on the left, derived numbers on the right. */
.kk-sheet-head { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 18px; margin-bottom: 10px; }
.kk-sheet-facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; }
.kk-sheet-facts div { display: grid; }
.kk-sheet-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.kk-sheet-facts dd { margin: 0; font-size: 16px; }
.kk-sheet { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.kk-sheet-attributes, .kk-sheet-derived { display: grid; gap: 6px; }
.kk-attribute-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
  padding: 6px 6px 6px 10px; border: 1px solid #786451; background: #efe2c4;
}
.kk-attribute-label { display: grid; gap: 3px; min-width: 0; }
.kk-attribute-label strong { font-size: max(16px, var(--kk-text, 14px)); }
#kk-campaign .kk-attribute-label small, #kk-campaign .kk-derived-row small, #kk-campaign .kk-sheet-passives small {
  font-size: var(--kk-text, 14px); line-height: 1.35;
}
.kk-attribute-effects { grid-column: 1 / -1; display: grid; gap: 2px; margin: 0; }
.kk-attribute-effects div {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; padding-top: 3px; border-top: 1px solid #c7b79a;
}
.kk-attribute-effects dt { margin-inline-end: auto; }
.kk-attribute-effects dd { margin: 0; font-weight: 700; }
.kk-attribute-next { color: #185b30; }
.kk-attribute-value {
  min-width: 52px; padding: 4px 8px; border: 2px solid var(--kk-ink); background: var(--kk-ink); color: var(--kk-paper);
  font-size: 22px; text-align: center;
}
/* Stepper: [−] value [+]. The minus only shows for points placed since the menu opened; hidden controls keep their space. */
.kk-attribute-stepper { display: grid; grid-template-columns: 44px auto 44px; align-items: center; gap: 6px; }
#kk-campaign :is(.kk-attribute-add, .kk-attribute-remove) { width: 44px; height: 44px; min-height: 44px; padding: 0; font-size: 24px; line-height: 1; }
#kk-campaign .kk-attribute-add:enabled { background: var(--kk-lime); }
#kk-campaign .kk-attribute-remove:enabled { background: var(--kk-paper); border-style: dashed; }
#kk-campaign :is(.kk-attribute-add, .kk-attribute-remove):enabled:hover { color: white; background: var(--kk-red); }
#kk-campaign :is(.kk-attribute-add, .kk-attribute-remove):disabled { visibility: hidden; }
.kk-attribute-value { position: relative; }
.kk-attribute-pending { box-shadow: inset 5px 0 0 var(--kk-lime); }
.kk-attribute-pending .kk-attribute-value { border-color: var(--kk-ink); background: var(--kk-lime); color: var(--kk-ink); }
#kk-campaign .kk-attribute-extra {
  position: absolute; top: -9px; right: -9px; display: grid; place-content: center; min-width: 22px; height: 20px; padding: 0 4px;
  border: 1px solid var(--kk-ink); border-radius: 10px; background: var(--kk-ink); color: var(--kk-lime); font-size: 12px; line-height: 1;
}
.kk-points-left { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; }
#kk-campaign .kk-points-lock { display: inline; font-size: 12px; font-weight: 600; }
.kk-derived-row strong.kk-pending { color: #185b30; text-decoration: underline 2px var(--kk-lime); text-underline-offset: 3px; }
.kk-invisible { visibility: hidden; }
#kk-campaign .kk-sheet-derived h3 { margin: 0 0 2px; }
.kk-derived-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 3px 7px;
  padding: 6px 8px; border-bottom: 1px solid var(--card-rule); background: #f5ebd3;
}
.kk-derived-row canvas { max-width: 22px; max-height: 22px; }
.kk-derived-row small, .kk-sheet-passives small { grid-column: 2 / -1; color: #414740; }
.kk-derived-row strong { font-size: max(17px, var(--kk-text, 14px)); }
.kk-derived-row.kk-affected { background: var(--kk-lime); outline: 1px solid var(--kk-ink); }
.kk-sheet-passives { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; font-size: max(15px, var(--kk-text, 14px)); }
.kk-sheet-passives li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 3px 7px; }

/* Skills tab: branch tabs, one tree per branch and a detail card. */
.kk-skill-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.kk-branch-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
#kk-campaign .kk-branch-tab { min-height: 44px; min-width: 44px; padding-inline: 12px; }
#kk-campaign .kk-branch-tab[aria-selected="true"] { color: var(--kk-paper); background: var(--kk-ink); }
.kk-branch-spent { display: inline-block; margin-inline-start: 6px; opacity: .7; font-size: 12px; }
.kk-skill-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: 12px; align-items: start; }
.kk-skill-tree-scroll {
  padding: 12px 6px 4px; border: 1px solid #60645b;
  background: radial-gradient(ellipse at 50% 30%, #2f4140, #172124 80%);
}
.kk-skill-tree {
  --node: 56px; --row: 108px;
  position: relative; height: calc(var(--rows) * var(--row)); min-width: calc(var(--columns) * 84px);
}
.kk-skill-links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.kk-skill-links path { fill: none; stroke-width: 3; stroke-linejoin: round; }
.kk-link-met { stroke: #e7b45f; }
.kk-link-unmet { stroke: #6f7d78; stroke-dasharray: 5 4; }
.kk-skill-slot {
  position: absolute; top: calc(var(--y) * var(--row)); left: calc((var(--x) + .5) * 100% / var(--columns));
  display: grid; justify-items: center; gap: 9px; width: calc(100% / var(--columns) - 6px); transform: translateX(-50%);
}
#kk-campaign .kk-skill-node {
  position: relative; display: grid; place-items: center; width: var(--node); height: var(--node); min-height: var(--node);
  padding: 0; border: 2px solid #5e6662; border-radius: 6px; background: #10171a; color: var(--kk-paper);
}
#kk-campaign .kk-skill-node:hover { background: #24323a; border-color: var(--kk-paper); }
.kk-skill-node .kk-skill-icon { inline-size: calc(var(--node) - 12px); block-size: calc(var(--node) - 12px); }
.kk-skill-node[data-state="locked"] { opacity: .55; border-style: dashed; }
.kk-skill-node[data-state="locked"] .kk-skill-icon { filter: grayscale(1) brightness(.7); }
#kk-campaign .kk-skill-node[data-state="learned"] { border-color: #e7b45f; }
#kk-campaign .kk-skill-node[data-state="maxed"] { border-color: #ffd36e; background: #6b4a17; box-shadow: inset 0 0 0 2px #ffd36e; }
#kk-campaign .kk-skill-node[data-state="ready"] { border-color: var(--kk-lime); box-shadow: 0 0 0 2px #d8ed6266, 0 0 14px 3px #d8ed62aa; }
#kk-campaign .kk-skill-node[aria-pressed="true"] { outline: 3px solid var(--kk-paper); outline-offset: 2px; }
#kk-campaign .kk-skill-ghost { --node: 44px; opacity: .8; border-style: dashed; }
@media (prefers-reduced-motion: no-preference) {
  .kk-skill-node[data-state="ready"] { animation: kk-skill-ready 1.6s ease-in-out infinite alternate; }
}
@keyframes kk-skill-ready { to { box-shadow: 0 0 0 2px #d8ed6233, 0 0 6px 1px #d8ed6266; } }
.kk-skill-rank, .kk-skill-level {
  position: absolute; padding: 0 3px; border: 1px solid #000; font-size: 11px; line-height: 15px; pointer-events: none;
}
.kk-skill-rank { right: -6px; bottom: -6px; background: var(--kk-paper); color: var(--kk-ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.kk-skill-node[data-state="maxed"] .kk-skill-rank { background: #ffd36e; }
.kk-skill-node[data-state="ready"] .kk-skill-rank { background: var(--kk-lime); }
.kk-skill-level { left: -7px; top: -7px; background: #33403f; color: #d9e2dc; }
.kk-skill-level[data-unmet] { background: var(--kk-red); color: white; }
.kk-skill-ghost .kk-skill-level { display: none; }
.kk-skill-name {
  max-width: 100%; color: #f1e3c2; font-size: 11px; line-height: 1.2; text-align: center;
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.kk-skill-detail {
  position: sticky; top: 0; z-index: 2; display: grid; gap: 6px; padding: 10px;
  border: 2px solid var(--kk-ink); background: #efe2c4;
}
.kk-skill-detail-head { display: flex; align-items: center; gap: 9px; }
.kk-skill-detail-head strong { display: block; font-size: 16px; }
.kk-skill-detail .kk-skill-taper { margin: 0; font-size: 12px; line-height: 1.3; color: #5e5340; }
.kk-skill-detail .kk-skill-text { margin: 0; font-size: max(14px, var(--kk-text, 14px)); line-height: 1.4; }
.kk-skill-needs { margin: 0; padding: 0; list-style: none; font-size: max(14px, var(--kk-text, 14px)); }
.kk-skill-facts > div {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 2px 6px;
  padding: 3px 0; border-top: 1px solid var(--card-rule);
}
.kk-skill-facts canvas { max-width: 20px; max-height: 20px; }
.kk-skill-facts .kk-attribute-next { grid-column: 2 / -1; text-align: end; font-weight: 700; }
.kk-skill-needs .kk-met { color: #2d6a3a; }
.kk-skill-needs .kk-unmet { color: var(--kk-red); }
#kk-campaign .kk-skill-learn { min-height: 44px; }
#kk-campaign .kk-skill-learn:enabled { background: var(--kk-lime); }
#kk-campaign .kk-skill-learn:enabled:hover { background: var(--kk-red); }
.kk-skill-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font-size: 12px; }
.kk-skill-legend span::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-inline-end: 5px; vertical-align: -2px;
  border: 2px solid #5e6662; border-radius: 3px; background: #10171a;
}
.kk-skill-legend [data-state="ready"]::before { border-color: var(--kk-lime); box-shadow: 0 0 5px 1px var(--kk-lime); }
.kk-skill-legend [data-state="learned"]::before { border-color: #e7b45f; }
.kk-skill-legend [data-state="maxed"]::before { border-color: #ffd36e; background: #6b4a17; }
.kk-skill-legend [data-state="locked"]::before { border-style: dashed; opacity: .55; }

@media (max-width: 700px) {
  .kk-sheet, .kk-skill-layout { grid-template-columns: minmax(0, 1fr); }
  .kk-skill-tree { --node: 50px; --row: 104px; min-width: 0; }
  .kk-skill-tree-scroll { padding-inline: 2px; }
  /* The selected skill stays in view at the bottom while the tree scrolls, like the item inspector. */
  .kk-skill-detail { top: auto; bottom: 0; gap: 4px; padding: 8px; box-shadow: 0 -6px 14px #18212555; }
  .kk-char-level { flex-basis: 100%; }
  .kk-sheet-derived { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 550px) {
  .kk-skill-layout { grid-template-columns: minmax(0, 1fr) minmax(200px, 250px); }
  .kk-skill-tree { --row: 92px; --node: 48px; }
}

/* Skill bar: tap to cast, drag to arrange (skill-bar.js gesture) */
#kk-skill-dock .kk-dock-slots button[data-skill-slot], .kk-bar-slot, .kk-bar-chip, .kk-skill-node[data-bar-source] {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
#kk-skill-dock .kk-dock-slots button[data-cooling]::after {
  content: ''; position: absolute; inset: 0; z-index: 1; border-radius: inherit; pointer-events: none;
  background: conic-gradient(#07080dcc calc(var(--kk-cooldown) * 360deg), transparent 0);
}
#kk-skill-dock .kk-dock-slots button[data-low-mana] { border-color: #3f8fd4; box-shadow: inset 0 0 0 1px #3f8fd4; }
#kk-skill-dock .kk-dock-slots button[data-low-mana] > .kk-skill-icon { filter: grayscale(.75) brightness(.55); }
#kk-skill-dock .kk-dock-slots button[data-denied] { border-color: #ff7a66; animation: kk-denied .32s ease-out; }
@keyframes kk-denied { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
#kk-skill-dock .kk-dock-slots button[data-dragging] { opacity: .45; }
:is(#kk-skill-dock .kk-dock-slots button, .kk-bar-slot)[data-drop-target] {
  border-color: var(--kk-lime, #d8ed62); box-shadow: 0 0 0 2px var(--kk-lime, #d8ed62), 0 0 12px 2px #d8ed6299;
}
.kk-skill-drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  margin: -64px 0 0 -24px; filter: drop-shadow(0 5px 9px #000c);
}
.kk-skill-drag-ghost .kk-skill-icon { inline-size: 48px; block-size: 48px; }
.kk-skill-drag-ghost[data-remove] { opacity: .55; }
.kk-skill-drag-ghost[data-remove]::after {
  content: '×'; position: absolute; inset: -8px -8px auto auto; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-content: center; background: #b8392c; color: #fff; font: 700 16px/1 sans-serif;
}
.kk-bar-editor { margin: 0 0 10px; }
#kk-campaign .kk-bar-editor h3 { margin: 0 0 2px; }
#kk-campaign .kk-bar-hint { margin: 0 0 6px; font-size: .86em; opacity: .85; }
.kk-bar-strip, .kk-bar-basics { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.kk-bar-basics { margin-top: 6px; }
.kk-bar-basics > span { font-size: .86em; opacity: .85; margin-inline-end: 2px; }
#kk-campaign :is(.kk-bar-slot, .kk-bar-chip) {
  position: relative; display: grid; place-content: center; width: 48px; height: 48px; min-width: 48px; min-height: 48px;
  padding: 0; background: linear-gradient(#392c2b, #1a1b25); border: 1px solid #71594a; border-radius: 5px; touch-action: pan-y;
}
#kk-campaign .kk-bar-slot > .kk-skill-icon, #kk-campaign .kk-bar-chip > .kk-skill-icon { inline-size: 34px; block-size: 34px; border-width: 1px; }
#kk-campaign .kk-bar-slot > span[aria-hidden]:not(.kk-skill-icon) { font-size: 17px; opacity: .6; }
#kk-campaign .kk-bar-slot small { position: absolute; bottom: 1px; right: 4px; font-size: 10px; color: #d8b78b; }
#kk-campaign .kk-bar-chip[aria-pressed="true"] { outline: 3px solid var(--kk-paper); outline-offset: 2px; }
#kk-campaign .kk-bar-slot[data-dragging], #kk-campaign .kk-skill-node[data-dragging] { opacity: .45; }
@media (prefers-reduced-motion: reduce) {
  #kk-skill-dock .kk-dock-slots button[data-denied] { animation: none; }
}

/* Short and wide screens: every overlay card fits the play area. The card never grows past the overlay; the campaign
   body, help list and long cards scroll inside the card, so the title, tabs and Close stay in view. */
#kk-overlay > .kk-card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
#kk-overlay > :is(#kk-campaign, #kk-help):not([hidden]) { display: flex; flex-direction: column; overflow: hidden; scrollbar-gutter: auto; }
#kk-campaign > *, #kk-help > * { flex: none; }
#kk-campaign > #kk-campaign-body, #kk-help > #kk-help-controls {
  flex: 0 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-inline-end: 4px;
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 550px) {
  /* Keep the one-row header grid here: the flex column above would otherwise win on specificity and stack the
     title, Close and tabs on three rows, which leaves a short landscape phone almost no room for the body. */
  #kk-overlay > #kk-campaign:is([data-panel="pack"], [data-panel="stats"], [data-panel="training"], [data-panel="journal"]):not([hidden]) {
    display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden;
  }
}
/* Mouse: the selected item's card opens beside the item (inventory-ui placeBeside), never over the bottom of the panel. */
#kk-campaign .kk-item-inspector.kk-inspector-popup {
  position: fixed; z-index: 7; bottom: auto; margin: 0; width: min(450px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain;
}
/* Phone map button (explored-map.js places it under the minimap). */
#kk-map-btn {
  position: absolute; right: 13px; z-index: 6; min-width: 54px; min-height: 44px; padding: 4px 10px;
  border: 2px solid var(--kk-ink); background: var(--kk-paper); color: var(--kk-ink); font: inherit; font-weight: 700;
  pointer-events: auto; touch-action: manipulation; box-shadow: 3px 3px #111a1e;
}
#kk-map-btn[aria-pressed="true"] { background: var(--kk-lime); }
#kk-online-controls {
  position: absolute; left: max(10px, env(safe-area-inset-left)); z-index: 6;
  display: grid; justify-items: start; gap: 5px; pointer-events: none;
}
#kk-online-controls[hidden], #kk-net-debug[hidden] { display: none; }
#kk-online-btn { min-height: 44px; padding: 4px 12px; pointer-events: auto; touch-action: manipulation; }
#kk-net-debug {
  max-width: min(75vw, 420px); background: #111a1e; color: #f1eddb; padding: 6px 8px;
  border: 1px solid var(--kk-copper); font-size: 12px;
}
.kk-online-player { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-block: 8px; }
/* Owner 1 Dec: seven skill slots (1, 2, Q, X, C, V, G) between the tonics (3, 4) and the scroll (5).
   Empty slots stay hidden in play (fewer HUD controls); the Skills tab shows all seven with their keys. */
#kk-campaign .kk-bar-chip.kk-bar-default {
  display: inline-flex; align-items: center; gap: 6px; width: auto; max-width: 100%; height: 44px; min-height: 44px; padding: 3px 8px 3px 3px;
}
#kk-campaign .kk-bar-default > .kk-skill-icon { inline-size: 30px; block-size: 30px; }
#kk-campaign .kk-bar-default small { font-size: .8em; color: #d8b78b; white-space: nowrap; }
/* Owner 2 Dec: the default attack's slot shows its key ("Shift"); the icon shrinks a little and the hint sits
   centred under it, so the longer label never covers the icon or the slot border. */
#kk-skill-dock .kk-dock-slots button[data-basic-attack]:has(small:not(:empty)) > .kk-skill-icon {
  inline-size: clamp(19px, 5.6vw, 24px); block-size: clamp(19px, 5.6vw, 24px); margin-block-end: 9px;
}
#kk-skill-dock .kk-dock-slots button[data-basic-attack] small { left: 0; right: 0; bottom: 2px; text-align: center; line-height: 1; }
#kk-campaign .kk-bar-slot[data-basic-attack]:has(small:not(:empty)) > .kk-skill-icon { inline-size: 27px; block-size: 27px; margin-block-end: 10px; }
#kk-campaign .kk-bar-slot[data-basic-attack] small { left: 0; right: 0; bottom: 2px; text-align: center; line-height: 1; }
/* Seven slots on one row on a 412px phone. */
@media (max-width: 460px) {
  .kk-bar-strip { gap: 3px; }
  #kk-campaign .kk-bar-slot { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
}
/* Phones: ten buttons do not fit one row at 48px, so the tonics and scroll sit on a short row above the slots. */
@media (pointer: coarse) and (max-width: 640px) {
  #kk-skill-dock .kk-dock-slots { display: grid; grid-template-columns: repeat(7, clamp(40px, 11.2vw, 48px)); gap: 2px; }
  #kk-skill-dock .kk-dock-slots button { width: 100%; height: 44px; }
  #kk-skill-dock .kk-dock-slots .kk-belt { grid-row: 1; height: 38px; }
  #kk-skill-dock .kk-dock-slots [data-belt="0"] { grid-column: 2; }
  #kk-skill-dock .kk-dock-slots [data-belt="1"] { grid-column: 3; }
  #kk-skill-dock .kk-dock-slots [data-belt="2"] { grid-column: 4; }
  #kk-skill-dock .kk-dock-slots [data-belt="3"] { grid-column: 5; }
  #kk-skill-dock .kk-dock-slots #kk-portal-belt { grid-column: 6; }
  #kk-skill-dock .kk-dock-slots [data-skill-slot] { grid-row: 2; }
  #game-container:has(#kk-skill-dock:not([hidden])) {
    --kk-actions-bottom: calc(max(7px, env(safe-area-inset-bottom)) + 128px);
  }
}
@media (pointer: coarse) and (max-width: 465px) {
  #kk-skill-dock .kk-vessel { bottom: 110px; }
}

/* Owner 1 Dec item skills: a violet glow on the item, its tooltip line and the skill icon. CSS only, no new art. */
:root { --kk-item-skill: #c58cff; }
.kk-item-cell[data-item-skill] {
  border-color: var(--kk-item-skill) !important;
  box-shadow: 0 0 0 1px var(--kk-item-skill), 0 0 10px 1px color-mix(in srgb, var(--kk-item-skill) 70%, transparent), inset 0 0 8px color-mix(in srgb, var(--kk-item-skill) 35%, transparent);
}
.kk-item-skill-note {
  color: #e7cfff; border-inline-start: 3px solid var(--kk-item-skill); padding-inline-start: 6px;
  background: color-mix(in srgb, var(--kk-item-skill) 14%, transparent);
}
.kk-skill-icon[data-item-skill] { box-shadow: 0 0 0 2px var(--kk-item-skill), 0 0 8px var(--kk-item-skill); }
.kk-skill-icon[data-item-skill][data-locked] { filter: grayscale(.8) brightness(.7); }
.kk-skill-tip-item { color: #e7cfff; font-size: .9em; }

/* Keyboard layout picker (js/key-layout.js): two options, each with a small keyboard drawing. */
/* Owner 1 Dec: a thicker frame, the same 4px copper as every card's top edge, carried round all four sides. */
#kk-layout { max-width: min(860px, 96vw); border: 4px solid var(--kk-copper); }
#kk-layout-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 10px; margin: 10px 0 14px; }
.kk-layout-option {
  display: grid; gap: 6px; padding: 10px; cursor: pointer; text-align: start;
  border: 2px solid #71594a; border-radius: 8px; background: #1a1b25;
}
.kk-layout-option:has(input:checked) { border-color: #e4b679; box-shadow: 0 0 0 2px #e4b67955; background: #241e24; }
.kk-layout-option input { position: absolute; opacity: 0; pointer-events: none; }
.kk-layout-option:has(input:focus-visible) { outline: 2px solid #f9db9f; outline-offset: 2px; }
.kk-layout-option strong { font-size: 1.05em; color: #f9db9f; }
.kk-layout-summary { font-size: .82em; color: #d8c6a8; }
.kk-keyboard { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.kk-key-main, .kk-key-arrows { display: grid; gap: 3px; }
.kk-key-row { display: flex; gap: 3px; }
.kk-key-main .kk-key-row:nth-child(2) { padding-inline-start: 10px; }
.kk-key-main .kk-key-row:nth-child(3) { padding-inline-start: 16px; }
.kk-key {
  display: grid; place-items: center; width: 27px; height: 29px; border-radius: 4px; line-height: 1;
  background: #2b2730; border: 1px solid #4b4250; color: #9c9091; font: 600 11px KKPlex, system-ui, sans-serif;
}
.kk-key b { font-weight: 700; }
.kk-key small { font-size: 7px; letter-spacing: -.02em; }
.kk-key[data-code="ShiftLeft"] { width: 38px; }
.kk-key[data-blank] { visibility: hidden; }
.kk-key[data-role="move"] { background: #23472f; border-color: #57a36c; color: #d7f5de; }
.kk-key[data-role="skill"] { background: #4a3517; border-color: #e4b679; color: #ffe2b0; }
.kk-key[data-role="belt"] { background: #4a1f25; border-color: #ff8f80; color: #ffd8d2; }
.kk-key[data-role="other"] { background: #26303f; border-color: #6f8db0; color: #d3e3f6; }
@media (max-width: 420px) { .kk-key { width: 24px; height: 27px; font-size: 10px; } .kk-key-main .kk-key-row:nth-child(n+2) { padding-inline-start: 6px; } }
/* Narrow phones: the 13-key number row shrinks to fit inside its option card instead of running over the border. */
.kk-key-row { min-width: 0; }
.kk-key-row .kk-key { flex: 0 1 auto; min-width: 0; }
.kk-key small { white-space: nowrap; overflow: hidden; max-width: 100%; }
@media (max-width: 420px) {
  .kk-layout-option { padding: 8px; }
  .kk-key-row { gap: 2px; }
  .kk-key small { font-size: 6px; letter-spacing: -.04em; }
}
/* Two-ring comparison (owner 1 Dec, inventory-ui itemText): the item beside Ring I and Ring II. */
.kk-item-tooltip:has(.kk-item-values-rings),
#kk-campaign .kk-item-inspector.kk-inspector-popup:has(.kk-item-values-rings) { width: min(560px, calc(100vw - 16px)); }
.kk-item-values-rings .kk-item-identity { width: 25%; }
.kk-item-values-rings thead th + th { border-left: 1px solid #55635d; }
.kk-item-values-rings :is(.kk-gain, .kk-loss) { display: block; margin-inline-start: 0; }
.kk-item-values-rings .kk-item-heading { overflow-wrap: break-word; }
@media (max-width: 480px) { .kk-item-values-rings .kk-item-heading .kk-grid-name { font-size: 14px; } .kk-item-values-rings .kk-item-identity { width: 24%; } .kk-card .kk-item-values-rings tbody th { font-size: 13px; overflow-wrap: break-word; } }

/* UI kit charm: short, springy feedback that never blocks input. Off under reduced motion and the in-game Reduce effects. */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-kk-reduce="true"]) .kk-card button:not(:disabled) {
    transition: transform 90ms var(--kk-ease-out), background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  }
  :root:not([data-kk-reduce="true"]) .kk-card button:not(:disabled):active { transform: scale(.95); }
  :root:not([data-kk-reduce="true"]) #kk-campaign :is(.kk-item-cell, .kk-check-cell) { transition: transform 110ms var(--kk-ease-pop); }
  :root:not([data-kk-reduce="true"]) #kk-campaign :is(.kk-item-cell, .kk-check-cell):active { transform: scale(.94); }
  @media (hover: hover) {
    :root:not([data-kk-reduce="true"]) #kk-campaign .kk-item-cell:not(:active):hover { transform: translateY(-2px); }
  }
  :root:not([data-kk-reduce="true"]) .kk-attribute-value.kk-bump { animation: kk-bump 240ms var(--kk-ease-pop); }
  :root:not([data-kk-reduce="true"]) .kk-attribute-value.kk-dip { animation: kk-dip 200ms var(--kk-ease-out); }
  :root:not([data-kk-reduce="true"]) .kk-bump .kk-attribute-extra:not(.kk-invisible) { animation: kk-pop-in 260ms var(--kk-ease-pop); }
  /* Unspent points and tab badges give a small nudge every few seconds so they read at a glance. */
  :root:not([data-kk-reduce="true"]) #kk-campaign-nav .kk-tab-badge { animation: kk-nudge 5s ease-in-out 1.2s infinite; }
  :root:not([data-kk-reduce="true"]) .kk-points-left.kk-has-points {
    background-image: linear-gradient(100deg, transparent 42%, #ffffff70 50%, transparent 58%);
    background-size: 300% 100%; background-repeat: no-repeat; animation: kk-shimmer 6s ease-in-out 0.8s infinite;
  }
  :root:not([data-kk-reduce="true"]) #kk-score.kk-coin-pop { animation: kk-coin 520ms var(--kk-ease-pop); }
  :root:not([data-kk-reduce="true"]) #kk-score.kk-coin-pop::after {
    content: "✦"; position: absolute; margin: -6px 0 0 2px; color: #ffe27a; font-size: 11px; pointer-events: none;
    animation: kk-sparkle 520ms ease-out forwards;
  }
}
#kk-score { position: relative; }
@keyframes kk-bump { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }
@keyframes kk-dip { 0% { transform: scale(1); } 45% { transform: scale(.88); } 100% { transform: scale(1); } }
@keyframes kk-pop-in { 0% { transform: scale(0); } 100% { transform: scale(1); } }
@keyframes kk-nudge { 0%, 86%, 100% { transform: none; } 90% { transform: scale(1.18) rotate(-6deg); } 94% { transform: scale(.96) rotate(4deg); } }
@keyframes kk-shimmer { 0% { background-position: 130% 0; } 30%, 100% { background-position: -30% 0; } }
@keyframes kk-coin { 0% { color: inherit; } 30% { color: #ffe27a; text-shadow: 0 0 8px #ffd36e99; } 100% { color: inherit; } }
@keyframes kk-sparkle { 0% { opacity: 0; transform: scale(.4) rotate(0); } 35% { opacity: 1; transform: scale(1.2) rotate(40deg); } 100% { opacity: 0; transform: translateY(-6px) scale(.6) rotate(90deg); } }
