@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600&family=Noto+Serif+KR:wght@400;600&family=Noto+Sans+KR:wght@400;500;700;900&display=swap');

:root {
  color-scheme: dark;
  --bg: #06070f;
  --bg-2: #0c0e1e;
  --panel: rgba(232, 227, 210, 0.035);
  --panel-2: rgba(232, 227, 210, 0.06);
  --violet: #c9a86a;
  --cyan: #a8bfe0;
  --pink: #d9a8a0;
  --amber: #e0c080;
  --green: #8fbf8a;
  --blood: #c96868;
  --text: #f2ede0;
  --muted: #948fa0;
  --border: rgba(232, 227, 210, 0.14);
  --gradient: linear-gradient(90deg, #c9a86a, #d9a8a0);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

.lang-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 60;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(6, 7, 15, 0.7);
  backdrop-filter: blur(10px);
}

.lang-btn {
  padding: 5px 11px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.lang-btn.active {
  background: var(--gradient);
  color: #0a0a12;
}

@media (max-width: 640px) {
  .lang-toggle { top: 8px; right: 8px; }
  .lang-btn { padding: 4px 9px; font-size: 0.68rem; }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  background-size: cover;
  background-position: center top;
  background-attachment: scroll;
  background-repeat: no-repeat;
  overscroll-behavior-y: none;
}

body.page-home,
body.page-duel,
body.page-royale {
  background-image:
    linear-gradient(180deg, rgba(6, 7, 15, 0.6) 0%, rgba(6, 7, 15, 0.72) 100%),
    url('bg-arena-photo2.png');
}

body.page-duel {
  background-position: center 38%;
}

/* ---- Ambient background fx: fills the wide empty gutters beside the
   centered content (main.single etc.) with slow-moving depth instead of
   flat black — dust particles, gold mist, drifting stars, glowing rune
   circles, and a coliseum silhouette along the bottom. Fixed + z-index:-1
   so it sits above the body's own background image but below all real
   content, and pointer-events:none so it never intercepts clicks. ---- */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* Arena photo is now the primary hero visual — keep only the drifting
   stars from the old ambient fx layer so it doesn't compete/overlap with it. */
.bg-fx-dust,
.bg-fx-mist,
.bg-fx-emblem,
.bg-fx-arena {
  display: none;
}

.bg-fx-stars {
  position: absolute;
  inset: -15%;
  background-image:
    radial-gradient(1.6px 1.6px at 8% 22%, rgba(240, 236, 224, 0.85), transparent),
    radial-gradient(1.2px 1.2px at 32% 8%, rgba(240, 236, 224, 0.65), transparent),
    radial-gradient(1.8px 1.8px at 58% 38%, rgba(240, 236, 224, 0.8), transparent),
    radial-gradient(1px 1px at 78% 15%, rgba(240, 236, 224, 0.55), transparent),
    radial-gradient(1.4px 1.4px at 92% 55%, rgba(240, 236, 224, 0.75), transparent),
    radial-gradient(1.2px 1.2px at 15% 68%, rgba(240, 236, 224, 0.6), transparent),
    radial-gradient(1.6px 1.6px at 45% 82%, rgba(240, 236, 224, 0.7), transparent),
    radial-gradient(1px 1px at 68% 92%, rgba(240, 236, 224, 0.5), transparent);
  background-repeat: repeat;
  background-size: 480px 480px;
  animation: bgfx-stars-drift 220s linear infinite;
}

@keyframes bgfx-stars-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-480px, -320px, 0); }
}

.bg-fx-dust {
  position: absolute;
  inset: -15%;
  opacity: 0.6;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(201, 168, 106, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 40% 66%, rgba(201, 168, 106, 0.4), transparent),
    radial-gradient(1px 1px at 72% 34%, rgba(201, 168, 106, 0.5), transparent),
    radial-gradient(1.3px 1.3px at 88% 78%, rgba(201, 168, 106, 0.35), transparent),
    radial-gradient(1px 1px at 24% 88%, rgba(201, 168, 106, 0.4), transparent),
    radial-gradient(1.2px 1.2px at 58% 12%, rgba(201, 168, 106, 0.3), transparent);
  background-repeat: repeat;
  background-size: 240px 240px;
  animation: bgfx-dust-drift 70s linear infinite;
}

@keyframes bgfx-dust-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(140px, -240px, 0); }
}

.bg-fx-mist {
  position: absolute;
  top: 18%;
  width: min(46vw, 560px);
  height: 62vh;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(201, 168, 106, 0.16) 0%, rgba(201, 168, 106, 0.06) 45%, transparent 75%);
  filter: blur(40px);
  animation: bgfx-mist-drift 20s ease-in-out infinite;
}

.bg-fx-mist-l { left: min(-12vw, -120px); }
.bg-fx-mist-r { right: min(-12vw, -120px); animation-delay: -10s; }

@keyframes bgfx-mist-drift {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.75; }
  50% { transform: translateY(-26px) scale(1.08); opacity: 1; }
}

.bg-fx-emblem {
  position: absolute;
  top: 50%;
  width: 420px;
  height: 420px;
  margin-top: -210px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 106, 0.16);
  box-shadow:
    0 0 50px rgba(201, 168, 106, 0.08),
    inset 0 0 0 22px rgba(201, 168, 106, 0.015),
    inset 0 0 0 24px rgba(201, 168, 106, 0.1),
    inset 0 0 0 58px rgba(201, 168, 106, 0.015),
    inset 0 0 0 60px rgba(201, 168, 106, 0.07);
  animation: bgfx-emblem-spin 100s linear infinite, bgfx-emblem-pulse 7s ease-in-out infinite;
}

.bg-fx-emblem-l { left: -160px; }
.bg-fx-emblem-r { right: -160px; animation-direction: reverse; }

@keyframes bgfx-emblem-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes bgfx-emblem-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

.bg-fx-arena {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 130px;
  background-image: url('bg-arena-silhouette.svg');
  background-repeat: repeat-x;
  background-position: bottom left;
  background-size: 200px 130px;
  opacity: 0.5;
  filter: drop-shadow(0 -6px 24px rgba(0, 0, 0, 0.5));
}

