:root {
  --bg: #0b1117;
  --surface: #121a23;
  --surface-2: #172231;
  --border: #273546;
  --text: #edf3f8;
  --muted: #96a3b0;
  --accent: #21d07a;
  --accent-2: #46b7f0;
  --warn: #ffd166;
  --danger: #ff5c75;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
}

main {
  width: min(100%, 1760px);
  margin: 0 auto;
  padding: 14px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 17, 23, .92);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar .logo {
  font-weight: 800;
  color: var(--text);
  font-size: 18px;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 14px;
}

.balance {
  color: var(--accent);
  font-weight: 800;
}

.inline {
  display: inline;
}

.linklike {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.arena-shell {
  display: grid;
  grid-template-columns:
    clamp(230px, 17vw, 290px)
    minmax(0, 1.8fr)
    clamp(260px, 19vw, 320px);
  gap: 14px;
  align-items: start;
}

.center-stage {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.arena-panel,
.form-card,
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.arena-panel {
  min-width: 0;
}

.match-rail,
.chat-panel {
  position: sticky;
  top: 73px;
  max-height: calc(100vh - 92px);
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head.compact {
  padding-bottom: 10px;
}

.panel-head h2,
.stream-meta h1 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
}

.stream-meta h1 {
  font-size: clamp(20px, 3vw, 32px);
}

.stream-meta h1 span,
.match-title span {
  color: var(--muted);
  font-size: .75em;
  font-weight: 700;
}

.eyebrow {
  display: block;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-count,
.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 128px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-list {
  overflow: auto;
  padding: 10px;
}

.match-card {
  padding: 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.match-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.match-link {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  color: var(--text);
}

.match-round,
.match-time,
.empty-inline {
  color: var(--muted);
  font-size: 12px;
}

.match-title {
  grid-column: 1 / -1;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.match-time {
  grid-column: 1 / -1;
}

.status-pill {
  justify-self: end;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(150, 163, 176, .14);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-live {
  background: rgba(33, 208, 122, .16);
  color: var(--accent);
}

.odds-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.odds-btn {
  display: grid;
  place-items: center;
  min-height: 54px;
  padding: 8px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.odds-btn:hover {
  border-color: var(--accent);
}

.odds-btn .lbl {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.odds-btn .val {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: var(--accent);
}

.stream-panel {
  overflow: hidden;
}

.stream-meta {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 16px;
}

.stream-meta time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.stream-player {
  position: relative;
  height: clamp(440px, 64vh, 780px);
  min-height: 440px;
  background: #020507;
  border-top: 1px solid var(--border);
}

.stream-player video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #020507;
}

.stream-player iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #020507;
}

.stream-player.has-stream {
  display: grid;
  place-items: stretch;
}

.stream-status {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: min(520px, calc(100% - 32px));
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: rgba(2, 5, 7, .72);
  color: var(--text);
  font-size: 13px;
  backdrop-filter: blur(6px);
}

.stream-status.is-error {
  border-color: rgba(255, 92, 117, .6);
  color: #ffd8de;
}

.stream-status[hidden] {
  display: none;
}

.stream-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,.10) 1px, transparent 1px) 50% 0 / 50% 100% no-repeat,
    repeating-linear-gradient(90deg, #0c5a3c 0 14%, #0a4f36 14% 28%);
}

.score-strip {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(2, 5, 7, .62);
  backdrop-filter: blur(6px);
}

.score-strip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.score-strip span:last-child {
  text-align: right;
}

.score-strip strong {
  color: var(--warn);
  font-size: 20px;
}

.pitch-mark {
  position: absolute;
  border: 2px solid rgba(255,255,255,.35);
}

.center-circle {
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  left: 39%;
  top: 40%;
}

.penalty-left,
.penalty-right {
  width: 14%;
  height: 42%;
  top: 29%;
}

.penalty-left {
  left: -2px;
  border-left: 0;
}

.penalty-right {
  right: -2px;
  border-right: 0;
}

.empty-player {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  background: var(--surface-2);
}

.bet-dock {
  overflow: hidden;
}

.bet-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.bet-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}

.bet-item strong,
.bet-item span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bet-item span {
  color: var(--muted);
  font-size: 12px;
}

.bet-numbers {
  display: grid;
  gap: 2px;
  min-width: 84px;
  text-align: right;
}

.bet-numbers b {
  font-size: 13px;
}

.chat-panel {
  min-height: 520px;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.chat-message {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}

.chat-message.mine {
  border-color: rgba(33, 208, 122, .45);
  background: rgba(33, 208, 122, .08);
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chat-meta strong {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message p {
  margin: 6px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}

.chat-form button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #04140a;
  font-weight: 800;
  cursor: pointer;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-inline {
  margin-top: 10px;
}

.msg {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.msg-success {
  background: rgba(33, 208, 122, .12);
  border: 1px solid var(--accent);
}

.msg-error {
  background: rgba(255, 92, 117, .12);
  border: 1px solid var(--danger);
}

.form-card {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
}

input[type=text],
input[type=password],
input[type=number],
input[type=url],
input[type=datetime-local],
select {
  width: 100%;
  padding: 12px;
  margin: 6px 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
}

select {
  appearance: none;
}

.chat-form input[type=text] {
  height: 42px;
  padding: 0 12px;
  margin: 0;
  font-size: 14px;
}

button[type=submit].cta {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #04140a;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.match-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.match-teams {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 14px;
}

.match-teams span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.vs {
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.st-pending {
  color: var(--warn);
}

.st-won {
  color: var(--accent);
}

.st-lost {
  color: var(--danger);
}

.st-void {
  color: var(--muted);
}

h2 {
  font-size: 18px;
}

.manage-shell {
  display: grid;
  gap: 14px;
}

.manage-shell.narrow {
  max-width: 980px;
  margin: 0 auto;
}

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

.manage-head h1 {
  margin: 2px 0 0;
  font-size: 26px;
}

.manage-home-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
}

.manage-grid {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.manage-form {
  padding: 14px;
}

.manage-field-grid,
.odds-field-grid {
  display: grid;
  gap: 10px 12px;
}

.manage-field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.odds-field-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 4px;
}

.manage-form label span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.manage-form small,
.form-errors {
  display: block;
  color: #ffd8de;
  font-size: 12px;
}

.manage-form .cta {
  margin-top: 4px;
}

.manage-match-list,
.manage-users {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.manage-match-item,
.manage-user-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}

.manage-match-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.manage-match-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.manage-match-main strong {
  overflow-wrap: anywhere;
}

.manage-match-main time,
.stream-ready {
  color: var(--muted);
  font-size: 12px;
}

.stream-ready {
  color: var(--accent-2);
  font-weight: 800;
}

.stream-url-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.stream-url-form input[type=url] {
  height: 38px;
  margin: 0;
  padding: 0 10px;
  font-size: 13px;
}

.stream-url-form button {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #04140a;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.manage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manage-actions a,
.manage-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.manage-actions button.danger {
  border-color: rgba(255, 92, 117, .45);
  color: #ffd8de;
}

.manage-user-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.manage-user-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.manage-user-row span {
  color: var(--muted);
}

.manage-user-row b {
  color: var(--accent);
  font-size: 12px;
}

@media (max-width: 1180px) {
  .arena-shell {
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  }

  .chat-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    min-height: 420px;
  }

  .chat-log {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 10px;
  }

  /* 메인(아레나) 페이지만 무스크롤 한 화면 레이아웃.
     다른 페이지(베팅/내역/운영)는 일반 스크롤을 유지한다. */
  body.app-arena {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  body.app-arena main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
  }

  .topbar {
    padding: 8px 12px;
  }

  .topbar nav {
    flex-wrap: wrap;
  }

  .arena-shell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    min-height: 0;
  }

  .match-rail,
  .chat-panel {
    position: static;
    max-height: none;
  }

  .match-rail .panel-head,
  .bet-dock,
  .stream-meta {
    display: none;
  }

  /* 경기 목록: 좌우 슬라이드 */
  .match-list {
    display: flex;
    gap: 8px;
    max-height: none;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .match-list::-webkit-scrollbar {
    display: none;
  }

  .match-card {
    flex: 0 0 70vw;
    margin-bottom: 0;
    scroll-snap-align: start;
  }

  .center-stage {
    flex: none;
  }

  .stream-player {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .chat-panel {
    flex: 1;
    min-height: 0;
  }

  .chat-log {
    max-height: none;
  }

  .bet-item {
    grid-template-columns: 1fr;
  }

  .bet-numbers {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
    text-align: left;
  }

  .manage-head,
  .manage-match-item {
    grid-template-columns: 1fr;
  }

  .manage-grid,
  .manage-field-grid,
  .odds-field-grid {
    grid-template-columns: 1fr;
  }

  .manage-actions {
    justify-content: flex-start;
  }

  .stream-url-form {
    grid-template-columns: 1fr;
  }
}

/* ===== 로그인 모달 ===== */
.login-open {
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #04140a;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.login-open:hover {
  filter: brightness(1.1);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 12, 0.72);
  backdrop-filter: blur(2px);
}

/* display: flex가 hidden 속성(UA의 display: none)을 덮어쓰지 않도록 한다. */
.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(92vw, 360px);
  padding: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.modal-form {
  display: grid;
  gap: 12px;
}

.modal-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.modal-form input {
  height: 42px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.modal-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-submit {
  height: 44px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #04140a;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}

/* 비로그인 안내 */
.stream-placeholder.login-required {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.chat-login-prompt {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
}

.chat-login-prompt .login-open {
  flex: 1;
  height: 42px;
}

/* ===== 라이브 버튼 ===== */
.live-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  background: rgba(2, 5, 7, .72);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
}

.live-button:hover {
  border-color: rgba(255, 255, 255, .4);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.live-button.is-behind,
.live-button.is-behind .live-dot {
  color: var(--muted);
  background-color: rgba(2, 5, 7, .72);
}

.live-button.is-behind .live-dot {
  background: var(--muted);
}

/* ===== 베팅 보드 ===== */
.bet-board {
  display: grid;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-head h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

.board-card {
  overflow: hidden;
}

.board-match {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.board-match-info {
  display: grid;
  gap: 4px;
}

.board-match-info .match-title {
  font-size: 17px;
}

.board-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.board-col {
  display: grid;
  gap: 8px;
  align-content: start;
}

.main-odds {
  min-height: 62px;
}

.main-odds .lbl {
  font-size: 13px;
  font-weight: 800;
}

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

.score-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.score-btn b {
  color: var(--accent);
}

.score-btn:hover {
  border-color: var(--accent);
}

.odds-btn.is-locked,
.score-btn.is-locked {
  opacity: .45;
  pointer-events: none;
}

@media (max-width: 760px) {
  .board-columns {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
