:root {
  --bg-deep: #04110f;
  --bg-forest: #0b2a22;
  --bg-night: #07182a;
  --panel: rgba(6, 18, 23, 0.82);
  --panel-strong: rgba(8, 28, 32, 0.94);
  --line: rgba(139, 244, 205, 0.28);
  --line-blue: rgba(96, 190, 255, 0.26);
  --text-main: #eefbf6;
  --text-soft: #b8d8d4;
  --muted: #7fa5a0;
  --mint: #55f4c4;
  --cyan: #67b7ff;
  --gold: #ffcc5f;
  --coral: #ff6f91;
  --violet: #c68cff;
  --shadow: rgba(0, 10, 16, 0.58);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text-main);
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(5, 22, 18, 0.96), rgba(8, 18, 38, 0.94) 48%, rgba(29, 17, 42, 0.9)),
    repeating-linear-gradient(115deg, rgba(106, 255, 194, 0.05) 0 2px, transparent 2px 28px);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.aurora-layer,
.leaf-layer,
.grain-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.aurora-layer {
  background:
    linear-gradient(100deg, rgba(85, 244, 196, 0.16), transparent 28%, rgba(103, 183, 255, 0.14) 54%, transparent 78%),
    linear-gradient(170deg, transparent, rgba(255, 204, 95, 0.08) 50%, rgba(255, 111, 145, 0.08));
  mix-blend-mode: screen;
}

.leaf-layer {
  opacity: 0.42;
  background-image:
    linear-gradient(90deg, rgba(139, 244, 205, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(139, 244, 205, 0.07) 1px, transparent 1px),
    repeating-linear-gradient(45deg, transparent 0 38px, rgba(255, 204, 95, 0.04) 39px 41px);
  background-size: 34px 34px, 34px 34px, 120px 120px;
  mask-image: linear-gradient(to bottom, black, rgba(0, 0, 0, 0.65) 58%, transparent);
}

.grain-layer {
  opacity: 0.18;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 5px);
}

.page-shell,
.fa-game-guide,
.ad-zone {
  position: relative;
  z-index: 1;
}

.page-shell {
  width: min(1500px, 96vw);
  margin: 20px auto 34px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(420px, 0.78fr);
  gap: 18px;
  align-items: stretch;
}

.title-wrap,
.hud,
.lobby-card,
.panel-block,
.arena-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(9, 32, 35, 0.88), rgba(5, 16, 28, 0.78)),
    linear-gradient(90deg, rgba(85, 244, 196, 0.08), rgba(103, 183, 255, 0.05));
  box-shadow: 0 24px 70px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
}

.title-wrap {
  border-radius: 16px;
  padding: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.title-wrap h1 {
  margin: 10px 0 10px;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.title-wrap h1 span {
  color: var(--gold);
  text-shadow: 0 0 28px rgba(255, 204, 95, 0.34);
}

.hero-copy,
.card-copy,
.status-line,
.hint,
.rules-list,
.event-log p,
.game-card p {
  color: var(--text-soft);
}

.hero-copy {
  max-width: 660px;
  margin: 0;
  line-height: 1.65;
  font-size: 1rem;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.quick-links a {
  color: #dffdf4;
  text-decoration: none;
  border: 1px solid rgba(139, 244, 205, 0.26);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(2, 12, 19, 0.36);
}

.quick-links a:hover {
  color: var(--gold);
  border-color: rgba(255, 204, 95, 0.46);
}

.hud {
  border-radius: 16px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 12px;
}

.hud-item,
.stat-pill,
.meta-chip {
  border: 1px solid rgba(96, 190, 255, 0.24);
  border-radius: 8px;
  padding: 12px;
  background: rgba(4, 14, 24, 0.62);
}

label,
.hud-item label,
.stat-pill label,
.meta-chip label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}

.hud-item strong,
.stat-pill strong,
.meta-chip strong {
  display: block;
  margin-top: 5px;
  color: var(--text-main);
  font-size: 1.08rem;
}

.lobby-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(260px, 0.75fr) minmax(280px, 0.72fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(300px, 360px);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.stage-column,
.side-column,
.sidebar {
  min-width: 0;
}

.lobby-card,
.panel-block,
.arena-card {
  border-radius: 14px;
  padding: 18px;
}

.lobby-card h2,
.panel-block h2,
.arena-head h2,
.room-toolbar h2 {
  margin: 6px 0 8px;
  font-size: 1.32rem;
  letter-spacing: 0;
}

.card-copy,
.status-line,
.hint {
  margin: 8px 0 0;
  line-height: 1.55;
}

.hint {
  font-size: 0.9rem;
}

.stack-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.stack-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(139, 244, 205, 0.3);
  border-radius: 8px;
  outline: none;
  color: var(--text-main);
  background: rgba(3, 12, 18, 0.76);
  padding: 0 13px;
}

.stack-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 204, 95, 0.15);
}

.primary-btn,
.secondary-btn,
.pill-button,
.icon-btn,
.dir-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  font-weight: 900;
  color: var(--text-main);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--mint), #b9ff88 52%, var(--gold));
  color: #062017;
  box-shadow: 0 14px 34px rgba(85, 244, 196, 0.24);
  padding: 0 16px;
}

.secondary-btn,
.pill-button,
.icon-btn,
.dir-btn {
  background: rgba(5, 18, 28, 0.72);
  border-color: rgba(96, 190, 255, 0.34);
}

.secondary-btn {
  padding: 0 16px;
}

.pill-button {
  padding: 0 14px;
}

.pill-button.secondary {
  border-color: rgba(255, 111, 145, 0.42);
  color: #ffd7df;
}

.icon-btn {
  width: 44px;
  padding: 0;
  color: #e7fff9;
}

