:root {
  --bg1: #0f1226;
  --bg2: #171b34;
  --card: rgba(255, 255, 255, 0.14);
  --cursor-default: url("../images/cursors/sticker-cursor.png") 16 16;
  --text: #f5f7ff;
  --muted: #d9e1ff;
  --line: rgba(233, 221, 255, 0.4);
  --accent: #ff7ab6;
  --ok: #2fba7a;
  --shadow: 0 18px 40px rgba(8, 10, 24, 0.4);
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', 'Apple SD Gothic Neo', sans-serif;
  color: var(--text);
  background: url("../images/backgrounds/bingo-background.jpg") center/cover no-repeat fixed;
  padding: 24px 16px 42px;
  overflow-x: hidden;
}

html,
body,
body * {
  cursor: var(--cursor-default), auto !important;
}

button:hover,
button:active,
button:focus,
a:hover,
a:active,
a:focus,
.cell:hover,
.player-btn:hover,
.emoji-btn:hover,
.icon-btn:hover,
.mode-btn:hover,
.btn:hover {
  cursor: var(--cursor-default), pointer !important;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.hero {
  text-align: center;
  margin-bottom: 18px;
  animation: soft-float 5.5s ease-in-out infinite;
}

.current-profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: 10px;
}

.current-profile-pill.sidebar {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 8px 10px;
}

h1 {
  margin: 0;
  font-family: 'Gaegu', cursive;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.5);
}

.subtitle {
  margin-top: 8px;
  color: #f5f7ff;
  font-size: 0.96rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.countdown {
  margin-top: 10px;
  display: inline-block;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.86rem;
  color: #f4f7ff;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(147, 101, 210, 0.15);
  animation: countdown-glow 2.4s ease-in-out infinite;
}

.layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: none;
  transition: transform .25s ease, box-shadow .25s ease;
}

.layout > main.card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
}

.layout > aside.card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(2px);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 44px rgba(8, 10, 24, 0.5);
}

.card h2,
.card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row.wrap {
  flex-wrap: wrap;
}

input,
textarea,
button {
  font: inherit;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

.input:focus,
.textarea:focus {
  border-color: #ffb9d8;
  box-shadow: 0 0 0 3px rgba(255, 122, 182, 0.16);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 700;
  background: var(--accent);
  color: white;
  transition: transform .12s ease, opacity .2s ease, box-shadow .18s ease, filter .18s ease;
  position: relative;
  overflow: hidden;
}

#createOrLoadBtn {
  min-width: 72px;
  flex: 0 0 auto;
}

.btn:hover {
  transform: translateY(-1px);
  opacity: .93;
}

.btn:active {
  transform: translateY(1px) scale(0.985);
  filter: brightness(0.96);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none;
}

.btn.secondary {
  background: #8f88a6;
}

.btn.sky {
  background: #4fa6ff;
}

.btn.mint {
  background: #2fbf8d;
}

.small {
  font-size: .86rem;
  color: var(--muted);
}

.profile-status {
  margin-top: 0;
  background: transparent;
  border: none;
  color: #f1f5ff;
  border-radius: 0;
  padding: 0;
  font-size: .9rem;
  font-weight: 800;
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 2px solid #ffd4e8;
  background: linear-gradient(140deg, #ffe9f5, #e8f4ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex: 0 0 auto;
  overflow: hidden;
}

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

.player-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.player-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  display: grid;
  gap: 6px;
}

.player-btn.active {
  border-color: #ffc0de;
  background: rgba(255, 122, 182, 0.16);
  box-shadow: 0 0 0 2px rgba(255, 122, 182, 0.3), 0 8px 18px rgba(255, 88, 166, 0.22);
}

.player-btn.mine {
  border-color: rgba(159, 223, 255, 0.78);
  background: rgba(115, 182, 255, 0.14);
  box-shadow: 0 8px 16px rgba(4, 18, 42, 0.32);
}

.player-btn.mine .player-title strong {
  color: #d6efff;
}

.player-btn.mine.active {
  border-color: #9fdaff;
  background: rgba(111, 191, 240, 0.22);
  box-shadow: 0 0 0 2px rgba(111, 191, 240, 0.4), 0 8px 20px rgba(89, 178, 230, 0.3);
}

.player-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: .82rem;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.player-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid #f1d7ff;
  background: linear-gradient(130deg, #ffe8f5, #dff3ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  overflow: hidden;
  flex: 0 0 auto;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #edf2ff;
  padding: 4px 8px;
  font-size: .78rem;
  font-weight: 700;
}

.chip.ok {
  background: rgba(47, 186, 122, 0.2);
  color: #c8ffe3;
}

.chip.warn {
  background: rgba(255, 122, 182, 0.2);
  color: #ffd7ea;
}

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

.board-title {
  margin: 0;
  font-size: 1.2rem;
}

.board-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-left: auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.cell {
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 6px;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform .11s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
  user-select: none;
  backdrop-filter: blur(2px);
}

.cell:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.4);
}

.cell .emoji {
  font-size: 1.5rem;
  line-height: 1.1;
}

.cell .text {
  margin-top: 4px;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
  color: #f2f6ff;
}

.cell.checked {
  background: linear-gradient(165deg, rgba(255, 122, 182, 0.42), rgba(79, 166, 255, 0.38));
  border-color: rgba(255, 204, 230, 0.98);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .38), 0 0 20px rgba(255, 110, 186, 0.38);
  animation: cell-pop .24s ease;
}

.cell.checked .emoji,
.cell.checked .text {
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(18, 8, 34, 0.55);
}

.cell.readonly {
  cursor: default;
  opacity: .92;
}

.cell.selected {
  border-color: #62b4ff;
  box-shadow: 0 0 0 2px rgba(98, 180, 255, .2);
}

