* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1d3b22;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #fff;
}

html.transparente,
html.transparente body {
  background: transparent;
}

/* Como en Twitch: ranking y normas a la izquierda, lago en el centro y chat a la derecha (en pantallas anchas). */
:root {
  --left: 0px;
  --right: 0px;
  --mid: calc(var(--left) + (100vw - var(--left) - var(--right)) / 2);
}

@media (min-width: 1100px) {
  :root {
    --left: 284px;
  }

  :root.con-chat {
    --right: 340px;
  }
}

#bg,
#game {
  position: fixed;
  top: 0;
  left: var(--left);
  display: block;
}

#fog {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;
}

#fog.on {
  display: block;
}

#fog::before,
#fog::after {
  content: "";
  position: absolute;
  top: 0;
  left: -25%;
  width: 150%;
  height: 100%;
  background:
    radial-gradient(ellipse 18% 26% at 12% 28%, rgba(205, 195, 235, 0.2), transparent 70%),
    radial-gradient(ellipse 20% 22% at 40% 82%, rgba(205, 195, 235, 0.17), transparent 70%),
    radial-gradient(ellipse 16% 26% at 66% 14%, rgba(205, 195, 235, 0.17), transparent 70%),
    radial-gradient(ellipse 20% 25% at 88% 70%, rgba(205, 195, 235, 0.2), transparent 70%);
  animation: niebla 50s ease-in-out infinite alternate;
}

#fog::after {
  top: 8%;
  animation-duration: 73s;
  animation-direction: alternate-reverse;
}

@keyframes niebla {
  from {
    transform: translateX(-10%);
  }
  to {
    transform: translateX(10%);
  }
}

#events {
  position: fixed;
  top: 12px;
  left: calc(var(--left) + 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: clamp(260px, 24vw, 420px);
  pointer-events: none;
}

.ev {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(10, 18, 30, 0.85);
  border: 2px solid var(--c);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 45%, transparent);
  animation: drop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  transition: opacity 0.5s, transform 0.5s;
}

.ev.intro {
  border-style: dashed;
}

.ev.intro .ev-icon {
  animation: pulse 0.8s ease-in-out infinite;
}

.ev.out {
  opacity: 0;
  transform: translateY(-14px);
}

.ev-icon {
  font-size: 34px;
  line-height: 1;
}

.ev-body {
  flex: 1;
  min-width: 0;
}

.ev-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  color: var(--c);
}

.ev-time {
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ev-desc {
  margin-top: 2px;
  font-size: 14px;
  color: #e6eef7;
}

.ev-bar {
  height: 5px;
  margin-top: 7px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.ev-bar i {
  display: block;
  height: 100%;
  background: var(--c);
  transform-origin: left;
}

#corner {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

#help {
  width: 250px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 18, 30, 0.82);
  font-size: 13px;
}

#help.hidden,
#legend.hidden {
  display: none;
}

#legend {
  width: 250px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(10, 18, 30, 0.8);
  font-size: 13px;
  line-height: 1.3;
}

#legend h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

#legend .row {
  display: flex;
  gap: 7px;
  padding: 2px 0;
}

#legend .ico {
  flex: none;
  width: 18px;
  text-align: center;
}

#legend b {
  color: #ffd54a;
}

#help .keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  margin-top: 6px;
  align-items: center;
}

#help kbd {
  min-width: 24px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

#help .next {
  margin-top: 8px;
  color: #9fb4c9;
  font-size: 12px;
}

@media (max-height: 820px) {
  .ev {
    gap: 8px;
    padding: 6px 10px;
    border-radius: 10px;
  }

  .ev-icon {
    font-size: 24px;
  }

  .ev-head {
    font-size: 15px;
  }

  .ev-desc {
    display: none;
  }

  .ev-bar {
    margin-top: 5px;
  }

  #board {
    width: 220px;
    padding: 10px 12px;
  }

  #rank li {
    font-size: 14px;
    padding: 2px 0;
  }

  #help,
  #legend {
    width: 215px;
    font-size: 12px;
  }

  #legend h3 {
    font-size: 13px;
  }
}

#status {
  position: fixed;
  bottom: 56px;
  left: var(--mid);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 14px;
  transition: opacity 0.6s;
}

#board {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 260px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10, 18, 30, 0.72);
  backdrop-filter: blur(4px);
}

#board h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

#rank {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pos;
}

#rank li {
  counter-increment: pos;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  font-size: 15px;
}

#rank li::before {
  content: counter(pos);
  width: 20px;
  text-align: right;
  color: #9fb4c9;
  font-weight: 700;
}

#rank li:nth-child(1)::before {
  color: #ffd54a;
}

#rank li:nth-child(2)::before {
  color: #d5dde5;
}

#rank li:nth-child(3)::before {
  color: #e0955a;
}

#rank .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#rank .pts {
  font-weight: 700;
  color: #7fe3ff;
}

#rank .empty {
  color: #9fb4c9;
  font-size: 14px;
}

#rank .empty::before {
  content: "";
  width: 0;
}

