:root {
  --bg: #101114;
  --panel: #1a1d23;
  --panel-strong: #242833;
  --text: #f2eee6;
  --muted: #aeb4c0;
  --line: #373d4a;
  --red: #e55348;
  --cyan: #45b7c8;
  --gold: #d6b74a;
  --green: #63b36d;
  --blue: #6a83d8;
  --ink: #0a0b0e;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, .026) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

body {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.brawl-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: 64px minmax(0, 1fr);
  gap: 0;
  width: 100vw;
  height: 100svh;
}

.brawl-topbar,
.side-panel {
  background: rgba(16, 17, 20, .92);
  border-color: rgba(255, 255, 255, .12);
}

.brawl-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand,
.session-strip,
.panel-head,
.hud,
.meter,
.room-create,
.quick-chat {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 10px;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-size: .9rem;
}

.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-strip {
  gap: 8px;
  min-width: 0;
  justify-content: flex-end;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.session-strip span {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .05);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-select-label {
  display: block;
  min-width: 112px;
}

.room-select-label select {
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: .76rem;
  font-weight: 900;
  outline: none;
}

.room-select-label select:focus {
  border-color: var(--cyan);
}

.room-create {
  gap: 4px;
  min-width: 136px;
}

.room-create input {
  min-width: 0;
  width: 96px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: .76rem;
  font-weight: 900;
  outline: none;
}

.room-create input:focus {
  border-color: var(--cyan);
}

.room-create button {
  width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(69, 183, 200, .18);
  color: var(--text);
  font-size: .72rem;
  font-weight: 900;
}

.arena-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

#brawl-canvas {
  display: block;
  width: min(100%, calc((100svh - 100px) * 16 / 9));
  max-height: calc(100svh - 100px);
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: #15171d;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .42);
}

.hud {
  position: absolute;
  top: 30px;
  gap: 8px;
  pointer-events: none;
}

.hud-left {
  left: 30px;
}

.hud-right {
  right: 30px;
}

.meter {
  gap: 8px;
  min-width: 88px;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  background: rgba(10, 11, 14, .78);
}

.meter span {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
}

.meter strong {
  color: var(--text);
  font-size: .92rem;
}

.event-log {
  position: absolute;
  left: 30px;
  bottom: 30px;
  display: grid;
  gap: 6px;
  width: min(360px, calc(100% - 60px));
  pointer-events: none;
}

.event-line {
  overflow: hidden;
  padding: 7px 9px;
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  background: rgba(10, 11, 14, .78);
  color: var(--text);
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-panel {
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto minmax(96px, .8fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  border-left: 1px solid rgba(255, 255, 255, .12);
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.panel-head h2 {
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: 0;
}

.panel-head a {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 900;
  text-decoration: none;
}

.panel-head button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  font-weight: 900;
}

.panel-head-small {
  margin-bottom: 8px;
}

.player-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.player-list li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.player-name {
  overflow: hidden;
  font-size: .86rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  color: var(--gold);
  font-size: .82rem;
  font-weight: 900;
}

.ranking-panel {
  min-height: 0;
  overflow: hidden;
}

.brawl-ranking-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.brawl-ranking-list li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 6px;
  background: rgba(255, 255, 255, .045);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.brawl-ranking-list li.self {
  border-color: rgba(214, 183, 74, .62);
  background: rgba(214, 183, 74, .1);
}

.brawl-ranking-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brawl-ranking-list strong {
  color: var(--text);
}

.quick-chat {
  gap: 8px;
}

.quick-chat input {
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d0f13;
  color: var(--text);
  outline: none;
}

.quick-chat input:focus {
  border-color: var(--cyan);
}

.quick-chat button,
.touch-attack {
  border: 0;
  border-radius: 6px;
  background: var(--red);
  color: #fff8f4;
  font-weight: 900;
}

.quick-chat button {
  height: 40px;
  padding: 0 12px;
}

.touch-stick,
.touch-attack {
  display: none;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .brawl-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 58px auto auto;
    min-height: 100svh;
    height: auto;
  }

  .brawl-topbar {
    padding: 9px 12px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .session-strip {
    gap: 4px;
    font-size: .66rem;
  }

  .session-strip span {
    max-width: 92px;
    padding: 6px;
  }

  .room-select-label {
    min-width: 96px;
  }

  .room-select-label select {
    height: 28px;
    font-size: .66rem;
  }

  .room-create {
    min-width: 96px;
  }

  .room-create input {
    width: 58px;
    height: 28px;
    font-size: .66rem;
  }

  .room-create button {
    width: 32px;
    height: 28px;
    font-size: .64rem;
  }

  .arena-wrap {
    min-height: calc(100svh - 58px);
    padding: 8px;
  }

  #brawl-canvas {
    width: 100%;
    max-height: calc(100svh - 88px);
  }

  .hud {
    top: 18px;
  }

  .hud-left {
    left: 18px;
  }

  .hud-right {
    right: 18px;
  }

  .meter {
    min-width: 64px;
    padding: 6px 8px;
  }

  .event-log {
    left: 18px;
    bottom: 88px;
    width: min(320px, calc(100% - 36px));
  }

  .touch-stick {
    position: absolute;
    left: 22px;
    bottom: 18px;
    display: block;
    width: 88px;
    height: 88px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 50%;
    background: rgba(10, 11, 14, .54);
    touch-action: none;
  }

  .touch-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--cyan);
    transform: translate(-50%, -50%);
  }

  .touch-attack {
    position: absolute;
    right: 24px;
    bottom: 24px;
    display: block;
    width: 78px;
    height: 78px;
    border-radius: 50%;
    font-size: 1.6rem;
    touch-action: manipulation;
  }

  .side-panel {
    border-top: 1px solid rgba(255, 255, 255, .12);
    border-left: 0;
  }
}

@media (max-width: 520px) {
  .brand-text {
    max-width: 132px;
  }

  .hud {
    gap: 5px;
  }

  .hud-right {
    top: 58px;
    left: 18px;
    right: auto;
  }
}