.board-wrap {
  position: relative;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 10px;
  backdrop-filter: blur(2px);
}

.line-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.bingo-line {
  stroke: #ff4f9f;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  filter: drop-shadow(0 0 8px rgba(255, 91, 164, .45));
  animation: draw-line .7s ease forwards;
}

.mode-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.mode-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.mode-btn.active {
  background: rgba(255, 122, 182, 0.3);
  border-color: rgba(255, 193, 220, 0.86);
  color: #fff2f8;
}

.editor-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(39, 22, 60, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

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

.success-flash,
.check-flash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 140;
}

.success-flash.hidden,
.check-flash.hidden {
  display: none;
}

.success-flash img,
.check-flash img {
  width: min(460px, 76vw);
  max-height: 62vh;
  object-fit: contain;
  filter: drop-shadow(0 12px 34px rgba(0, 0, 0, 0.45));
}

.success-flash img {
  animation: success-burst 1.1s ease forwards;
}

.check-flash img {
  animation: check-burst .8s ease forwards;
}

.modal-card {
  width: min(560px, 100%);
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  border: 1px solid #efdefc;
  box-shadow: 0 20px 50px rgba(70, 40, 100, 0.25);
  padding: 16px;
  backdrop-filter: blur(2px) saturate(1.16);
}

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

.modal-head h3 {
  margin: 0;
}

.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-weight: 700;
  color: #f1f5ff;
}

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

.emoji-btn {
  border: 1px solid #eadfff;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  cursor: pointer;
  height: 34px;
  line-height: 1;
  font-size: 1.1rem;
}

.emoji-btn:hover {
  background: #fff2fa;
  border-color: #ffc0de;
}

.win-banner {
  margin-top: 12px;
  border-radius: 14px;
  padding: 12px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff0a6, #ffc7df);
  color: #6d3a57;
  border: 1px solid #ffd67c;
}

.empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #dbcaf8;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .26;
}

.orb-a {
  width: 240px;
  height: 240px;
  left: -40px;
  top: 18%;
  background: radial-gradient(circle, #ffd8ea, transparent 70%);
  animation: drift-a 14s ease-in-out infinite;
}

.orb-b {
  width: 320px;
  height: 320px;
  right: -70px;
  top: 10%;
  background: radial-gradient(circle, #d6f0ff, transparent 70%);
  animation: drift-b 16s ease-in-out infinite;
}

.orb-c {
  width: 260px;
  height: 260px;
  left: 38%;
  bottom: -110px;
  background: radial-gradient(circle, #ffeab8, transparent 70%);
  animation: drift-c 18s ease-in-out infinite;
}

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

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid #e4d0f8;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.24);
  color: #6d4f8e;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  position: relative;
  overflow: hidden;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: #fff3fa;
  border-color: #ffc0de;
}

.icon-btn:active {
  transform: translateY(1px) scale(0.96);
}

.icon-btn.is-active {
  background: linear-gradient(140deg, #ffe4f2, #e5f5ff);
  border-color: #ff9dcb;
  color: #9f2f66;
  box-shadow: inset 0 0 0 1px rgba(255, 122, 182, 0.25);
}

.btn.click-pop,
.icon-btn.click-pop {
  animation: click-pop .28s ease;
}

.btn.click-pop::after,
.icon-btn.click-pop::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid rgba(255, 255, 255, 0.65);
  animation: click-ring .28s ease;
}

.music-widget-floating {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 232px;
  padding: 0 12px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(2px);
  box-shadow: 0 10px 24px rgba(61, 38, 93, 0.2);
  z-index: 25;
}

.music-preview {
  width: calc(100% + 24px);
  margin: 0 -12px 10px;
  aspect-ratio: 9 / 16;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.24);
}

.music-preview video,
.music-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  object-fit: cover;
}

.music-head.compact {
  gap: 4px;
  align-items: center;
}

.music-head.compact strong {
  font-size: .8rem;
}

.music-head.compact .small {
  font-size: .72rem;
  flex: 1 1 auto;
}

.music-toggle-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 8px;
  font-size: .92rem;
  padding: 0;
}

.music-widget-floating.collapsed {
  width: 170px;
  padding-top: 8px;
}

.music-widget-floating.collapsed .music-preview,
.music-widget-floating.collapsed .row.wrap,
.music-widget-floating.collapsed .volume-range.compact {
  display: none;
}

.music-widget-floating.collapsed .music-toggle-btn {
  transform: rotate(180deg);
}

.volume-range.compact {
  margin-top: 8px;
}

.volume-range {
  width: 100%;
}

#ytPlayerHost {
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes countdown-glow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(147, 101, 210, 0.25); }
}

@keyframes soft-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes cell-pop {
  0% { transform: scale(.92); }
  100% { transform: scale(1); }
}

@keyframes drift-a {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(18px, -14px); }
}

@keyframes drift-b {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-20px, 16px); }
}

@keyframes drift-c {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10px, -20px); }
}

@keyframes click-pop {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

@keyframes click-ring {
  0% { opacity: .8; transform: scale(.92); }
  100% { opacity: 0; transform: scale(1.2); }
}

@keyframes success-burst {
  0% { opacity: 0; transform: scale(0.7); }
  14% { opacity: 1; transform: scale(1.08); }
  32% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.88); }
}

@keyframes check-burst {
  0% { opacity: 0; transform: scale(0.72); }
  18% { opacity: 1; transform: scale(1.04); }
  40% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9); }
}

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

  .board {
    gap: 6px;
  }

  .cell {
    min-height: 85px;
  }

  .board-meta {
    width: 100%;
    justify-content: flex-end;
  }

  .music-widget-floating {
    width: 204px;
    right: 10px;
    bottom: 10px;
  }
}