@media (prefers-reduced-motion: reduce) {
  .bg-fx-stars,
  .bg-fx-dust,
  .bg-fx-mist,
  .bg-fx-emblem {
    animation: none;
  }
}

@media (max-width: 900px) {
  .bg-fx-emblem { width: 280px; height: 280px; margin-top: -140px; }
  .bg-fx-emblem-l { left: -110px; }
  .bg-fx-emblem-r { right: -110px; }
  .bg-fx-mist { width: min(60vw, 420px); }
}

.site-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 20px;
  flex-wrap: wrap;
}

.nav-link {
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.2px;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  touch-action: manipulation;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.nav-link:hover { color: var(--text); border-color: var(--violet); transform: translateY(-1px); filter: brightness(1.15); }
.nav-link:active { transform: translateY(0) scale(0.97); filter: brightness(0.92); transition-duration: 0.08s; }

.nav-link.active {
  color: #0a0a12;
  background: var(--gradient);
  border-color: transparent;
  box-shadow: 0 0 20px rgba(201, 168, 106, 0.5);
}

main.single {
  max-width: 640px;
}

main.single.wide {
  max-width: 920px;
}

header {
  padding: 44px 20px 22px;
  text-align: center;
  position: relative;
}

header::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  max-width: 90vw;
  height: 320px;
  background: radial-gradient(ellipse at center, rgba(201, 168, 106, 0.16) 0%, rgba(201, 168, 106, 0.05) 45%, transparent 75%);
  pointer-events: none;
  z-index: -1;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.brand-kicker {
  margin: 0 0 10px;
  font-family: 'Cinzel', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-kicker::before,
.brand-kicker::after {
  content: '';
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--violet));
}

.brand-kicker::after { background: linear-gradient(90deg, var(--violet), transparent); }

.header-inner h1 {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 3rem;
  margin: 0;
  letter-spacing: 2px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 24px rgba(201, 168, 106, 0.45));
}

.brand-by {
  margin: 6px 0 0;
  font-family: 'Cinzel', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--muted);
}

.tagline {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.2px;
}

.season-badge {
  margin: 14px 0 0;
  display: inline-block;
  padding: 8px 20px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(201, 168, 106, 0.18), rgba(217, 168, 160, 0.18));
  border: 1px solid var(--violet);
  color: var(--text);
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  box-shadow: 0 0 20px rgba(201, 168, 106, 0.25);
}

.notice-badge-btn {
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--violet);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.notice-badge-btn:hover { background: rgba(201, 168, 106, 0.2); }

.season-countdown {
  display: block;
  margin: 8px 0 0;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.nickname-bar {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.nickname-bar input {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
}

.nickname-bar input:focus { outline: none; border-color: var(--violet); }

.login-bar {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  flex-wrap: wrap;
  justify-content: center;
}

.login-bar input {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  width: 130px;
}

.login-bar input:focus { outline: none; border-color: var(--violet); }

.primary-small {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: var(--gradient);
  color: #0a0a12;
  font-weight: 900;
  padding: 8px 16px;
  border-radius: 999px;
}

.btn-countdown {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.7;
}

.login-status {
  color: var(--text);
  padding: 8px 4px;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
}

.logout-btn:hover { color: var(--text); border-color: var(--blood); }

.login-error {
  color: var(--blood);
  font-size: 0.78rem;
  flex-basis: 100%;
  text-align: center;
}

.link-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  text-decoration: underline;
  padding: 4px 2px;
}

.link-btn:hover { color: var(--violet); }

.recovery-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.recovery-question-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  flex-basis: 100%;
}

.recovery-question-box.hidden { display: none; }

.recovery-question-box .hint { flex-basis: 100%; margin: 2px 0; }

.modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text);
}

.modal-stats.hidden { display: none; }

.vote-btn {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(244, 114, 182, 0.5);
  background: rgba(244, 114, 182, 0.08);
  color: #f472b6;
  font-weight: 700;
  font-size: 0.85rem;
}

.vote-btn:hover:not(:disabled) { background: rgba(244, 114, 182, 0.18); }
.vote-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.vote-btn.voted {
  border-color: var(--border);
  background: var(--bg-2);
  color: var(--muted);
}

.vote-btn.hidden { display: none; }

.modal-history {
  margin-top: 4px;
}

.modal-history-label {
  margin: 4px 0 6px !important;
  font-weight: 700;
  color: var(--text) !important;
}

.modal-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.modal-history-item:first-of-type { border-top: none; }

.modal-history-time {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}

.result-icon { flex-shrink: 0; }

.history-filter {
  margin-bottom: 12px;
}

.history-filter select {
  padding: 9px 14px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  color-scheme: dark;
  font-family: inherit;
  font-size: 0.85rem;
}

.history-filter select option {
  background: var(--bg-2);
  color: var(--text);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#notice-panel p { line-height: 1.7; margin: 0 0 12px; }
#notice-panel .notice-date { color: var(--muted); font-size: 0.85rem; margin-bottom: 20px; }
#notice-panel .notice-sign { margin-top: 20px; color: var(--muted); }

.history-item {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.history-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.history-type { font-weight: 700; color: var(--violet); }

.history-vs {
  font-size: 0.92rem;
  color: var(--text);
}

.history-vs .win-name { color: var(--amber); }

.countdown {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.05rem;
}

.random-matchup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  padding: 20px;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(201, 168, 106, 0.12), transparent 70%);
  border: 1px solid var(--border);
}

.random-fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}

.random-fighter .portrait {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f7f7fb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.random-fighter .pot {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--amber);
}

.bet-form {
  margin-top: 16px;
}

.bet-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
}

.bet-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  cursor: pointer;
}

.bet-controls input[type='radio'] { accent-color: var(--violet); }

.bet-controls input[type='number'] {
  width: 90px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  color-scheme: dark;
  font-family: inherit;
}

.random-last-result {
  margin-top: 16px;
}

.random-last-result.hidden { display: none; }

.bet-list-title {
  margin: 20px 0 8px;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 1rem;
  color: var(--text);
}

