/* HyperClutch Brain War — full-screen app shell for battle-arena.html.
   Loaded after battle.css / battle-game.css. Shared event pages are untouched. */

:root {
  --app-bg: #070b16;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body.arena-app {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body.arena-app {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -12%, #2a235f 0, transparent 46%),
    radial-gradient(ellipse at 100% 20%, #0d2a3b 0, transparent 42%),
    var(--app-bg);
  background-attachment: fixed;
  font: 14px/1.45 'DM Sans', system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

body.arena-app::before {
  opacity: .17;
  filter: saturate(1.1) brightness(.8);
}

body.arena-app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 11, 22, .08), rgba(7, 11, 22, .62) 72%, var(--app-bg)),
    radial-gradient(ellipse at 50% 0, rgba(56, 228, 239, .08), transparent 56%);
}

.app-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
}

.app-bar {
  position: relative;
  z-index: 30;
  flex: none;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: calc(56px + var(--app-safe-top));
  padding: var(--app-safe-top) 14px 0;
  background: linear-gradient(180deg, rgba(8, 12, 25, .98), rgba(8, 12, 25, .8) 72%, rgba(8, 12, 25, 0));
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.app-bar::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56, 228, 239, .22), transparent);
}

.app-back {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  background: rgba(17, 26, 46, .86);
  color: #eaf2ff;
  font: 700 20px/1 'DM Sans', sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, transform .15s;
}

.app-back:active {
  transform: scale(.94);
  background: #18243c;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.app-brand-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  overflow: hidden;
  border: 1px solid rgba(56, 228, 239, .28);
  border-radius: 10px;
  background: #0a1020;
  box-shadow: 0 0 18px rgba(56, 228, 239, .13);
}

.app-brand-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.app-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.app-brand-copy b {
  font: 900 20px/1 'Barlow Condensed', sans-serif;
  letter-spacing: .08em;
  color: #f5f7ff;
  white-space: nowrap;
}

.app-brand-copy b em {
  font-style: normal;
  color: var(--cyan);
}

.app-brand-copy small {
  font: 800 9px/1 'DM Sans', sans-serif;
  letter-spacing: .18em;
  color: var(--dim);
  text-transform: uppercase;
}

.app-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 99px;
  background: rgba(10, 16, 32, .72);
  color: var(--muted);
  font: 800 10px/1 'DM Sans', sans-serif;
  letter-spacing: .12em;
}

.app-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
}

.app-status.on {
  color: var(--lime);
  border-color: rgba(200, 255, 36, .28);
  background: rgba(200, 255, 36, .06);
}

.app-status.on i {
  background: var(--lime);
  box-shadow: 0 0 10px rgba(200, 255, 36, .5);
  animation: appPulse 1.6s infinite;
}

.app-status.done {
  color: var(--amber);
  border-color: rgba(255, 194, 74, .3);
  background: rgba(255, 194, 74, .07);
}

.app-status.done i {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 194, 74, .5);
}

.app-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px clamp(10px, 3vw, 20px) calc(18px + var(--app-safe-bottom));
  scrollbar-width: none;
}

.app-main::-webkit-scrollbar {
  display: none;
}

.app-main > .panel,
.app-main > .live-arena {
  flex: none;
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
}

#lobby:not(.hidden) {
  margin-top: auto;
  margin-bottom: auto;
}

#live-arena:not(.hidden) {
  margin-top: 0;
  margin-bottom: auto;
}

/* ---------- lobby ---------- */
.game-lobby {
  padding: 0 !important;
  overflow: hidden;
  border-radius: 20px !important;
  border-color: rgba(56, 228, 239, .2) !important;
  background: linear-gradient(160deg, #111a30, #0a0f20 60%, #0b1322) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5), 0 0 60px rgba(56, 228, 239, .05) !important;
}

.lobby-hero {
  position: relative;
  isolation: isolate;
  min-height: 168px;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: #0a1020;
}

.lobby-hero .lobby-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
  opacity: .34;
  filter: saturate(1.1);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}

.lobby-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(8, 13, 26, .22), rgba(8, 13, 26, .9) 80%),
    linear-gradient(90deg, rgba(8, 13, 26, .86), rgba(8, 13, 26, .14) 58%, rgba(8, 13, 26, .5));
}

