:root {
  color-scheme: dark;
  --ink: #f7fff8;
  --muted: #b8c9bc;
  --jungle-950: #06110a;
  --jungle-900: #0b1d10;
  --jungle-800: #12351b;
  --leaf: #72ff9d;
  --leaf-strong: #2de26a;
  --amber: #ffd166;
  --danger: #ff7b72;
  --glass: rgba(7, 24, 12, 0.82);
  --line: rgba(160, 255, 182, 0.22);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--jungle-950);
  font-family: "Baloo 2", system-ui, sans-serif;
  text-align: center;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    radial-gradient(circle at 50% 20%, rgba(45, 226, 106, 0.08), transparent 32rem),
    linear-gradient(180deg, rgba(3, 12, 6, 0.48), rgba(3, 12, 6, 0.88));
}

.jungle-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: url("img/jungle-bg.jpg") center / cover no-repeat;
  transform: scale(1.02);
}

.lianen-container {
  position: fixed;
  inset: 0 0 auto;
  z-index: 0;
  display: flex;
  height: 150px;
  justify-content: space-between;
  overflow: hidden;
  pointer-events: none;
}

.liane {
  width: min(30vw, 260px);
  height: auto;
  object-fit: contain;
  object-position: top;
  opacity: 0.78;
  transform-origin: top center;
  animation: sway 7s ease-in-out infinite alternate;
}

.liane:last-child { animation-delay: -3s; }

@keyframes sway {
  from { transform: rotate(-1.5deg) translateX(-3px); }
  to { transform: rotate(1.5deg) translateX(3px); }
}

header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  padding: max(0.6rem, env(safe-area-inset-top)) 1rem 0;
  pointer-events: none;
}

nav {
  display: flex;
  width: min(100%, 980px);
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

a { color: inherit; }

.nav-link {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 17, 8, 0.72);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  backdrop-filter: blur(12px);
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(4, 17, 8, 0.72);
  color: var(--leaf);
  font-size: 0.75rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.connection-status::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
  content: "";
}

.connection-status.offline { color: var(--danger); }

#contentWrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: max(4.6rem, calc(3.5rem + env(safe-area-inset-top))) 1rem max(3rem, env(safe-area-inset-bottom));
  scrollbar-color: rgba(114, 255, 157, 0.35) transparent;
  -webkit-overflow-scrolling: touch;
}

#contentWrapper > section,
#statusMessage,
#profile-pic,
footer {
  width: min(100%, 920px);
  margin-inline: auto;
}

#contentWrapper > *,
.room-bar,
.room-heading,
.qr-invite,
.join-room-row,
.join-player-row,
.category-add-row {
  min-width: 0;
  max-width: 100%;
}

#setup {
  display: flex;
  flex-direction: column;
}

#joinPanel { order: 1; }
#setup > .room-bar { order: 2; }
#setup > .join-room-row { order: 3; }
#setup > .lobby-panel { order: 4; }
#setup > #categorySection { order: 5; }

#profile-pic {
  display: flex;
  width: 108px;
  height: 108px;
  margin-bottom: 0.8rem;
  padding: 0;
  border: 2px solid rgba(114, 255, 157, 0.4);
  border-radius: 28px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 38px rgba(45, 226, 106, 0.22);
}

#profileLogo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#profile-pic.localized-brand {
  width: 132px;
  height: 132px;
  padding: 0.4rem 0.45rem 0.5rem;
  flex-direction: column;
  background: linear-gradient(145deg, rgba(16, 55, 25, 0.96), rgba(4, 19, 9, 0.94));
}

#profile-pic.localized-brand #profileLogo {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

#profileTitle {
  color: #fff7d6;
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 0.9;
  text-align: center;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.35rem; font-size: clamp(1.6rem, 4vw, 2.25rem); }
h2 { margin-bottom: 0.5rem; font-size: clamp(1.35rem, 3vw, 1.8rem); }
h3 { margin-bottom: 0.65rem; }
p { color: var(--muted); line-height: 1.45; }

.eyebrow {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--leaf);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.panel,
.phase-card,
#gamePhase,
#resultsPhase {
  margin-bottom: 1rem;
  padding: clamp(1rem, 3vw, 1.7rem);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(13, 43, 21, 0.9), var(--glass));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.room-heading,