.bet-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#random-panel.alarm-flash {
  animation: alarm-pulse 0.5s ease 3;
}

@keyframes alarm-pulse {
  0%, 100% { box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 0 3px rgba(224, 192, 128, 0.8), 0 20px 50px rgba(0, 0, 0, 0.4); }
}

.history-quote {
  margin: 8px 0 0;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  border-left: 2px solid var(--pink);
  padding-left: 10px;
}

.tutorial-trigger {
  max-width: 700px;
  margin: 20px auto 0;
  padding: 0 20px;
}

.tutorial-btn {
  display: block;
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: 18px 20px;
  background: var(--panel-2);
  border: 1px solid var(--violet);
  border-radius: 14px;
  color: var(--text);
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 0 20px rgba(201, 168, 106, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tutorial-btn:hover {
  transform: translateY(-1px);
  background: rgba(201, 168, 106, 0.12);
  box-shadow: 0 0 26px rgba(201, 168, 106, 0.4);
}

.tutorial-modal-card { display: block; max-width: 560px; }

.modal-card .tutorial {
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

.tutorial h2 {
  margin: 0 0 14px;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 1.15rem;
  color: var(--text);
}

.tutorial ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.tutorial strong { color: var(--pink); }

main {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 30px 32px 60px;
  max-width: 1150px;
  margin: 0 auto;
}

.panel {
  position: relative;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  flex: 1 1 420px;
  min-width: 320px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.panel.hidden { display: none; }

/* Sci-fi HUD corner brackets, HSR-site-style: thin gold L-marks at two
   opposing corners rather than a full decorative border. */
.panel::before,
.panel::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  opacity: 0.55;
}

.panel::before {
  top: -1px;
  left: -1px;
  border-top: 1.5px solid var(--violet);
  border-left: 1.5px solid var(--violet);
  border-top-left-radius: 6px;
}

.panel::after {
  bottom: -1px;
  right: -1px;
  border-bottom: 1.5px solid var(--violet);
  border-right: 1.5px solid var(--violet);
  border-bottom-right-radius: 6px;
}

.panel h2 {
  margin-top: 0;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 1.2rem;
  letter-spacing: 0.3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: none;
  position: relative;
}

.panel h2::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--violet) 0%, rgba(201, 168, 106, 0.4) 45%, transparent 100%);
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--gradient);
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 900;
  color: #0a0a12;
  font-family: 'Noto Sans KR', sans-serif;
  box-shadow: 0 0 0 3px rgba(201, 168, 106, 0.15), 0 0 10px rgba(201, 168, 106, 0.4);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: -4px;
}

.draw-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.my-characters-box {
  margin-top: 14px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.my-characters-box .hint {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--text);
}

.my-characters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.my-characters-header .hint {
  margin-bottom: 0;
}

.buy-slot-btn {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--amber, #fbbf24);
  background: rgba(251, 191, 36, 0.12);
  color: var(--amber, #fbbf24);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.buy-slot-btn:hover {
  background: rgba(251, 191, 36, 0.22);
  transform: translateY(-1px);
}

.buy-slot-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.buy-slot-btn.hidden {
  display: none;
}

.my-characters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.draw-toolbar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.draw-toolbar input[type='color'] {
  width: 40px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.draw-toolbar input[type='range'] {
  width: 100px;
  accent-color: var(--violet);
}

.tool-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
}

.tool-btn.active {
  background: var(--gradient);
  border-color: transparent;
  box-shadow: 0 0 14px rgba(201, 168, 106, 0.5);
}

.tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#clearBtn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--blood);
  border-radius: 8px;
  font-size: 1.1rem;
}

canvas {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  background: #f7f7fb;
  border: 1px solid var(--border);
  border-radius: 12px;
  touch-action: none;
  cursor: crosshair;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.95rem;
  touch-action: manipulation;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

/* Baseline motion+brightness feedback for every button on the site.
   Class-specific hover rules (e.g. .primary) still win on shared
   properties like transform since they're more specific, but this
   guarantees every button gets at least a lift + brightness pop and
   a press-down on click, even ones with no custom hover style. */
button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.15);
}

button:active:not(:disabled) {
  transform: translateY(0) scale(0.96);
  filter: brightness(0.92);
  transition-duration: 0.08s;
}

.primary {
  position: relative;
  overflow: hidden;
  background: var(--gradient);
  color: #0a0a12;
  font-weight: 900;
  margin-top: 12px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(201, 168, 106, 0.35);
  letter-spacing: 0.2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary::after,
.quick-match-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
  pointer-events: none;
}

.primary:hover:not(:disabled)::after,
.quick-match-btn:hover:not(:disabled)::after { left: 130%; }

.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(201, 168, 106, 0.5);
}

.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Judge-button loading feedback: a quick shake on press, then a pulsing
   glow for as long as the AI call is in flight, plus a small spinner. */
@keyframes btn-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@keyframes btn-glow-pulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(201, 168, 106, 0.35); }
  50% { box-shadow: 0 8px 44px rgba(201, 168, 106, 0.95), 0 0 30px rgba(201, 168, 106, 0.7); }
}

#judgeBtn.judging {
  animation: btn-shake 0.4s ease, btn-glow-pulse 1.1s ease-in-out infinite 0.4s;
}

#judgeBtn.judging:disabled {
  opacity: 1;
  cursor: wait;
}

.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(10, 10, 18, 0.25);
  border-top-color: #0a0a12;
  border-radius: 50%;
  animation: btn-spinner-spin 0.7s linear infinite;
}

.btn-spinner.hidden { display: none; }

@keyframes btn-spinner-spin {
  to { transform: rotate(360deg); }
}