.lobby-hero-copy {
  position: relative;
  z-index: 1;
  padding: 20px 20px 16px;
}

.lobby-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--cyan);
  font: 800 9.5px/1 'DM Sans', sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.lobby-kicker i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: appPulse 1.6s infinite;
}

.lobby-hero h1 {
  margin: 8px 0 6px;
  color: #fff;
  font: 900 clamp(34px, 7vw, 54px)/.92 'Barlow Condensed', sans-serif;
  letter-spacing: .01em;
  text-shadow: 0 4px 26px rgba(0, 0, 0, .5);
}

.lobby-hero h1 span {
  color: var(--violet);
}

.lobby-hero .hint {
  max-width: 510px;
  margin: 0;
  color: #c4cde5;
  font-size: 12.5px;
  line-height: 1.5;
}

.lobby-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.lobby-chips span {
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 99px;
  background: rgba(7, 13, 27, .72);
  color: #dfe7f8;
  font-size: 10px;
  font-weight: 700;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.lobby-chips b {
  margin-right: 2px;
  color: var(--lime);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
}

.lobby-body {
  padding: 16px 18px 18px;
}

#live-auth {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

#live-auth:empty {
  display: none;
}

#live-controls {
  margin: 0;
}

/* hero picker injected by battle-game.js */
.hc-picker {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 14px;
  background: rgba(10, 16, 32, .8);
}

.hc-picker .lab {
  margin-bottom: 8px;
  color: var(--dim);
  font-size: 9.5px;
}

.hc-picks {
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  max-width: none;
}

.hc-pick {
  padding: 7px 3px 5px;
  border-radius: 11px;
  background: #0b1324;
}

.hc-pick svg {
  width: 38px;
  height: 38px;
}

.hc-pick span {
  font-size: 9.5px;
}

/* join */
.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin: 0 0 6px;
  align-items: end;
}

.code-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.code-field > span {
  padding-left: 2px;
  color: var(--dim);
  font: 800 9.5px/1 'DM Sans', sans-serif;
  letter-spacing: .16em;
}

.live-input {
  flex: 0 0 auto;
  width: 100%;
  max-width: none;
  min-height: 54px;
  margin: 0;
  border-radius: 13px;
  background: #060b16;
  border-color: #2c3754;
  font-size: 24px;
}

.live-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 228, 239, .11);
}

.join-row .btn {
  min-height: 54px;
  padding: 10px 18px;
  border-radius: 13px;
  font-size: 15px;
  white-space: nowrap;
}

#live-message {
  min-height: 0;
  margin-top: 8px;
  font-size: 12px;
}

#live-message:empty {
  display: none;
}

/* room info */
.room-divider {
  margin: 14px 0 0;
}

.room-card {
  grid-template-columns: 1fr auto;
  margin: 12px 0;
  padding: 13px 14px;
  background: #070d1b;
  border-color: #2a3550;
  border-radius: 14px;
}

.live-code {
  font-size: 34px;
}

.live-roster {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.live-player {
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 12px;
}

.live-actions {
  margin: 10px 0 2px;
}

.live-actions .btn,
.live-actions .btn-ghost {
  flex: 1 1 auto;
  min-height: 44px;
}

#live-start-hint {
  margin-top: 8px;
  font-size: 11px;
}

/* compact rules */
.how-to {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 13px;
  background: rgba(8, 14, 28, .6);
}

.how-to summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  cursor: pointer;
  list-style: none;
  color: #dfe7f8;
  font: 800 12px 'DM Sans', sans-serif;
  touch-action: manipulation;
}

.how-to summary::-webkit-details-marker {
  display: none;
}

.how-to summary::after {
  content: "+";
  color: var(--cyan);
  font: 700 18px/1 'DM Sans', sans-serif;
}

.how-to[open] summary::after {
  content: "−";
}

.how-to summary span {
  display: none;
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
}

.how-to-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 10px 10px;
}

.how-to-grid > div {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  column-gap: 7px;
  align-items: start;
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, .04);
  border-radius: 10px;
  background: #0a1120;
}

.how-to-grid i {
  grid-row: span 2;
  font-style: normal;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
}

.how-to-grid b {
  color: #eef2ff;
  font-size: 11px;
}