#log {
  position: fixed;
  left: calc(var(--left) + 12px);
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 380px;
}

.entry {
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(10, 18, 30, 0.72);
  font-size: 14px;
  animation: slide 0.35s ease-out;
  transition: opacity 0.6s;
}

.entry .fish-ico {
  width: 30px;
  height: 30px;
  margin: -7px 6px -7px -4px;
  vertical-align: middle;
}

.entry.rare {
  background: rgba(70, 40, 120, 0.85);
  border: 1px solid #b98cff;
}

.entry.legendary {
  background: rgba(120, 86, 0, 0.9);
  border: 1px solid #ffd54a;
  font-weight: 700;
}

.entry.event {
  border-left: 4px solid #5fd0ff;
}

.entry.bonus {
  background: rgba(110, 30, 90, 0.88);
  border: 1px solid #ff8fd6;
}

.entry .stars {
  margin-right: 6px;
  color: var(--r);
  font-size: 12px;
  letter-spacing: -1px;
}

.entry.mythic {
  background: rgba(40, 10, 50, 0.92);
  border: 1px solid var(--r);
  box-shadow: 0 0 16px var(--r);
  font-weight: 800;
}

.entry.ach {
  background: rgba(80, 60, 0, 0.9);
  border: 1px dashed #ffd54a;
  color: #fff3c4;
  font-weight: 700;
}

#chatbox {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, 100vw);
  padding: 10px;
  background: rgba(10, 18, 30, 0.95);
}

#chatbox[hidden] {
  display: none;
}

/* Columnas fijas en pantallas anchas; en estrechas, ranking flotando a la derecha y chat con su botón. */
@media (min-width: 1100px) {
  :root.con-chat body {
    background: #0e1824;
  }

  #board {
    right: auto;
    left: 12px;
  }

  #corner {
    right: auto;
    left: 12px;
    align-items: flex-start;
  }

  #chatbox,
  #chatbox[hidden] {
    display: flex;
    width: var(--right);
  }

  .chat-toggle {
    display: none !important;
  }
}

#chatbox .ver-stats {
  margin: 0;
}

#chatbox .chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
}

#chatbox .chat-line {
  padding: 3px 0;
  font-size: 14px;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

#chatbox .chat-send {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chatbox .chat-send small {
  color: #9fb4c9;
  font-size: 12px;
}

#chatbox .chat-send form {
  display: flex;
  gap: 6px;
}

#chatbox .chat-send input,
#chatbox .chat-send form button {
  padding: 8px 10px;
  border: 2px solid #3a5470;
  border-radius: 10px;
  background: #1b2f42;
  color: #fff;
  font: inherit;
  font-size: 14px;
}

#chatbox .chat-send input {
  flex: 1;
  min-width: 0;
}

#chatbox .chat-send form button {
  font-weight: 700;
  cursor: pointer;
}

#chatbox :is(input, button):focus-visible {
  outline: 3px solid #fff;
  outline-offset: 1px;
}

#chatbox .chat-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

#chatbox .chat-suggest:empty {
  display: none;
}

#chatbox .chat-suggest button {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 2px 8px 2px 4px;
  border: 1px solid #3a5470;
  border-radius: 8px;
  background: #1b2f42;
  color: #fff;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

#chatbox .chat-suggest .emote {
  height: 22px;
  margin: 0;
}

#chatbox .chat-link {
  padding: 0;
  border: 0;
  background: none;
  color: #ffd54a;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

#chatbox .chat-error {
  min-height: 1em;
  color: #ff8a8a;
}

#chatbox .emote {
  height: 28px;
  margin: -6px 0;
  vertical-align: middle;
}

#charca {
  position: fixed;
  top: 50%;
  left: var(--mid);
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 90vw;
  padding: 22px 32px;
  border: 3px solid #ff6b6b;
  border-radius: 18px;
  background: rgba(10, 18, 30, 0.92);
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.35);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#charca[hidden] {
  display: none;
}

#charca b {
  color: #ff8a8a;
  font-size: 30px;
}

#charca span {
  font-size: 17px;
}

#card {
  position: fixed;
  top: 12px;
  left: var(--mid);
  min-width: 300px;
  padding: 12px 18px;
  border: 2px solid #ffd54a;
  border-radius: 14px;
  background: rgba(10, 18, 30, 0.9);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -20px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}

#card.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

#card .card-head {
  color: #ffd54a;
  font-size: 22px;
  font-weight: 800;
}

#card .card-stats {
  margin-top: 2px;
  font-size: 15px;
}

#card .card-best {
  margin-top: 6px;
  color: var(--r);
  font-size: 14px;
  font-weight: 700;
}

#card .card-best img {
  width: 30px;
  height: 30px;
  margin: -8px 4px -8px 0;
  vertical-align: middle;
}

.entry.warn {
  background: rgba(40, 50, 70, 0.9);
  color: #cfe3ff;
}

@keyframes drop {
  from {
    transform: translateY(-30px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes pulse {
  50% {
    transform: scale(1.18);
  }
}

@keyframes slide {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
