:root {
  color-scheme: light;
  --ink: #171717;
  --text: #24272d;
  --muted: #66707d;
  --line: #dce3ea;
  --soft-line: #eef2f5;
  --page: #f6f8fa;
  --panel: #ffffff;
  --green: #138a63;
  --green-soft: #e6f6ef;
  --cyan: #168b96;
  --cyan-soft: #e6f6f8;
  --yellow: #f2c94c;
  --red: #d94f45;
  --red-soft: #fff0ee;
  --shadow: 0 18px 50px rgba(23, 23, 23, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(22, 139, 150, 0.09), transparent 280px),
    var(--page);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0.78rem 1rem;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(23, 23, 23, 0.14);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.05;
  color: var(--ink);
}

h3 {
  color: var(--ink);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 8px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #ffffff, var(--cyan-soft));
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.brand-mark svg {
  width: 31px;
  height: 31px;
}

.hint,
.message {
  color: var(--muted);
  line-height: 1.5;
}

.message {
  min-height: 1.5em;
  font-weight: 700;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-weight: 800;
  padding: 0.65rem 0.8rem;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(23, 23, 23, 0.05);
}

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

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
}

.dot.connected {
  background: var(--green);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.join-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 22px;
  align-items: stretch;
}

.intro {
  min-height: 560px;
  display: grid;
  align-content: center;
  gap: 26px;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(230, 246, 248, 0.84)),
    var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--soft-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--soft-line) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, black, transparent 84%);
  opacity: 0.78;
  pointer-events: none;
}

.intro::after {
  content: "";
  position: absolute;
  right: 42px;
  bottom: 42px;
  width: 190px;
  height: 118px;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(var(--ink), var(--ink)) 18px 20px / 154px 12px no-repeat,
    linear-gradient(var(--green), var(--green)) 18px 48px / 48px 12px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) 76px 48px / 40px 12px no-repeat,
    linear-gradient(var(--yellow), var(--yellow)) 126px 48px / 46px 12px no-repeat,
    linear-gradient(var(--red), var(--red)) 18px 76px / 100px 12px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 128px 76px / 44px 12px no-repeat,
    rgba(255, 255, 255, 0.78);
  box-shadow: 0 20px 44px rgba(23, 23, 23, 0.1);
  opacity: 0.72;
}

.intro > * {
  position: relative;
  z-index: 1;
}

.intro-title {
  max-width: 760px;
  color: var(--ink);
  font-size: 4.25rem;
  line-height: 0.98;
}

.intro-copy {
  max-width: 650px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.65;
}

.falling-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 720px;
}

.preview-word {
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 10px 18px rgba(23, 23, 23, 0.07);
  padding: 0.55rem 0.72rem;
  font-weight: 900;
}

.preview-word:nth-child(2n) {
  background: var(--green-soft);
}

.preview-word:nth-child(3n) {
  background: var(--red-soft);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 20px;
}

.join-panel,
.lobby-actions,
.config-panel,
.scoreboard,
.events {
  display: grid;
  gap: 12px;
}

.join-panel {
  align-content: start;
}

.form-row {
  display: grid;
  gap: 7px;
}

label {
  color: var(--ink);
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.78rem 0.9rem;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
  outline: none;
  transition: border 140ms ease, box-shadow 140ms ease;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 20px / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 20px / 7px 7px no-repeat,
    #fff;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(22, 139, 150, 0.14);
}

input:disabled,
select:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background-color: #f3f6f8;
}

.mode-actions,
.two-buttons {
  display: grid;
  gap: 10px;
}