.section-heading,
.game-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
}

.room-bar {
  width: 100%;
  margin-bottom: 0.8rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(4, 17, 8, 0.72);
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.room-heading {
  min-height: 58px;
}

.room-heading > div {
  min-width: 0;
}

.qr-invite {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1rem, 4vw, 1.6rem);
  margin-top: 0.8rem;
  padding: 1rem 0.2rem 0.2rem;
  border-top: 1px solid var(--line);
  align-items: center;
}

.qr-frame {
  position: relative;
  padding: 0.55rem;
  border: 1px solid rgba(255, 209, 102, 0.8);
  border-radius: 20px;
  background: white;
  max-width: 100%;
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.1), 0 0 30px rgba(255, 209, 102, 0.2);
}

.qr-frame::after {
  position: absolute;
  inset: -5px;
  z-index: -1;
  border-radius: 24px;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.28), transparent 70%);
  content: "";
}

.room-qr {
  display: block;
  width: clamp(154px, 24vw, 190px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
}

.qr-copy {
  min-width: 0;
  text-align: left;
}

.qr-kicker {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.qr-copy > strong {
  display: block;
  color: white;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  line-height: 1.15;
}

.qr-copy p {
  max-width: 33rem;
  margin: 0.35rem 0 0.65rem;
}

.invite-address {
  display: inline-flex;
  max-width: 100%;
  padding: 0.3rem 0.6rem;
  overflow: hidden;
  border: 1px solid rgba(114, 255, 157, 0.22);
  border-radius: 999px;
  background: rgba(114, 255, 157, 0.08);
  color: var(--leaf);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-code {
  display: block;
  color: white;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.4rem, 5vw, 2.1rem);
  letter-spacing: 0.13em;
  line-height: 1;
}

input,
button {
  min-height: 44px;
  border-radius: 14px;
  font: inherit;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  outline: none;
  background: rgba(255, 255, 255, 0.96);
  color: #112116;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: var(--leaf-strong);
  box-shadow: 0 0 0 4px rgba(45, 226, 106, 0.18);
}

button {
  width: auto;
  padding: 0.65rem 1rem;
  border: 1px solid var(--leaf-strong);
  background: linear-gradient(135deg, #2ebd60, #198b42);
  color: white;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.18s, border-color 0.18s, filter 0.18s;
}

button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { cursor: not-allowed; filter: grayscale(0.55); opacity: 0.42; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.secondary-button,
.preset-buttons button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.start-button {
  width: min(100%, 360px);
  margin-top: 1rem;
  padding: 0.85rem 1.3rem;
  border-color: var(--leaf);
  box-shadow: 0 10px 30px rgba(26, 160, 72, 0.25);
  font-size: 1.05rem;
}

.join-room-row,
.join-player-row,
.category-add-row {
  display: flex;
  gap: 0.55rem;
}

.join-room-row input,
.join-player-row input,
.category-add-row input {
  flex: 1 1 0;
}

.join-room-row button,
.join-player-row button,
.category-add-row button {
  flex: 0 0 auto;
}

.join-room-row { margin-bottom: 1rem; }
.join-player-row { width: min(100%, 560px); margin: 1rem auto 0; }
.category-add-row { width: min(100%, 520px); margin: 1rem auto 0; }

.status-message {
  margin-bottom: 0.8rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(4, 17, 8, 0.88);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.status-message[data-type="success"] { border-color: rgba(114, 255, 157, 0.55); color: var(--leaf); }
.status-message[data-type="error"] { border-color: rgba(255, 123, 114, 0.55); color: #ffd4d0; }

.players-list-ui {
  display: flex;
  min-height: 36px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.player-display {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.32rem 0.68rem;
  border: 1px solid rgba(114, 255, 157, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-weight: 700;
}

.count-badge {
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(114, 255, 157, 0.15);
  color: var(--leaf);
  font-size: 0.7rem;
  font-weight: 800;
}

.player-role {
  display: inline-grid;
  width: 29px;
  height: 29px;
  border: 1px solid rgba(255, 209, 102, 0.68);
  border-radius: 50%;
  place-items: center;
  background: radial-gradient(circle at 45% 35%, rgba(255, 219, 112, 0.3), rgba(17, 61, 28, 0.88));
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.23);
}

.player-role img { width: 21px; height: 21px; }

.player-legend {
  display: flex;
  margin-top: 0.35rem;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.player-legend img { width: 18px; height: 18px; }

.lobby-panel {
  min-height: 0;
  padding: 0.8rem 1rem 0.65rem;
}

.lobby-panel .section-heading h2 {
  margin-bottom: 0.25rem;
}

.host-hint { margin-bottom: 1rem; color: #d6e8da; }

@media (min-width: 681px) {
  #nextRoundHint { margin-top: 2rem; margin-bottom: 0.25rem; }
  body.results-mode #contentWrapper { overflow-y: hidden; }
  body.results-mode #nextRoundHint { margin-top: 0.8rem; margin-bottom: 0; }

  #setup > #joinPanel {
    margin-bottom: 0.65rem;
    padding: 0.8rem 1.25rem;
  }

  #setup > #joinPanel h1 { font-size: 1.7rem; }
  #setup > #joinPanel p { margin-bottom: 0.35rem; }
  #setup > #joinPanel .join-player-row { margin-top: 0.55rem; }
  #setup > .room-bar { margin-bottom: 0.55rem; padding-block: 0.65rem; }
  #setup > .room-bar .room-heading { min-height: 48px; }
  #setup > .room-bar .qr-invite { margin-top: 0.5rem; padding-top: 0.65rem; }
  #setup > .room-bar .room-qr { width: clamp(126px, 15vw, 154px); }
  #setup > .join-room-row { margin-bottom: 0.65rem; }
  #setup > .lobby-panel { min-height: 0; margin-bottom: 0.65rem; padding: 0.7rem 1rem 0.55rem; }
  #setup > .lobby-panel .section-heading h2 { margin-bottom: 0.2rem; font-size: 1.35rem; }
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 1.2rem;
}

.preset-buttons button { min-height: 38px; padding: 0.45rem 0.72rem; font-size: 0.88rem; }
.preset-buttons button.active { border-color: var(--leaf); background: rgba(45, 226, 106, 0.22); color: var(--leaf); }

#categoriesScrollArea {
  width: min(100%, 560px);
  max-height: 250px;
  margin: 0 auto;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.12);
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem 0.55rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
}

.category-row:last-child { border-bottom: 0; }
.category-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

.remove-btn {
  display: inline-grid;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border-color: rgba(255, 123, 114, 0.42);
  border-radius: 50%;
  background: rgba(255, 123, 114, 0.12);
  color: #ffd4d0;
  font-size: 1.2rem;
}

.phase-card { padding-block: clamp(2rem, 8vw, 5rem); }

#currentLetter {
  display: grid;
  width: clamp(120px, 30vw, 190px);
  aspect-ratio: 1;
  margin: 1.3rem auto 0;
  place-items: center;
  border: 2px solid var(--leaf);
  border-radius: 36%;
  background: radial-gradient(circle, rgba(114, 255, 157, 0.22), rgba(8, 30, 14, 0.85));
  color: var(--leaf);
  font-size: clamp(4.5rem, 17vw, 8rem);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 28px rgba(114, 255, 157, 0.6);
  animation: letter-pulse 0.7s ease-in-out infinite alternate;
}

@keyframes letter-pulse { to { transform: scale(1.035) rotate(1deg); } }

.game-headline { margin-bottom: 1rem; }
.game-headline h2 { margin: 0; }

.timer {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 92px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  color: var(--leaf);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.timer.urgent { border-color: rgba(255, 123, 114, 0.65); color: #ffb1aa; animation: urgent 0.7s ease-in-out infinite alternate; }
@keyframes urgent { to { box-shadow: 0 0 20px rgba(255, 123, 114, 0.25); } }

#playersArea {
  display: grid;
  gap: 0.8rem;
}

.player-block {
  width: 100%;
  padding: clamp(0.9rem, 2vw, 1.25rem);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.16);
}

.player-block h3 { text-align: left; }

.category-input {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  text-align: left;
}

.category-input span { overflow: hidden; color: #dbeade; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.category-input input { margin: 0; }
.finish-button { margin-top: 0.5rem; }
.fill-warning { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.86rem; }
.waiting-msg { margin: 0; font-style: italic; }
.waiting-msg.finished { color: var(--leaf); font-style: normal; font-weight: 700; }
.spectator-note { padding: 0.8rem; border: 1px dashed var(--line); border-radius: 14px; }

.results-heading { margin-bottom: 1.1rem; }
.results-heading h2 { margin-bottom: 0.3rem; }

body.results-mode #contentWrapper {
  padding-top: max(4rem, calc(3.2rem + env(safe-area-inset-top)));
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

body.results-mode #statusMessage,
body.results-mode footer { display: none; }

body.results-mode #resultsPhase {
  margin-bottom: 0;
  padding: clamp(0.7rem, 1.5vw, 1rem) clamp(0.55rem, 1.7vw, 1.1rem);
}

body.results-mode .results-heading { margin-bottom: 0.5rem; }
body.results-mode .results-heading h2 { margin-bottom: 0; font-size: clamp(1.3rem, 2.4vw, 1.65rem); line-height: 1.05; }

.results-reward-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.7rem;
  margin-top: 0.42rem;
}

.reward-equation {
  display: inline-flex;
  min-height: 1.85rem;
  align-items: center;
  justify-content: center;
  gap: 0.32rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(130, 255, 158, 0.18);
  border-radius: 999px;
  background: rgba(3, 23, 10, 0.44);
}

.reward-legend-icon {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  flex: 0 0 auto;
  object-fit: contain;
}

.reward-watermelon { width: 1.52rem; height: 1.52rem; }
.reward-equals { color: var(--muted); font-weight: 800; }
.reward-number { color: #fff4bb; font-size: 0.9rem; font-weight: 900; }

.reward-match-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.13rem 0.45rem;
  border: 1px solid rgba(255, 248, 199, 0.82);
  border-radius: 999px;
  background: linear-gradient(135deg, #fff1a8, #f5b82e);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.42);
  color: #3d2900;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

.reward-legend-divider {
  width: 1px;
  height: 1.5rem;
  background: rgba(255, 255, 255, 0.12);
}

.results-scroll { width: 100%; overflow-x: auto; padding-bottom: 0.18rem; }
.results-clean { width: 100%; min-width: 520px; border-collapse: separate; border-spacing: 0; }
.results-clean.single-player { min-width: 0; table-layout: fixed; }
.results-clean.single-player th:first-child,
.results-clean.single-player td:first-child { width: 38%; }
.results-clean.two-players { --category-column: 26%; }
.results-clean th, .results-clean td { height: 2.25rem; padding: 0.3rem 0.65rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.results-clean th { color: var(--leaf); font-size: 0.69rem; letter-spacing: 0.06em; text-transform: uppercase; }
.results-clean th:first-child, .results-clean td:first-child { position: sticky; left: 0; z-index: 2; background: #102b17; text-align: left; }
.results-clean tbody tr:nth-child(even) td { background-color: rgba(255, 255, 255, 0.025); }
.results-clean tbody tr:nth-child(even) td:first-child { background-color: #13321c; }
.cat-cell { max-width: 170px; overflow: hidden; color: var(--muted); font-size: 0.7rem; font-weight: 700; line-height: 1.05; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.res-answer { color: white; }
.res-empty { color: rgba(255, 255, 255, 0.28); }
.res-too-short, .res-wrong-letter { color: var(--danger); text-decoration: line-through; }
.res-duplicate {
  position: relative;
  display: inline-flex;
  min-width: 4.5rem;
  max-width: 100%;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow: visible;
  vertical-align: middle;
}

.res-match-answer {
  display: inline-flex;
  min-width: 4.5rem;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.24rem 0.65rem;
  border: 1px solid rgba(255, 221, 112, 0.82);
  border-radius: 999px;
  background:
    linear-gradient(110deg, rgba(255, 209, 102, 0.08), rgba(255, 224, 122, 0.24) 45%, rgba(255, 209, 102, 0.08)),
    rgba(69, 48, 5, 0.28);
  color: #ffe583;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow:
    0 0 5px rgba(255, 247, 183, 0.95),
    0 0 14px rgba(255, 209, 102, 0.78);
  box-shadow:
    0 0 8px rgba(255, 209, 102, 0.4),
    0 0 22px rgba(255, 187, 51, 0.18),
    inset 0 0 10px rgba(255, 238, 164, 0.12);
  animation: match-glow 1.8s ease-in-out infinite alternate;
}

.res-match-answer::before {
  color: #fff7c7;
  content: "✦";
  font-size: 0.7em;
  text-shadow: 0 0 8px #fff1a6;
  animation: match-sparkle 1.2s ease-in-out infinite alternate;
}

.res-match-label {
  position: absolute;
  top: -0.72rem;
  right: -0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.08rem 0.34rem;
  border: 1px solid rgba(255, 248, 199, 0.8);
  border-radius: 999px;
  background: linear-gradient(135deg, #fff1a8, #f5b82e);
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.62);
  color: #3d2900;
  font-size: 0.48rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-shadow: none;
}

@keyframes match-glow {
  from {
    filter: brightness(0.98);
    box-shadow: 0 0 7px rgba(255, 209, 102, 0.34), 0 0 18px rgba(255, 187, 51, 0.14), inset 0 0 9px rgba(255, 238, 164, 0.1);
  }
  to {
    filter: brightness(1.16);
    box-shadow: 0 0 12px rgba(255, 224, 122, 0.68), 0 0 30px rgba(255, 187, 51, 0.3), inset 0 0 14px rgba(255, 248, 199, 0.2);
  }
}

@keyframes match-sparkle {
  from { opacity: 0.65; transform: rotate(-8deg) scale(0.9); }
  to { opacity: 1; transform: rotate(8deg) scale(1.16); }
}

.results-scores {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
  padding-bottom: 0.08rem;
  overflow-x: auto;
}

.score-card {
  min-width: 118px;
  padding: 0.48rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
}

.score-card.winner { border-color: rgba(255, 209, 102, 0.58); background: rgba(255, 209, 102, 0.08); }
.score-name { overflow: hidden; color: var(--muted); font-size: 0.78rem; font-weight: 800; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.score-points { display: flex; min-height: 1.72rem; align-items: center; justify-content: center; color: var(--leaf); font-size: 1.55rem; font-weight: 800; line-height: 1; }
.winner .score-points { color: var(--amber); }
.score-total { display: flex; flex-direction: column; align-items: center; gap: 0.08rem; margin-top: 0.16rem; color: var(--muted); font-size: 0.69rem; }
.score-total-label { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.score-total-currency { display: inline-flex; min-height: 1.45rem; align-items: center; justify-content: center; gap: 0.32rem; white-space: nowrap; }
.currency-value { display: inline-flex; align-items: center; justify-content: center; gap: 0.14em; white-space: nowrap; }
.currency-icon { display: block; width: 1.35em; height: 1.35em; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 0 0.2rem rgba(255, 209, 102, 0.3)); }
.currency-watermelon .currency-icon { width: 1.45em; height: 1.45em; filter: drop-shadow(0 0 0.18rem rgba(114, 255, 157, 0.28)); }
.currency-divider { color: rgba(255, 255, 255, 0.42); font-weight: 800; }

footer { padding-top: 1rem; color: rgba(255, 255, 255, 0.48); font-size: 0.75rem; }

body.results-mode #newRoundButton {
  min-height: 42px;
  margin-top: 0.55rem;
  padding-block: 0.5rem;
}

body.results-mode #nextRoundHint { margin-top: 0.7rem; margin-bottom: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 780px) {
  .qr-invite { grid-template-columns: 1fr; justify-items: center; }
  .qr-copy { text-align: center; }
  .qr-copy p { max-width: 25rem; }
}

@media (max-width: 680px) {
  .lianen-container { opacity: 0.6; }
  #contentWrapper { padding-inline: 0.65rem; }
  #profile-pic { width: 88px; height: 88px; border-radius: 23px; }
  #profile-pic.localized-brand { width: 112px; height: 112px; }
  #profile-pic.localized-brand #profileLogo { width: 62px; height: 62px; }
  .panel, .phase-card, #gamePhase, #resultsPhase { border-radius: 19px; }
  .room-heading { align-items: flex-end; }
  .join-room-row, .join-player-row, .category-add-row { flex-direction: column; }
  .join-room-row button, .join-player-row button, .category-add-row button { width: 100%; }
  .preset-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-buttons button { width: 100%; padding-inline: 0.35rem; }
  .game-headline { align-items: flex-end; }
  .game-headline > div:first-child { min-width: 0; }
  .timer { min-width: 100px; }
  .category-input { grid-template-columns: 1fr; gap: 0.25rem; }
  .category-input span { white-space: normal; }
  .finish-button { width: 100%; }

  body.results-mode #contentWrapper {
    padding-top: max(3.9rem, calc(3rem + env(safe-area-inset-top)));
  }

  body.results-mode.results-solo #contentWrapper { overflow-y: hidden; }
  body.results-mode #resultsPhase { padding: 0.62rem 0.42rem; }
  body.results-mode .results-heading { margin-bottom: 0.38rem; }
  body.results-mode .results-heading h2 { font-size: 1.32rem; }
  body.results-mode .eyebrow { font-size: 0.58rem; }
  body.results-mode .results-reward-legend { margin-top: 0.3rem; }

  .results-clean.single-player th,
  .results-clean.single-player td {
    height: 2.05rem;
    padding: 0.24rem 0.34rem;
  }

  .results-clean.single-player th:first-child,
  .results-clean.single-player td:first-child { width: 42%; }

  .results-clean.single-player .cat-cell {
    max-width: none;
    font-size: 0.62rem;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .results-clean.single-player .res-answer,
  .results-clean.single-player .res-empty,
  .results-clean.single-player .res-too-short,
  .results-clean.single-player .res-wrong-letter {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 0.8rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .results-clean.two-players {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .results-clean.two-players th,
  .results-clean.two-players td {
    width: calc((100% - var(--category-column)) / 2);
    padding: 0.5rem 0.22rem 0.36rem;
  }

  .results-clean.two-players th {
    overflow: hidden;
  }

  .results-clean.two-players td { overflow: visible; }

  .results-clean.two-players th:first-child,
  .results-clean.two-players td:first-child {
    width: var(--category-column);
    padding-inline: 0.28rem;
  }

  .results-clean.two-players .cat-cell {
    max-width: none;
    font-size: 0.62rem;
    letter-spacing: -0.01em;
    line-height: 1.08;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .results-clean.two-players .res-answer,
  .results-clean.two-players .res-empty,
  .results-clean.two-players .res-too-short,
  .results-clean.two-players .res-wrong-letter {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .results-clean.two-players .res-duplicate {
    min-width: 0;
    max-width: 100%;
    overflow: visible;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .results-clean.two-players .res-match-answer {
    min-width: 0;
    max-width: 100%;
    padding-inline: 0.38rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .results-clean.two-players .res-match-label {
    top: -0.64rem;
    right: -0.12rem;
  }

  .results-scores.two-players {
    flex-wrap: nowrap;
    gap: 0.55rem;
  }

  .results-scores.two-players .score-card {
    width: calc(50% - 0.275rem);
    min-width: 0;
    padding-inline: 0.45rem;
  }

  .score-total-currency {
    gap: 0.2rem;
    font-size: 0.72rem;
  }

  .results-scores.single-player .score-card {
    display: grid;
    width: min(100%, 420px);
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.62rem;
  }

  .results-scores.single-player .score-name { text-align: left; }
  .results-scores.single-player .score-points { min-height: 0; font-size: 1.4rem; }
  .results-scores.single-player .score-total { margin-top: 0; align-items: flex-end; font-size: 0.64rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #resultsPhase { padding-top: 1rem; }
  .results-heading { margin-bottom: 0.75rem; }
  .results-clean th, .results-clean td { padding-block: 0.58rem; }
}

@media (max-width: 410px) {
  .results-reward-legend { flex-wrap: nowrap; gap: 0.38rem; }
  .reward-equation { gap: 0.24rem; padding: 0.26rem 0.42rem; }
  .reward-legend-divider { display: none; }
  .connection-status { font-size: 0; }
  .connection-status::before { width: 0.65rem; height: 0.65rem; }
  .room-heading { align-items: stretch; flex-direction: column; text-align: center; }
  .room-heading button { width: 100%; }
  .preset-buttons { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