.how-to-grid span {
  grid-column: 2;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

/* ---------- live game ---------- */
.live-arena {
  margin: 0 !important;
}

.live-arena .panel {
  width: 100%;
  padding: clamp(12px, 3vw, 18px) !important;
  border-color: rgba(56, 228, 239, .16) !important;
  border-radius: 20px !important;
  background: linear-gradient(160deg, #10182b, #090e1b) !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5) !important;
}

.live-arena .panel::before {
  opacity: .18;
}

.live-arena .panel::after {
  background: linear-gradient(170deg, rgba(7, 11, 22, .72), rgba(7, 11, 22, .84) 48%, rgba(7, 11, 22, .94));
}

#live-arena:not(.hidden),
#lobby:not(.hidden) {
  animation: appViewIn .3s cubic-bezier(.2, .8, .2, 1);
}

.live-arena .hcs {
  margin-bottom: 12px;
}

.live-arena .hud {
  margin-bottom: 10px;
}

.live-arena .live-question {
  margin: 4px 0 14px;
  font-size: clamp(20px, 3.2vw, 28px);
}

.live-arena .answers {
  gap: 9px;
}

.live-arena .answer {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 13px;
}

.live-arena .board {
  margin-top: 14px;
}

.live-arena .row {
  grid-template-columns: 26px minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 7px 9px;
}

.live-arena .row .hp {
  display: inline-flex;
}

.live-arena .result-art {
  width: clamp(110px, 20vw, 160px);
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  background: #0a1020;
}

.live-arena .live-actions {
  margin-top: 14px;
}

/* ---------- motion ---------- */
@keyframes appPulse {
  50% { opacity: .35; }
}

@keyframes appViewIn {
  from { opacity: 0; transform: translateY(8px) scale(.995); }
}

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  body.arena-app {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .app-frame {
    max-width: 980px;
    height: min(100dvh, 980px);
    border-left: 1px solid rgba(255, 255, 255, .04);
    border-right: 1px solid rgba(255, 255, 255, .04);
    border-radius: 24px;
    overflow: hidden;
    background: rgba(7, 11, 22, .24);
    box-shadow: 0 0 90px rgba(0, 0, 0, .55);
  }
}

@media (min-width: 651px) {
  .how-to summary span {
    display: inline;
  }

  .lobby-hero-copy {
    padding: 24px 24px 20px;
  }

  .lobby-body {
    padding: 18px 22px 20px;
  }
}

@media (max-width: 650px) {
  .app-bar {
    gap: 8px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .app-back {
    width: 38px;
    height: 38px;
  }

  .app-brand-icon {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
  }

  .app-brand-copy b {
    font-size: 18px;
  }

  .app-brand-copy small {
    font-size: 8px;
  }

  .app-status {
    padding: 5px 8px;
    font-size: 9px;
  }

  .app-main {
    padding: 10px 10px calc(14px + var(--app-safe-bottom));
  }

  .lobby-hero {
    min-height: 152px;
  }

  .lobby-hero-copy {
    padding: 16px 15px 14px;
  }

  .lobby-hero h1 {
    font-size: 36px;
  }

  .lobby-hero .hint {
    font-size: 11.5px;
  }

  .lobby-body {
    padding: 13px 13px 14px;
  }

  .join-row {
    grid-template-columns: 1fr;
  }

  .join-row .btn {
    width: 100%;
  }

  .live-input {
    min-height: 50px;
    font-size: 22px;
  }

  .room-card {
    grid-template-columns: 1fr auto;
  }

  .how-to-grid {
    grid-template-columns: 1fr;
  }

  .live-arena .panel {
    padding: 11px !important;
  }

  .live-arena .hcs {
    height: 220px;
  }

  .live-arena .answer {
    min-height: 54px;
  }

  .live-arena #board-sub {
    display: none;
  }

  .result-hero {
    flex-direction: column;
    text-align: center;
  }

  .result-copy {
    text-align: center;
  }

  .result-art {
    width: min(100%, 240px);
  }
}

@media (max-height: 620px) {
  .lobby-hero {
    min-height: 120px;
  }

  .lobby-hero h1 {
    font-size: 32px;
  }

  .live-arena .hcs {
    height: 190px;
  }
}