.settings-card {
  display: grid;
  gap: 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

.settings-head {
  display: grid;
  gap: 5px;
}

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

.settings-grid.compact {
  grid-template-columns: 1fr 1fr;
}

.settings-wide {
  grid-column: 1 / -1;
}

.two-buttons {
  grid-template-columns: 1fr 1fr;
}

.secondary {
  background: var(--green);
}

.accent {
  background: var(--red);
}

.solo {
  background: var(--cyan);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.arena-wrap {
  display: grid;
  gap: 12px;
}

.arena-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.room-code {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.55rem 0.72rem;
  color: var(--muted);
  font-weight: 850;
}

.code-box {
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  padding: 0.26rem 0.5rem;
  letter-spacing: 0;
  white-space: nowrap;
}

.timer {
  min-width: 92px;
  min-height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 0.65rem 0.8rem;
  font-weight: 950;
  text-align: center;
}

.arena {
  height: min(66vh, 650px);
  min-height: 440px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(230, 246, 248, 0.62)),
    repeating-linear-gradient(90deg, transparent 0 24.8%, rgba(23, 23, 23, 0.055) 24.8% 25%, transparent 25% 49.8%, rgba(23, 23, 23, 0.055) 49.8% 50%),
    linear-gradient(135deg, rgba(242, 201, 76, 0.2), rgba(19, 138, 99, 0.16));
  box-shadow: 0 22px 54px rgba(23, 23, 23, 0.13);
}

.arena::before {
  content: "TYPE ZONE";
  position: absolute;
  top: 14px;
  right: 14px;
  color: rgba(23, 23, 23, 0.26);
  font-size: 0.78rem;
  font-weight: 900;
}

.skyline {
  position: absolute;
  inset: auto 0 0;
  height: 86px;
  background:
    linear-gradient(var(--ink), var(--ink)) 3% 48% / 7% 52% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 14% 34% / 10% 66% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 31% 58% / 8% 42% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 46% 42% / 12% 58% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 65% 50% / 9% 50% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 82% 31% / 12% 69% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 96% 54% / 7% 46% no-repeat;
  opacity: 0.08;
  pointer-events: none;
}

.word {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(23, 23, 23, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: var(--word-bg);
  box-shadow: 0 12px 20px rgba(23, 23, 23, 0.14);
  padding: 0.42rem 0.68rem;
  font-weight: 950;
  white-space: nowrap;
  line-height: 1;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.word.matching {
  outline: 4px solid rgba(19, 138, 99, 0.24);
}

.word-char {
  min-width: 0.62em;
  border-radius: 4px;
  text-align: center;
  transition: background 120ms ease, color 120ms ease;
}

.typed-char {
  background: rgba(23, 23, 23, 0.9);
  color: #fff;
}

.next-char {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 -3px 0 var(--green);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.type-input {
  border: 1px solid rgba(23, 23, 23, 0.18);
  box-shadow: 0 14px 30px rgba(23, 23, 23, 0.08);
  font-size: 1.08rem;
}

.sidebar {
  display: grid;
  gap: 12px;
}

.score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 8px;
  background: #fff;
}

.score-card.me {
  border-color: rgba(19, 138, 99, 0.28);
  background: var(--green-soft);
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-name {
  color: var(--ink);
  font-weight: 900;
  word-break: break-word;
}

.score-value {
  color: var(--ink);
  font-size: 1.9rem;
  font-weight: 950;
}

.events {
  max-height: 190px;
  overflow: auto;
}

.event {
  border-left: 4px solid var(--cyan);
  border-radius: 0 8px 8px 0;
  padding: 0.48rem 0.58rem;
  background: var(--cyan-soft);
  color: var(--muted);
  font-weight: 750;
}

.result {
  display: none;
  border: 1px solid rgba(19, 138, 99, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green-soft), #fff);
  box-shadow: var(--shadow);
  padding: 18px;
  gap: 10px;
}

.result.active {
  display: grid;
}

.copy-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--muted);
  padding: 0.72rem;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.35;
}

@media (max-width: 900px) {
  .join-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .intro {
    min-height: 460px;
  }

  .intro-title {
    font-size: 3.1rem;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.35rem;
  }

  .shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .arena-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .status-pill,
  .timer {
    width: 100%;
  }

  .two-buttons,
  .settings-grid,
  .settings-grid.compact,
  .input-row {
    grid-template-columns: 1fr;
  }

  .settings-wide {
    grid-column: auto;
  }

  .intro {
    min-height: 390px;
    padding: 22px;
  }

  .intro::after {
    display: none;
  }

  .intro-title {
    font-size: 2.25rem;
  }

  .intro-copy {
    font-size: 1rem;
  }

  .arena {
    height: 56vh;
    min-height: 380px;
  }

  .word {
    font-size: 0.9rem;
    min-height: 32px;
  }
}

#typeInput:focus {
  outline: 2px solid #4CAF50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

/* Animasi pulse untuk menunjukkan input siap */
@keyframes inputPulse {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

#typeInput:not(:disabled) {
  animation: inputPulse 2s infinite;
}

/* Mencegah text selection di arena */
#arena {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}