:root {
  --board-card-height: 620px;
  --ink: #1d1b18;
  --muted: #736c62;
  --paper: #fff8ed;
  --panel: #fffdf8;
  --line: #2b241c;
  --red: #e13b2b;
  --orange: #f28b2c;
  --blue: #2b77b8;
  --green: #2e9d65;
  --shadow: 0 18px 55px rgba(29, 27, 24, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(242,139,44,.22), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(43,119,184,.18), transparent 30rem),
    linear-gradient(135deg, #fffaf0 0%, #f5efe6 100%);
}

button, textarea, input { font: inherit; }

.app-shell {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(38px, 7vw, 78px);
  line-height: .88;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #fff, 6px 6px 0 rgba(225,59,43,.2);
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
}

.login-view {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: stretch;
}

.login-copy, .feed-panel, .score-strip {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,248,.88);
  box-shadow: var(--shadow);
}

.login-copy {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-copy h2 {
  margin-bottom: 10px;
  font-size: 34px;
  line-height: 1;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.login-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.login-card {
  min-height: 150px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 8px 8px 0 rgba(43,36,28,.12);
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
}

.login-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 12px 12px 0 rgba(43,36,28,.14);
}

.login-form {
  text-align: left;
}

.login-card-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  height: 100%;
}

.mini-avatar, .avatar-frame {
  position: relative;
  overflow: hidden;
  flex: none;
  border: 3px solid var(--line);
  background: #f4d7a2;
}

.mini-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
}

.avatar-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.35);
}

.portrait-stack {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #111;
  font-size: 50px;
  font-weight: 1000;
  background:
    linear-gradient(135deg, rgba(255,255,255,.48), transparent 42%),
    linear-gradient(150deg, #f7ba54, #f0724a 48%, #3c9bc6);
}

.login-name {
  margin: 0;
  font-size: 28px;
  font-weight: 1000;
}

.login-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.login-fields {
  min-width: 0;
  width: 100%;
}

.login-fields label {
  display: block;
  margin: 8px 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 1000;
  text-transform: uppercase;
}

.login-fields input {
  width: 100%;
  height: 42px;
  margin-bottom: 8px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 900;
}

.game-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
  gap: 18px;
  align-items: start;
}

.flash,
.welcome-panel {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,248,.9);
  box-shadow: var(--shadow);
}

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  font-weight: 1000;
}

.welcome-panel {
  padding: 18px;
}

.welcome-panel h2 {
  margin: 0 0 7px;
  font-size: 36px;
  line-height: 1;
}

.welcome-panel p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.score-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.score-strip strong { display: block; }
.score-strip span { color: var(--muted); }

.healing-alert {
  border: 2px solid var(--green);
  border-radius: 999px;
  background: #eafff5;
  color: #15543a;
  padding: 8px 12px;
  white-space: nowrap;
}

.fighters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.fighter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
  box-shadow: 10px 10px 0 rgba(43,36,28,.13);
}

.board-layout .fighter-card {
  height: var(--board-card-height);
  min-height: 0;
}

.board-layout .portrait-stack {
  flex: 1 1 auto;
  min-height: 0;
}

.board-layout .avatar-frame {
  height: 100%;
  aspect-ratio: auto;
}

.fighter-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: auto;
}

.fighter-actions form {
  display: contents;
}

.fighter-card.healing {
  background: #f0fff8;
  border-color: var(--green);
}

.fighter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.fighter-head h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1;
}

.badge {
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 1000;
}

.bruise-layer {
  position: absolute;
  top: 14%;
  left: 12%;
  right: 12%;
  height: 52%;
  overflow: hidden;
  pointer-events: none;
}

.bruise {
  position: absolute;
  display: none;
  width: 48px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(58,35,96,.32), rgba(37,86,132,.22) 48%, rgba(130,44,72,.11) 68%, transparent 76%);
  filter: blur(7px);
  mix-blend-mode: multiply;
  opacity: .88;
}

.bruise.one { top: 34%; left: 20%; transform: rotate(-14deg); }
.bruise.two { top: 40%; right: 20%; transform: rotate(18deg); }
.bruise.three { top: 62%; left: 34%; transform: rotate(8deg); }
.bruise.four { top: 20%; right: 35%; transform: rotate(-8deg); }
.bruise.five { top: 58%; right: 31%; transform: rotate(18deg); }

.damage-1 .bruise.one,
.damage-2 .bruise.one, .damage-2 .bruise.two,
.damage-3 .bruise.one, .damage-3 .bruise.two, .damage-3 .bruise.three,
.damage-4 .bruise.one, .damage-4 .bruise.two, .damage-4 .bruise.three, .damage-4 .bruise.four,
.damage-5 .bruise.one, .damage-5 .bruise.two, .damage-5 .bruise.three, .damage-5 .bruise.four, .damage-5 .bruise.five {
  display: block;
}

.plaster {
  position: absolute;
  display: none;
  top: 18%;
  left: 50%;
  width: 78px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, #f6c994 0 12px, #f2b980 12px 24px);
  transform: rotate(-12deg);
  box-shadow: 0 2px 8px rgba(80,52,30,.18);
  opacity: .86;
}