.quick-match-btn {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  background: var(--gradient);
  color: #0a0a12;
  font-weight: 900;
  font-size: 1.35rem;
  padding: 22px 16px;
  border-radius: 16px;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 32px rgba(201, 168, 106, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quick-match-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 38px rgba(201, 168, 106, 0.6);
}

.quick-match-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quick-match-hint {
  text-align: center;
  margin: 8px 0 20px;
}

.secondary {
  background: transparent;
  border: 1px solid var(--violet);
  color: var(--violet);
  margin-top: 10px;
  width: 100%;
}

.secondary:hover { background: rgba(201, 168, 106, 0.1); }

.status { color: var(--muted); min-height: 1.2em; font-size: 0.9rem; }

.analysis-log {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analysis-log li {
  font-family: 'Noto Sans KR', monospace;
  font-size: 0.85rem;
  color: var(--cyan);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  padding: 6px 10px;
  animation: scan-in 0.3s ease;
}

.analysis-log li.stat-up { border-left-color: var(--green); color: var(--green); }
.analysis-log li.stat-down { border-left-color: var(--blood); color: var(--blood); }
.analysis-log li.highlight { border-left-color: var(--amber); color: var(--amber); font-weight: 700; }

@keyframes scan-in {
  0% { opacity: 0; transform: translateX(-8px); }
  100% { opacity: 1; transform: translateX(0); }
}

.result-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.result-card.hidden { display: none; }

.reasoning {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.judge-level-box {
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(201, 168, 106, 0.35);
  background: linear-gradient(135deg, rgba(201, 168, 106, 0.14), rgba(201, 168, 106, 0.03));
}

.judge-level-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.judge-level-badge {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--amber);
  letter-spacing: 0.3px;
  text-shadow: 0 0 12px rgba(224, 192, 128, 0.4);
}

.judge-level-box .xp-bar { margin-bottom: 6px; }
.judge-level-box .hint { margin: 0; text-align: right; font-size: 0.75rem; }

.grade-percentile-btn {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.grade-percentile-btn:hover { border-color: var(--violet); }

.grade-percentile-popup {
  position: relative;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  backdrop-filter: blur(10px);
}

.grade-percentile-popup.hidden { display: none; }

.grade-percentile-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.grade-percentile-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 4px;
}

#gradePercentileList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#gradePercentileList li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}

.grade-percentile-value { color: var(--muted); font-weight: 700; }

.story {
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel-2);
  border-left: 3px solid var(--pink);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0;
  line-height: 1.6;
}

.story:empty { display: none; }

#roster-panel {
  display: flex;
  flex-direction: column;
}

.roster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
  flex: 1 1 auto;
  min-height: 260px;
  max-height: 900px;
  overflow-y: auto;
  padding-right: 4px;
}

.roster-entry {
  display: flex;
  flex-direction: column;
}

.roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.roster-item:hover {
  border-color: rgba(201, 168, 106, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.my-char-item.selected {
  border-color: var(--amber);
  background: rgba(224, 192, 128, 0.14);
  box-shadow: 0 0 0 1px var(--amber), 0 4px 14px rgba(0, 0, 0, 0.3);
}


.roster-item.expanded {
  border-color: var(--violet);
  background: rgba(201, 168, 106, 0.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  transform: none;
}

.expand-caret {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.roster-item-detail {
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--violet);
  border-top: none;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  font-size: 0.85rem;
}

.roster-item-detail.hidden { display: none; }

.detail-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.detail-img {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f7f7fb;
  margin: 0;
  flex-shrink: 0;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.detail-img:hover { transform: scale(1.03); }

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 140px;
  min-width: 120px;
}

.detail-vote-btn,
.detail-vote-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 18px 14px;
  border-radius: 14px;
}

.detail-vote-btn {
  border: 1px solid rgba(244, 114, 182, 0.5);
  background: rgba(244, 114, 182, 0.08);
}

.detail-vote-btn:hover { background: rgba(244, 114, 182, 0.18); }

.detail-vote-btn.voted {
  border-color: var(--border);
  background: var(--bg-2);
}

.detail-vote-display {
  border: 1px solid var(--border);
  background: var(--bg-2);
}

.detail-vote-icon { font-size: 1.8rem; line-height: 1; }
.detail-vote-count { font-size: 1.3rem; font-weight: 900; color: var(--text); }
.detail-vote-label { font-size: 0.78rem; color: var(--muted); font-weight: 700; }

/* Compact variant used now that the vote control shares space with the
   share button in .detail-side — full-size version is still used
   wherever it stands alone. */
.detail-vote-btn.compact,
.detail-vote-display.compact {
  flex-direction: row;
  gap: 8px;
  padding: 8px 14px;
}

.detail-vote-btn.compact .detail-vote-icon,
.detail-vote-display.compact .detail-vote-icon { font-size: 1.1rem; }

.detail-vote-btn.compact .detail-vote-count,
.detail-vote-display.compact .detail-vote-count { font-size: 0.95rem; }

.detail-share-btn {
  display: block;
  width: 100%;
  margin: 0 0 12px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--violet);
  background: rgba(201, 168, 106, 0.08);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-share-btn:hover { background: rgba(201, 168, 106, 0.18); }
.detail-share-btn.hidden { display: none; }

.roster-item-detail .record { margin: 0 0 6px; color: var(--text); }
.roster-item-detail .hint { margin: 0 0 10px; }

.skills-inline {
  margin: 0 0 10px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.row-vote-badge { flex-shrink: 0; display: flex; }

.row-vote-btn,
.row-vote-count {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}

.row-vote-btn {
  border: 1px solid rgba(244, 114, 182, 0.5);
  background: rgba(244, 114, 182, 0.08);
  color: #f472b6;
}

.row-vote-btn:hover:not(:disabled) { background: rgba(244, 114, 182, 0.18); }
.row-vote-btn:disabled { opacity: 0.6; }
.row-vote-btn.voted { border-color: var(--border); background: var(--bg-2); color: var(--muted); }

.row-vote-count {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--muted);
}

@keyframes stagger-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.enter-stagger {
  animation: stagger-in 0.35s ease both;
}

.delete-btn {
  background: transparent;
  border: 1px solid var(--blood);
  color: var(--blood);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
}

.delete-btn:hover { background: var(--blood); color: var(--text); }

.restore-btn {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.restore-btn:hover { background: var(--green); color: #0a0a12; }

.streak-badge {
  margin-left: 8px;
  font-size: 0.75rem;
  color: var(--amber);
  background: rgba(224, 192, 128, 0.12);
  border: 1px solid rgba(224, 192, 128, 0.4);
  border-radius: 999px;
  padding: 1px 8px;
}

.level-badge {
  font-size: 0.72rem;
  font-weight: 900;
  color: #0a0a12;
  background: var(--gradient);
  border-radius: 999px;
  padding: 1px 8px;
}

.thumb {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f7fb;
  flex-shrink: 0;
  cursor: zoom-in;
  transition: transform 0.15s ease;
}

.thumb:hover { transform: scale(1.15); }

.roster-item .thumb { cursor: pointer; }

.fighter .portrait { cursor: zoom-in; }

.rank-badge {
  width: 30px;
  text-align: center;
  font-weight: 900;
  color: var(--violet);
  font-family: 'Noto Sans KR', sans-serif;
  flex-shrink: 0;
}

.roster-item .record { color: var(--muted); font-size: 0.8rem; }

.user-title {
  margin-left: 6px;
  font-size: 0.82rem;
  color: var(--pink);
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 10, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  cursor: zoom-out;
}

.image-modal.hidden { display: none; }

.modal-card {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(201, 168, 106, 0.15);
  cursor: default;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
}

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

.modal-card img {
  width: 220px;
  height: 220px;
  max-width: 100%;
  object-fit: cover;
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-shrink: 0;
}

.modal-info {
  flex: 1;
  min-width: 220px;
}

.modal-info h3 {
  margin: 0 0 8px;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 1.3rem;
}

.modal-info p {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal-info ul {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 0.85rem;
}

.modal-info .record {
  color: var(--amber);
  font-weight: 700;
}

.roster-item .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.roster-item .info-line1,
.roster-item .info-line2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-item .info-line2 { font-size: 0.78rem; color: var(--muted); }

.roster-item .tier { color: var(--muted); font-size: 0.8rem; }

.battle-select {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}

.battle-select > div { flex: 1; }
.battle-select select {
  width: 100%;
  padding: 9px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  color-scheme: dark;
}
.battle-select select option {
  background: var(--bg-2);
  color: var(--text);
}
.battle-select label { font-size: 0.8rem; color: var(--muted); }

.select-column {
  margin-bottom: 16px;
}

.select-column > label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.mystery-opponent {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 28px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--amber);
  background: var(--bg-2);
  border: 1px dashed rgba(224, 192, 128, 0.5);
  border-radius: 12px;
}

.mystery-opponent.hidden { display: none; }
.fighter-picker.hidden { display: none; }

/* ---- Quick-match "veiled challenger" reveal, played once before the
   mystery-mode battle starts ---- */
.mystery-reveal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20, 16, 10, 0.97) 0%, rgba(0, 0, 0, 0.98) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.mystery-reveal.active {
  opacity: 1;
  pointer-events: all;
}

.mystery-reveal.hidden { display: none; }

.mystery-reveal-silhouette {
  position: relative;
  width: 150px;
  height: 190px;
  transform: scale(0.2);
  opacity: 0;
  animation: mystery-silhouette-appear 1.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.mystery-reveal-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #050505;
  box-shadow: 0 0 44px rgba(201, 168, 106, 0.65);
}

.mystery-reveal-body {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 128px;
  background: #050505;
  border-radius: 50% 50% 0 0 / 60% 60% 0 0;
  box-shadow: 0 0 44px rgba(201, 168, 106, 0.55);
}

@keyframes mystery-silhouette-appear {
  0% { transform: scale(0.2); opacity: 0; }
  40% { opacity: 1; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.mystery-reveal-text {
  margin-top: 22px;
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: 1.05rem;
  letter-spacing: 2px;
  color: var(--amber);
  opacity: 0;
  animation: mystery-text-appear 0.8s ease forwards;
  animation-delay: 0.9s;
}

@keyframes mystery-text-appear {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-inline {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
}

.fighter-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.fighter-picker-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.fighter-picker-item:hover { border-color: rgba(201, 168, 106, 0.5); transform: translateY(-1px); }

.fighter-picker-item.selected {
  border-color: var(--violet);
  background: rgba(201, 168, 106, 0.15);
  box-shadow: 0 0 14px rgba(201, 168, 106, 0.35);
}

.fighter-picker-item.quick-picked {
  animation: quick-pick-flash 0.9s ease;
}

@keyframes quick-pick-flash {
  0% { box-shadow: 0 0 0 4px rgba(201, 168, 106, 0.8); }
  100% { box-shadow: none; }
}

.fighter-picker-item.fought {
  opacity: 0.45;
  filter: grayscale(0.6);
  background: rgba(0, 0, 0, 0.2);
}

.fighter-picker-item.fought:hover { border-color: var(--border); }

.fighter-picker-item.fought.selected {
  opacity: 0.75;
  border-color: var(--muted);
  background: rgba(120, 120, 120, 0.15);
  box-shadow: none;
}

.fighter-picker-item .info { flex: 1; min-width: 0; font-size: 0.85rem; }

.fought-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(120, 120, 120, 0.12);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}


.unranked-notice {
  margin: 4px 0 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--amber);
  background: rgba(224, 192, 128, 0.1);
  border: 1px solid rgba(224, 192, 128, 0.35);
  border-radius: 10px;
}

.unranked-notice.hidden { display: none; }

.battle-result {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}

.battle-result.hidden { display: none; }

#battleLog strong { color: var(--pink); text-shadow: 0 0 10px rgba(217, 168, 160, 0.4); }
#battleLog {
  font-size: 0.9rem;
  line-height: 1.6;
  max-height: 260px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.winner {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 1.3rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.winner.hidden { display: none; }

.round-badge {
  display: inline-block;
  margin: 12px 0 0;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--violet);
  color: var(--violet);
  font-weight: 700;
  font-size: 0.85rem;
}

.round-badge.hidden { display: none; }

.victory-quote {
  margin: 8px 0 14px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text);
}

.victory-quote::before { content: '"'; color: var(--amber); font-weight: 900; }
.victory-quote::after { content: '"'; color: var(--amber); font-weight: 900; }

.victory-quote.hidden { display: none; }

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.retired-panel { opacity: 0.85; }
.retired-panel.hidden { display: none; }

.retired-season-group {
  margin-bottom: 14px;
}

.retired-season-group:last-child { margin-bottom: 0; }

.retired-season-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.4px;
  margin: 0 0 6px;
}

.retired-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(232, 227, 210, 0.03);
  font-size: 0.85rem;
  filter: grayscale(0.4);
}

.retired-item .rank { font-weight: 900; width: 26px; flex-shrink: 0; color: var(--muted); }
.retired-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.retired-item .record { color: var(--muted); font-size: 0.78rem; flex-shrink: 0; white-space: nowrap; }

.ranking-list-scroll {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  background: var(--panel-2);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ranking-item:hover { border-color: rgba(201, 168, 106, 0.4); transform: translateY(-1px); }

.ranking-item.compact {
  padding: 6px 12px;
  font-size: 0.8rem;
  gap: 8px;
}

.ranking-item.compact .rank { width: 22px; font-size: 0.85rem; }
.ranking-item.compact .record { font-size: 0.75rem; }

.ranking-item .rank { font-weight: 900; width: 28px; flex-shrink: 0; color: var(--violet); }
.ranking-item .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-item .record { color: var(--muted); font-size: 0.85rem; flex-shrink: 0; white-space: nowrap; }

.ranking-item.is-me { border-color: var(--violet); background: rgba(201, 168, 106, 0.1); }

.top-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 6px 0 26px;
  align-items: end;
  padding-top: 16px;
}

.top-three.hidden { display: none; }

/* No card/plate at all — the rank's metal color is carried only by the
   portrait ring, medal glow, and name tint, floating directly on the
   panel background. */
.top3-card {
  --rank-glow: rgba(201, 168, 106, 0.28);
  --rank-ring: var(--violet);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 10px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.top3-card:hover { transform: translateY(-4px); }

.top3-1 {
  order: 2;
  z-index: 2;
  --rank-glow: rgba(224, 192, 128, 0.32);
  --rank-ring: var(--amber);
  transform: scale(1.04);
}

.top3-1:hover { transform: scale(1.05) translateY(-4px); }

.top3-crown {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  filter: drop-shadow(0 2px 4px rgba(224, 192, 128, 0.6));
}

.top3-2 {
  order: 1;
  --rank-glow: rgba(180, 196, 216, 0.24);
  --rank-ring: #a9bbd0;
}

.top3-3 {
  order: 3;
  --rank-glow: rgba(214, 166, 124, 0.24);
  --rank-ring: #cf9a6c;
}

.top3-medal {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 6px;
}

.top3-1 .top3-medal { font-size: 1.7rem; }

.top3-img {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 8px;
  flex-shrink: 0;
  border: 2px solid var(--rank-ring);
  box-shadow: 0 0 14px var(--rank-glow);
}

.top3-1 .top3-img { width: 82px; height: 82px; }

.top3-img-empty {
  background: var(--bg-2);
}

.top3-name {
  font-family: 'Cinzel', serif;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.top3-1 .top3-name { font-size: 1.1rem; color: var(--rank-ring); }

.top3-title {
  font-size: 0.72rem;
  color: var(--rank-ring);
  margin-top: 3px;
  letter-spacing: 0.2px;
}

.top3-record {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.top3-bio {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .top-three {
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 4px;
  }

  .top3-card {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    order: initial !important;
    transform: none !important;
  }

  .top3-card:last-child { border-bottom: none; }

  .top3-1:hover { transform: translateY(-3px) !important; }
  .top3-crown { top: 4px; left: 6px; transform: none; }
  .top3-medal { margin-bottom: 0; }
  .top3-img, .top3-1 .top3-img { margin-bottom: 0; width: 60px; height: 60px; }
  .top3-name, .top3-title, .top3-record, .top3-bio { max-width: 100%; }
  .top3-bio { -webkit-line-clamp: 2; }
}

.my-rank-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  margin-bottom: 14px;
  cursor: pointer;
  border: 1px solid var(--amber);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(224, 192, 128, 0.16), rgba(201, 168, 106, 0.05));
  box-shadow: 0 6px 20px rgba(201, 168, 106, 0.2);
}

.my-rank-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.my-rank-card .rank { flex-shrink: 0; font-size: 1.3rem; font-weight: 900; color: var(--amber); width: 32px; text-align: center; }
.my-rank-card .name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-rank-card .user-title { margin: 0; font-size: 0.85rem; color: var(--pink); }
.my-rank-card .record { margin: 0; color: var(--muted); font-size: 0.85rem; }
.my-rank-card .my-tag {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--amber);
  font-weight: 700;
  border: 1px solid rgba(224, 192, 128, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
}

.search-input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.search-input:focus { outline: none; border-color: var(--violet); }

.bio-input {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}

.bio-input:focus { outline: none; border-color: var(--violet); }

.bio-count {
  margin: 6px 0 14px;
  text-align: right;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---- Battle stage & fighter animation ---- */

#duel-arena-panel {
  flex: 1 1 380px;
  align-self: flex-start;
  position: sticky;
  top: 20px;
}

.arena-placeholder-hint {
  text-align: center;
  padding: 40px 12px;
}

.battle-stage {
  position: relative;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 28px;
  border-radius: 16px;
  background: radial-gradient(ellipse at center, rgba(201, 168, 106, 0.12), transparent 70%);
  border: 1px solid var(--border);
  transition: transform 0.1s ease;
  overflow: hidden;
}

.impact-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  font-size: 2.2rem;
  color: var(--blood);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 24px rgba(201, 104, 104, 0.8);
  pointer-events: none;
  z-index: 10;
  animation: impact-pop 0.7s ease forwards;
  white-space: nowrap;
}

.impact-text.ko { color: var(--amber); font-size: 2.5rem; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 24px rgba(224, 192, 128, 0.8); }

.impact-text.ultimate {
  background: linear-gradient(90deg, var(--amber), var(--blood));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 2.8rem;
  filter: drop-shadow(0 0 24px rgba(224, 192, 128, 0.9));
  animation: impact-pop 0.9s ease forwards, ultimate-pulse 0.3s ease infinite;
}

@keyframes ultimate-pulse {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(224, 192, 128, 0.8)); }
  50% { filter: drop-shadow(0 0 32px rgba(201, 104, 104, 0.95)); }
}