.icon-btn span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 204, 95, 0.62);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

.rules-list {
  margin: 12px 0 0;
  padding-left: 18px;
  line-height: 1.62;
}

.fruit-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.fruit-preview-list span {
  position: relative;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 6px 10px 6px 32px;
  color: #effff9;
  background: rgba(4, 14, 24, 0.66);
  font-size: 0.88rem;
  font-weight: 800;
}

.fruit-preview-list span::before {
  content: "";
  position: absolute;
  left: 9px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset -3px -4px 5px rgba(0, 0, 0, 0.24), 0 0 12px currentColor;
}

.fruit-preview-list [data-fruit="berry"]::before { background: #ff4e94; color: #ff4e94; }
.fruit-preview-list [data-fruit="citrus"]::before { background: #ffd45e; color: #ffd45e; }
.fruit-preview-list [data-fruit="pear"]::before { background: #86ff9a; color: #86ff9a; }
.fruit-preview-list [data-fruit="star"]::before { background: #8ad8ff; color: #8ad8ff; clip-path: polygon(50% 0, 62% 35%, 100% 35%, 69% 57%, 80% 94%, 50% 72%, 20% 94%, 31% 57%, 0 35%, 38% 35%); }
.fruit-preview-list [data-fruit="ghost"]::before { background: #f7fbff; color: #cfd8ff; border-radius: 50% 50% 42% 42%; }
.fruit-preview-list [data-fruit="dragon"]::before { background: #d88cff; color: #d88cff; border-radius: 42% 58% 52% 48%; }

.room-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar-copy {
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.game-stage-shell {
  min-width: 0;
}

.arena-card {
  padding: 14px;
}

.arena-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.arena-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.your-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
}

.stage-start-button {
  display: none;
  min-width: 112px;
  white-space: nowrap;
}

.arena-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 44 / 30;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(139, 244, 205, 0.26);
  background:
    linear-gradient(160deg, rgba(4, 22, 20, 0.98), rgba(6, 18, 36, 0.96)),
    repeating-linear-gradient(90deg, rgba(139, 244, 205, 0.05) 0 1px, transparent 1px 30px);
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.48);
}

#arena-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, rgba(1, 7, 12, 0.56), rgba(5, 20, 27, 0.34));
  backdrop-filter: blur(3px);
  text-align: center;
}

.game-overlay > * {
  max-width: 620px;
}

.overlay-kicker {
  margin: 0;
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 1.1px;
  text-transform: uppercase;
}

.game-overlay h3 {
  margin: 10px 0;
  font-size: clamp(1.45rem, 4vw, 3.2rem);
  letter-spacing: 0;
}

.overlay-copy {
  margin: 0;
  color: #dbf8ef;
  line-height: 1.55;
}

.touch-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(80px, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.dir-btn {
  min-height: 46px;
}

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

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

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.players-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.player-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(139, 244, 205, 0.22);
  border-radius: 10px;
  padding: 12px;
  background: rgba(2, 11, 18, 0.66);
}

.player-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--player-color, var(--mint));
  box-shadow: 0 0 16px var(--player-color, var(--mint));
}

.player-card.is-self {
  border-color: rgba(255, 204, 95, 0.56);
}

.player-card.is-out {
  opacity: 0.62;
}

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

.player-head strong {
  overflow-wrap: anywhere;
}

.tag-chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 4px 8px;
  color: #effff9;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tag-chip.live {
  border-color: rgba(85, 244, 196, 0.35);
  color: #baffed;
}

.tag-chip.out {
  border-color: rgba(255, 111, 145, 0.42);
  color: #ffd1dc;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.player-stats div {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
}

.player-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 800;
}

.player-stats strong {
  display: block;
  margin-top: 3px;
}

.event-log {
  display: grid;
  gap: 8px;
  max-height: 310px;
  overflow: auto;
  padding-right: 4px;
  margin-top: 12px;
}

.log-row {
  border-left: 3px solid rgba(103, 183, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  padding: 9px 10px;
}

.log-row strong {
  display: block;
  color: #eefbf6;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.log-row p {
  margin: 4px 0 0;
  line-height: 1.45;
}

.profile-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(139, 244, 205, 0.16);
  padding-bottom: 8px;
}

.profile-row span {
  color: var(--text-soft);
}

.ad-zone {
  width: min(1120px, 94vw);
  margin: 16px auto 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel);
}

.ad-zone ins.adsbygoogle {
  width: 100%;
  min-height: 120px;
}

#stage-shell:fullscreen {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: 18px;
  background:
    linear-gradient(135deg, #02100e, #081527 48%, #140c1f),
    repeating-linear-gradient(90deg, rgba(139, 244, 205, 0.05) 0 1px, transparent 1px 34px);
}

#stage-shell:fullscreen .arena-card {
  width: min(98vw, calc(96vh * 44 / 30));
  max-height: 96vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

#stage-shell:fullscreen .stage-start-button:not(.hidden) {
  display: inline-flex;
}

#stage-shell:fullscreen .arena-frame {
  width: 100%;
  max-height: calc(96vh - 150px);
}

@media (max-width: 1180px) {
  .topbar,
  .room-layout,
  .lobby-layout {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1500px);
    margin-top: 10px;
  }

  .title-wrap,
  .hud,
  .lobby-card,
  .panel-block,
  .arena-card {
    border-radius: 10px;
  }

  .title-wrap {
    padding: 18px;
  }

  .hud,
  .your-stats,
  .meta-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .room-toolbar,
  .arena-head {
    align-items: stretch;
    flex-direction: column;
  }

  .arena-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .touch-panel {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .game-overlay {
    padding: 14px;
  }
}