.damage-3 .plaster,
.damage-4 .plaster,
.damage-5 .plaster { display: block; }

.nurse {
  display: none;
  align-items: stretch;
  gap: 12px;
  border: 2px solid var(--green);
  border-radius: 8px;
  padding: 10px;
  background: #eafff5;
  color: #15543a;
  font-weight: 900;
}

.fighter-card.healing .nurse { display: flex; }

.nurse-image {
  width: 96px;
  min-height: 118px;
  object-fit: cover;
  flex: none;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.nurse-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.nurse-copy strong {
  color: #123f2d;
  font-size: 15px;
  line-height: 1.1;
}

.nurse-copy span {
  font-size: 13px;
  line-height: 1.25;
}

.meter {
  height: 18px;
  border: 3px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #eee2d2;
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #f6c344 58%, var(--red));
  transition: width .2s ease;
}

.counter {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.primary-btn, .ghost-btn, .drink-btn {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 1000;
  cursor: pointer;
}

.primary-btn, .drink-btn {
  color: #fff;
  box-shadow: 5px 5px 0 rgba(43,36,28,.16);
}

.primary-btn {
  background: var(--red);
}

.drink-btn {
  background: var(--green);
}

.primary-btn:disabled, .drink-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-btn {
  color: var(--ink);
  background: #fff;
}

.ghost-btn.danger {
  color: #8b1f17;
  border-color: #8b1f17;
}

.ghost-btn.mini {
  min-height: 32px;
  padding: 5px 8px;
  border-width: 2px;
  font-size: 12px;
}

.feed-panel {
  max-height: 430px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

.chat-panel {
  display: flex;
  height: var(--board-card-height);
  min-height: var(--board-card-height);
  flex-direction: column;
  overflow: hidden;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: rgba(255,253,248,.92);
  box-shadow: var(--shadow);
  padding: 14px;
}

.chat-head {
  align-items: flex-start;
  margin-bottom: 10px;
}

.chat-head h2 {
  margin: 0;
  font-size: 28px;
}

.chat-status {
  border: 2px solid var(--green);
  border-radius: 999px;
  background: #eafff5;
  color: #15543a;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 1000;
}

.online-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.online-pill {
  border: 2px solid rgba(43,36,28,.28);
  border-radius: 999px;
  background: #fff;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 1000;
}

.online-pill.muted {
  color: var(--muted);
}

.chat-messages {
  display: flex;
  min-height: 260px;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  border: 2px solid rgba(43,36,28,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  padding: 10px;
}

.chat-message {
  align-self: flex-start;
  max-width: 92%;
  border: 2px solid rgba(43,36,28,.2);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  line-height: 1.32;
  word-break: break-word;
}

.chat-message.mine {
  align-self: flex-end;
  border-color: rgba(43,119,184,.38);
  background: #eef7ff;
}

.chat-message-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chat-message-meta strong {
  color: var(--ink);
}

.chat-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.chat-form .primary-btn {
  background: var(--green);
}

.chat-form textarea {
  width: 100%;
  resize: none;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 25px;
}

.feed-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.feed-item {
  border: 2px solid rgba(43,36,28,.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.35;
}

.feed-text {
  margin: 0;
}

.feed-text strong {
  font-weight: 1000;
}

.feed-item time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-action {
  display: inline-flex;
  margin: 8px 8px 0 0;
}

.dispute-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 9px;
  border: 2px dashed rgba(225,59,43,.42);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff6ef;
  color: #7c2a18;
  font-size: 13px;
  font-weight: 900;
}

.dispute-box.accepted {
  border-style: solid;
  border-color: rgba(46,157,101,.55);
  background: #effff7;
  color: #15543a;
}

.empty-feed {
  margin: 0;
  color: var(--muted);
}

.hit-dialog {
  width: min(520px, calc(100% - 28px));
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hit-dialog::backdrop {
  background: rgba(29,27,24,.62);
}

.hit-dialog form {
  padding: 18px;
}

.dialog-head h2 {
  margin-bottom: 14px;
  font-size: 30px;
}

.hit-dialog label {
  display: block;
  margin-bottom: 7px;
  font-weight: 900;
}

.hit-dialog textarea {
  width: 100%;
  resize: vertical;
  border: 3px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 980px) {
  .fighters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-view { grid-template-columns: 1fr; }
  .board-layout { grid-template-columns: 1fr; }
  .chat-panel {
    height: var(--board-card-height);
    min-height: var(--board-card-height);
  }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 20px, 1560px); padding-top: 18px; }
  .topbar, .score-strip, .panel-head { align-items: stretch; flex-direction: column; }
  .fighters-grid, .login-list { grid-template-columns: 1fr; }
  .session { justify-content: space-between; }
  .login-card-inner { align-items: flex-start; }
  .board-layout .fighter-card,
  .chat-panel {
    height: 520px;
    min-height: 520px;
  }
}