.impact-text.levelup {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.8rem;
  filter: drop-shadow(0 0 20px rgba(201, 168, 106, 0.8));
  animation: impact-pop 1s ease forwards;
}

@keyframes impact-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(2deg); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1.05); }
}

.battle-stage.hidden { display: none; }

.battle-stage.shake { animation: stage-shake 0.4s ease; }

@keyframes stage-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) translateY(2px); }
  40% { transform: translateX(9px) translateY(-2px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(5px); }
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 90px;
  transition: transform 0.35s ease, filter 0.35s ease;
}

.fighter .portrait {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #f7f7fb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: filter 0.4s ease;
}

/* ---- Level-tier portrait frames (Lv.3/6/9/12/15+ get a progressively
   fancier border/glow, mirroring the level-tier colors used elsewhere) ---- */
.thumb.frame-t2, .portrait.frame-t2 { border-color: #f5f5f9; }

.thumb.frame-t3, .portrait.frame-t3 {
  border-color: #4ade80;
  box-shadow: 0 0 6px 1px rgba(74, 222, 128, 0.6);
}

.thumb.frame-t4, .portrait.frame-t4 {
  border-color: #22d3ee;
  box-shadow: 0 0 8px 1px rgba(34, 211, 238, 0.65);
}

.thumb.frame-t5, .portrait.frame-t5 {
  border-color: #f472b6;
  box-shadow: 0 0 10px 2px rgba(244, 114, 182, 0.7);
}

.thumb.frame-t6, .portrait.frame-t6 {
  border-width: 2px;
  border-color: #fbbf24;
  box-shadow: 0 0 14px 3px rgba(251, 191, 36, 0.85);
}

/* Lv.20+ — the growth ceiling keeps escalating past the old Lv.15 cap so
   there's always a next visual milestone to chase. */
.thumb.frame-t6b, .portrait.frame-t6b {
  border-width: 2px;
  border-color: #fb923c;
  box-shadow: 0 0 15px 3px rgba(251, 146, 60, 0.85);
}

.thumb.frame-t7, .portrait.frame-t7 {
  border-width: 2px;
  border-color: #f87171;
  box-shadow: 0 0 16px 3px rgba(248, 113, 113, 0.9);
}

.thumb.frame-t8, .portrait.frame-t8 {
  border-width: 2.5px;
  border-color: #c084fc;
  box-shadow: 0 0 18px 4px rgba(192, 132, 252, 0.9);
}

.thumb.frame-t9, .portrait.frame-t9 {
  border-width: 2.5px;
  border-color: #ffffff;
  box-shadow: 0 0 22px 5px rgba(255, 255, 255, 0.9);
}

@keyframes frame-shimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

@keyframes frame-prism {
  0% { border-color: #fbbf24; box-shadow: 0 0 22px 5px rgba(251, 191, 36, 0.85); }
  25% { border-color: #f472b6; box-shadow: 0 0 22px 5px rgba(244, 114, 182, 0.85); }
  50% { border-color: #22d3ee; box-shadow: 0 0 22px 5px rgba(34, 211, 238, 0.85); }
  75% { border-color: #c084fc; box-shadow: 0 0 22px 5px rgba(192, 132, 252, 0.85); }
  100% { border-color: #fbbf24; box-shadow: 0 0 22px 5px rgba(251, 191, 36, 0.85); }
}

.thumb.frame-t3, .portrait.frame-t3 { animation: frame-shimmer 3.2s ease-in-out infinite; }
.thumb.frame-t4, .portrait.frame-t4 { animation: frame-shimmer 2.8s ease-in-out infinite; }
.thumb.frame-t5, .portrait.frame-t5 { animation: frame-shimmer 2.4s ease-in-out infinite; }
.thumb.frame-t6, .portrait.frame-t6 { animation: frame-shimmer 2s ease-in-out infinite; }
.thumb.frame-t6b, .portrait.frame-t6b { animation: frame-shimmer 1.8s ease-in-out infinite; }
.thumb.frame-t7, .portrait.frame-t7 { animation: frame-shimmer 1.6s ease-in-out infinite; }
.thumb.frame-t8, .portrait.frame-t8 { animation: frame-shimmer 1.4s ease-in-out infinite; }
.thumb.frame-t9, .portrait.frame-t9 { animation: frame-prism 3s linear infinite; }

.hp-bar {
  width: 110px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  box-shadow: 0 0 10px rgba(143, 191, 138, 0.6);
  transition: width 0.5s ease, background 0.5s ease, box-shadow 0.5s ease;
}

.hp-bar-fill.hp-mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 10px rgba(224, 192, 128, 0.6); }
.hp-bar-fill.hp-low { background: linear-gradient(90deg, #e11d48, #f43f5e); box-shadow: 0 0 10px rgba(201, 104, 104, 0.7); }

.xp-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}

.xp-bar-fill {
  height: 100%;
  background: var(--gradient);
  box-shadow: 0 0 10px rgba(201, 168, 106, 0.6);
  transition: width 0.4s ease;
}

.fighter-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  max-width: 90px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 400;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 1.3rem;
}

/* condition (persistent damage state) */
.fighter.cond-unharmed .portrait,
.fighter.cond-fine .portrait { filter: brightness(1) saturate(1); }
.fighter.cond-pressured .portrait { filter: brightness(0.9) saturate(0.9); }
.fighter.cond-danger .portrait { filter: brightness(0.75) saturate(0.7) hue-rotate(-8deg); }
.fighter.cond-critical .portrait { filter: brightness(0.58) saturate(0.5) hue-rotate(-12deg); }
.fighter.cond-ko .portrait { filter: grayscale(1) brightness(0.4); }
.fighter.cond-ko { transform: rotate(-4deg) translateY(4px); opacity: 0.65; }

/* momentary attack lunge */
.fighter.attacking .portrait {
  animation: lunge 0.45s ease;
  box-shadow: 0 0 26px rgba(201, 168, 106, 0.7);
}

@keyframes lunge {
  0% { transform: scale(1); }
  35% { transform: scale(1.12) translateY(-4px); }
  100% { transform: scale(1); }
}

/* momentary hit shake, intensity by tier */
.fighter.hit-light .portrait { animation: shake-light 0.4s ease; }
.fighter.hit-medium .portrait { animation: shake-medium 0.4s ease; }
.fighter.hit-strong .portrait { animation: shake-strong 0.45s ease; }
.fighter.hit-critical .portrait { animation: shake-critical 0.5s ease; }
.fighter.hit-ultimate .portrait { animation: shake-ultimate 0.6s ease; }

.fighter.hit-light .portrait,
.fighter.hit-medium .portrait,
.fighter.hit-strong .portrait,
.fighter.hit-critical .portrait {
  box-shadow: 0 0 20px rgba(201, 104, 104, 0.75);
}

.fighter.hit-ultimate .portrait {
  box-shadow: 0 0 34px rgba(224, 192, 128, 0.95), 0 0 14px rgba(201, 104, 104, 0.8);
}

@keyframes shake-ultimate {
  0%, 100% { transform: translateX(0) scale(1); }
  15% { transform: translateX(-16px) scale(0.92) rotate(-4deg); }
  35% { transform: translateX(16px) scale(0.92) rotate(4deg); }
  55% { transform: translateX(-10px) scale(1.05); }
  75% { transform: translateX(10px); }
}

@keyframes shake-light {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-3px); }
}
@keyframes shake-medium {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes shake-strong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-2deg); }
  60% { transform: translateX(9px) rotate(2deg); }
}
@keyframes shake-critical {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(-12px) scale(0.96); }
  50% { transform: translateX(12px) scale(0.96); }
  80% { transform: translateX(-6px); }
}

