:root {
  font-family: Inter, "Pretendard", "Segoe UI", system-ui, sans-serif;
  color: #e8edf7;
  background: #080d17;
  color-scheme: dark;
  --bg: #080d17;
  --surface: #101827;
  --surface-2: #151f31;
  --surface-3: #1b273b;
  --line: #26344b;
  --line-soft: #ffffff12;
  --text: #e8edf7;
  --muted: #8f9bb0;
  --accent: #7568ff;
  --accent-2: #4bc7e8;
  --danger: #ff6676;
}

* { box-sizing: border-box; }

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 2%, #263265 0, transparent 31rem),
    radial-gradient(circle at 88% 95%, #123b4f 0, transparent 28rem),
    linear-gradient(145deg, #080d17, #0c1321 52%, #09101b);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .19;
  background-image:
    linear-gradient(#b8c6ff0a 1px, transparent 1px),
    linear-gradient(90deg, #b8c6ff0a 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.shell { max-width: 1240px; margin: auto; padding: 24px; }

header {
  display: flex;
  min-height: 52px;
  margin-bottom: 20px;
  align-items: center;
  justify-content: space-between;
}

header b {
  color: #a99fff;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.04em;
  text-shadow: 0 0 22px #7668ff66;
}

header span { margin-left: 12px; color: var(--muted); }

.panel {
  margin-bottom: 18px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid #ffffff14;
  border-radius: 18px;
  background: linear-gradient(145deg, #151e2ee8, #0f1725f2);
  box-shadow: 0 22px 55px #0007, inset 0 1px #ffffff0a;
  backdrop-filter: blur(18px);
}

.auth {
  position: relative;
  max-width: 410px;
  margin: 9vh auto;
  padding: 32px;
  border-color: #8e83ff38;
  box-shadow: 0 28px 80px #000a, 0 0 0 1px #ffffff08, 0 0 70px #6558e820;
}

.auth::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #786cff, #4bc7e8, transparent);
}

.auth h1 { margin: 7px 0 22px; font-size: 30px; letter-spacing: -.04em; }
.auth input, .auth button { width: 100%; margin-top: 10px; }

.eyebrow {
  margin: 0;
  color: #988eff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .18em;
}

.layout { display: flex; gap: 18px; }
.grow { flex: 1; min-width: 0; }
aside { width: 330px; }
.section-title, .game-head { display: flex; align-items: center; justify-content: space-between; }
.section-title h2 { margin: 5px 0 0; letter-spacing: -.035em; }

button, input, select {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #34435a;
  border-radius: 10px;
  outline: 0;
  color: var(--text);
  background: #111a29;
  font: inherit;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}

input::placeholder { color: #69768b; }
input:focus, select:focus {
  border-color: #8176ff;
  box-shadow: 0 0 0 3px #7568ff26;
  background: #162135;
}

button { cursor: pointer; background: #1a2538; }
button:hover:not(:disabled) { border-color: #536680; background: #223048; transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: .46; }

.primary {
  border-color: #776bff;
  color: white;
  background: linear-gradient(135deg, #776bff, #594be8);
  box-shadow: 0 8px 22px #594be833;
}

.primary:hover:not(:disabled) { border-color: #9c94ff; background: linear-gradient(135deg, #877dff, #6759ef); }
.danger { border-color: #ff66764a; color: #ff9aa5; background: #3a1822; }
.danger:hover:not(:disabled) { border-color: #ff7d89; background: #4a1c28; }
.link { min-height: auto; border: 0; color: #a9a1ff; background: transparent; box-shadow: none; }
.link:hover:not(:disabled) { color: #d2ceff; background: #ffffff08; }
.error { min-height: 20px; color: #ff8190; }

.rooms { display: grid; gap: 10px; margin-top: 18px; color: var(--muted); }
.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: linear-gradient(120deg, #172235, #121b2a);
  box-shadow: inset 0 1px #ffffff08;
  transition: border-color .15s ease, transform .15s ease;
}
.room-card:hover { border-color: #4b5d78; transform: translateY(-1px); }
.room-card small { color: var(--muted); line-height: 2; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 99px; color: #c4beff; background: #776bff20; font-size: 12px; }

.messages {
  height: 240px;
  padding: 10px;
  overflow: auto;
  border: 1px solid #ffffff0b;
  border-radius: 12px;
  color: #cbd4e3;
  background: #09111de0;
  scrollbar-color: #3d4b63 transparent;
}
.messages div { padding: 6px 4px; border-bottom: 1px solid #ffffff08; word-break: break-word; }
.messages b { color: #9c93ff; }
.send { display: flex; gap: 6px; margin-top: 8px; }
.send input { flex: 1; min-width: 0; }

.room-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.room-columns > div { padding: 4px 14px 14px; border: 1px solid #ffffff0c; border-radius: 14px; background: #0b1421a6; }
.player { padding: 12px; border-bottom: 1px solid #ffffff0c; color: #d6deeb; }
.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.setting-grid label { color: var(--muted); font-size: 12px; }
.setting-grid input { display: block; width: 100%; margin-top: 4px; }
.wide { width: 100%; margin-top: 16px; }
.tall { height: 440px; }

canvas { display: block; max-width: 100%; margin: 15px auto; border-radius: 8px; background: #202b3b; }
.apple-board { display: grid; max-width: 900px; margin: 15px auto; gap: 4px; user-select: none; touch-action: none; }
.apple { display: grid; aspect-ratio: 1; place-items: center; border-radius: 50%; background: #ffad73; font-weight: 800; cursor: crosshair; }
.apple.selected { background: #ff653f; transform: scale(1.08); }
.apple.cleared { visibility: hidden; }

dialog {
  min-width: 360px;
  padding: 24px;
  border: 1px solid #ffffff1c;
  border-radius: 18px;
  color: var(--text);
  background: linear-gradient(145deg, #182337, #0d1522);
  box-shadow: 0 25px 90px #000c;
}
dialog::backdrop { background: #030712c7; backdrop-filter: blur(5px); }
dialog label { display: block; margin: 10px 0; color: #aab5c7; }
dialog input, dialog select { display: block; width: 100%; margin-top: 4px; }
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px; border-bottom: 1px solid #ffffff16; text-align: left; }
th { color: #a69eff; }

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  z-index: 100;
  display: none;
  padding: 11px 17px;
  transform: translateX(-50%);
  border: 1px solid #ffffff18;
  border-radius: 10px;
  color: white;
  background: #151e2ff2;
  box-shadow: 0 12px 35px #0009;
}

@media (max-width: 850px) {
  .layout { display: block; }
  aside { width: auto; }
  .room-columns { grid-template-columns: 1fr; }
  .shell { padding: 12px; }
  .auth { margin: 7vh auto; padding: 25px; }
}