/* ---- Chat ---- */

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.chat-message {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.chat-nickname {
  font-weight: 700;
  color: var(--cyan);
  flex-shrink: 0;
}

.chat-message.mine .chat-nickname { color: var(--pink); }

.chat-bubble {
  color: var(--text);
  word-break: break-word;
}

.chat-time {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 10px;
}

.chat-input-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
}

.chat-input-row input:focus { outline: none; border-color: var(--violet); }
.chat-input-row input:disabled { opacity: 0.5; }

/* ---- Floating chat widget (all pages) ---- */

.chat-widget {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 200;
  font-family: 'Noto Sans KR', sans-serif;
}

.chat-widget.open .chat-widget-toggle { display: none; }
.chat-widget.collapsed .chat-widget-panel { display: none; }

.chat-widget-toggle {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient);
  color: #0a0a12;
  font-size: 1.4rem;
  border: none;
  box-shadow: 0 8px 24px rgba(201, 168, 106, 0.5);
  cursor: pointer;
}

.chat-widget-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--blood);
  border: 2px solid var(--bg);
}

.chat-widget-badge.hidden { display: none; }

.chat-widget-panel {
  display: flex;
  flex-direction: column;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 290px;
  max-width: calc(100vw - 40px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(201, 168, 106, 0.15);
  overflow: hidden;
}

.chat-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}

.chat-widget-header span { flex: 1; }

.chat-widget-expand,
.chat-widget-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  padding: 2px 4px;
  line-height: 1;
}

.chat-widget-expand:hover,
.chat-widget-close:hover { color: var(--text); }

.chat-widget-list {
  height: 240px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.8rem;
}

.chat-widget-message {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--text);
  word-break: break-word;
}

.chat-widget-nick { font-weight: 700; color: var(--cyan); flex-shrink: 0; }
.chat-widget-message.mine .chat-widget-nick { color: var(--pink); }

.chat-widget-time {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-widget-empty { color: var(--muted); font-size: 0.78rem; }

.chat-widget-input-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.chat-widget-input-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
}

.chat-widget-input-row input:disabled { opacity: 0.5; }
.chat-widget-input-row input:focus { outline: none; border-color: var(--violet); }

.chat-widget-input-row button {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--gradient);
  color: #0a0a12;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.chat-widget-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-widget-error {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 0.72rem;
  color: var(--blood);
  min-height: 0;
}

@media (max-width: 480px) {
  .chat-widget {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .chat-widget-panel { width: calc(100vw - 24px); }
}

/* iOS Safari zooms the page in when a focused input's font is under 16px —
   force every text control up to that size on small/touch screens without
   changing the more compact desktop sizing. */
@media (max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important;
  }

  main {
    padding: 20px 16px 40px;
    gap: 14px;
  }

  /* Two-column arena layout only makes sense once panels sit side by side;
     on narrow screens they stack, so sticky positioning would just pin the
     arena awkwardly mid-scroll instead of helping. */
  #duel-arena-panel {
    position: static;
    flex-basis: auto;
  }

  header {
    padding: 32px 16px 18px;
  }

  .site-nav {
    padding: 12px 12px;
    gap: 8px;
  }

  .nav-link {
    padding: 9px 14px;
    font-size: 0.8rem;
  }

  /* Trim panel padding so content (especially the canvas) has more real
     usable width on phone screens instead of losing 48px to gutters. */
  .panel {
    min-width: 0;
    padding: 14px;
  }

  #draw-panel {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* The canvas is a fixed 480x480 drawing surface (see home.js getPos,
     which already scales pointer coords against the rendered size), so
     letting its CSS size grow past the old 480px cap is purely visual —
     it just renders bigger/crisper on wide phones instead of floating in
     a lot of empty side margin. */
  canvas {
    max-width: 100%;
  }

  .draw-toolbar {
    padding: 8px;
    gap: 6px;
  }

  .draw-toolbar input[type='range'] {
    width: 70px;
  }

  /* Apple/Google's ~44px minimum touch-target guidance — the desktop
     36px buttons are a bit small to reliably tap with a thumb. */
  .tool-btn,
  #clearBtn {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .draw-toolbar input[type='color'] {
    width: 42px;
    height: 36px;
  }

  /* Popularity now has a bigger home next to the photo in the expanded
     detail panel, so the small row-level badge is redundant clutter on
     narrow screens where every pixel of row width matters. */
  .row-vote-badge {
    display: none;
  }
}

@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}
