:root {
  --bg1: #000000;
  --bg2: #000000;
  --ink: #f5fbff;
  --panel: #0c1722;
  --gold: #0d3fa8;
  --aqua: #3ad2ff;
  --line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background: #000;
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0.8rem 1.2rem 1.2rem;
}

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

.app:not(.game-live) .layout {
  grid-template-columns: 1fr;
}

.app:not(.game-live) .side-panel {
  display: none;
}

.hud {
  display: block;
  text-align: center;
  margin-bottom: 0.8rem;
}

.hud h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 800;
}

.hud p {
  margin: 0.35rem 0 0;
  opacity: 0.94;
  font-size: 1.25rem;
  font-weight: 500;
}

.canvas-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  background: #000;
}

.logo-wrap {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: none;
  text-align: center;
}

.canvas-wrap.game-live .logo-wrap {
  display: none;
}

.endzone-brand {
  display: none !important;
  position: absolute;
  left: 7.8%;
  top: 30.5%;
  width: 24%;
  height: 58%;
  z-index: 3;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0.02em;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.2);
}

.canvas-wrap.game-live .endzone-brand {
  display: none !important;
}

.endzone-brand .wb {
  color: #f4f8ff;
  font-size: clamp(1.8rem, 4.2vw, 3.5rem);
}

.endzone-brand .sports {
  color: #0d3fa8;
  font-size: clamp(1.5rem, 3.2vw, 2.7rem);
}

.brand-logo {
  width: min(220px, 42vw);
  height: auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
}

.logo-wrap h1 {
  margin: 0.75rem 0 0;
  font-size: clamp(1.15rem, 2.4vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.logo-wrap p {
  margin: 0.55rem 0 0;
  font-size: clamp(0.9rem, 1.7vw, 1.25rem);
  opacity: 0.95;
}

.player-frame {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 0;
  background: #0b0b0b;
}

.overlay {
  position: absolute;
  inset: 0;
  background: #000;
  z-index: 10;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 1rem;
}

.canvas-wrap:not(.game-live) .overlay {
  place-content: end center;
  padding: clamp(280px, 45vh, 500px) 1rem 1rem;
  overflow-y: auto;
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
}

.overlay p {
  margin: 0 0 1.25rem;
  opacity: 0.9;
  font-size: 0.95rem;
}

button {
  font: inherit;
  cursor: pointer;
  color: #ffffff;
  background: var(--gold);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.7rem 1.3rem;
  font-weight: 700;
  transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.overlay button {
  display: block;
  margin: 0.8rem auto 0;
  min-width: min(280px, 90vw);
}

.quick-controls {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.quick-controls button {
  min-width: 140px;
}

.instructions {
  margin-top: 0.5rem;
  text-align: center;
  color: #d9e6ff;
}

.instructions p {
  margin: 0.2rem 0;
  font-weight: 600;
}

.snap-hint {
  display: none;
  margin-top: 0.6rem !important;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(13, 63, 168, 0.18);
}

.app.game-live .snap-hint {
  display: block;
}

.mobile-controls {
  display: none;
  margin-top: 1.4rem;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.dpad {
  position: relative;
  width: 190px;
  height: 190px;
}

.dpad-btn {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #0b1a2a;
  color: #fff;
  font-weight: 800;
}

.dpad-btn.up {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-btn.down {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-btn.left {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.dpad-btn.right {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.mobile-actions {
  display: grid;
  gap: 1.1rem;
}

.mobile-btn {
  min-width: 170px;
  padding: 1.05rem 1.5rem;
  font-size: 1.05rem;
}

.side-panel {
  background: rgba(12, 23, 34, 0.84);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.side-panel h3,
.side-panel h4 {
  margin: 0 0 0.55rem;
}

.side-panel ol {
  margin: 0 0 0.8rem;
  padding-left: 1.1rem;
}

.side-panel li {
  margin: 0.2rem 0 0.35rem;
}

.action-stack {
  display: grid;
  gap: 0.6rem;
  margin: 0.75rem 0 0.5rem;
}

.difficulty-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.difficulty {
  padding: 0.55rem 0.5rem;
  font-size: 0.9rem;
  background: #0b1a2a;
}

.difficulty.active {
  background: var(--gold);
}

.action-stack button {
  width: 100%;
  font-size: 1rem;
  padding: 0.85rem 1rem;
}

.dev-only {
  display: none;
  background: #303b46;
}

.dev-only.visible {
  display: block;
}

.status {
  min-height: 1.2em;
  margin: 0.35rem 0 0.9rem;
  color: #d9e6ff;
}

.post-form {
  display: grid;
  gap: 0.55rem;
  margin: 0.35rem 0 0.9rem;
}

.post-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.post-form input,
.post-form textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #0a1118;
  color: #fff;
  padding: 0.55rem 0.6rem;
}

.post-form textarea {
  min-height: 78px;
  resize: vertical;
}

.post-form button {
  width: 100%;
}

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.post-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.2rem 0 0.45rem;
}

.post-toolbar label {
  font-size: 0.85rem;
  font-weight: 700;
}

.post-toolbar select {
  flex: 1;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #0a1118;
  color: #fff;
  padding: 0.45rem 0.55rem;
}

.post-card {
  display: grid;
  gap: 0.35rem;
}

.post-card strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.post-thumb-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: #071018;
  overflow: hidden;
  cursor: zoom-in;
}

.post-thumb-btn img {
  display: block;
  width: 100%;
  max-height: 110px;
  object-fit: cover;
}

.post-card p {
  margin: 0;
  color: #d7e3ff;
  font-size: 0.86rem;
  line-height: 1.28;
}

.post-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.post-pagination button {
  min-width: 68px;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}

#postPageInfo {
  font-size: 0.85rem;
  color: #d7e3ff;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.86);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.image-modal.hidden {
  display: none;
}

.image-modal-card {
  position: relative;
  width: min(94vw, 1000px);
  max-height: 94vh;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #03070d;
  padding: 0.8rem;
}

.image-modal-card img {
  display: block;
  width: 100%;
  max-height: calc(94vh - 2rem);
  object-fit: contain;
  border-radius: 10px;
}

.image-modal-close {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.post-card {
  display: grid;
  gap: 0.45rem;
}

.post-card strong {
  font-size: 0.95rem;
}

.post-card img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.post-card p {
  margin: 0;
  color: #d9e6ff;
  font-size: 0.88rem;
}

@media (max-width: 800px) {
  .app {
    padding: 0.5rem;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    border-radius: 10px;
  }

  .logo-wrap {
    top: 10px;
  }

  .brand-logo {
    width: min(165px, 40vw);
  }

  .endzone-brand {
    left: 7.4%;
    top: 30.2%;
    width: 24.8%;
    height: 58.5%;
  }

  .logo-wrap h1 {
    font-size: clamp(1rem, 5vw, 1.4rem);
    margin-top: 0.55rem;
  }

  .logo-wrap p {
    margin-top: 0.4rem;
    font-size: clamp(0.8rem, 3.6vw, 1rem);
  }

  .overlay {
    padding: 0.75rem;
  }

  .canvas-wrap:not(.game-live) .overlay {
    padding: clamp(235px, 38vh, 340px) 0.75rem 0.85rem;
  }

  .overlay h2 {
    font-size: 1.1rem;
  }

  .overlay p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .overlay button {
    width: min(320px, 92vw);
    padding: 0.65rem 1rem;
  }

  .quick-controls {
    display: none;
  }

  .instructions {
    margin-top: 0.9rem;
  }

  .instructions p:not(.snap-hint) {
    display: none;
  }

  .mobile-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: end;
    gap: 1.4rem;
  }
}

@media (max-width: 480px) {
  .player-frame {
    aspect-ratio: 3 / 4;
  }

  .brand-logo {
    width: min(140px, 38vw);
  }

  .endzone-brand .wb {
    font-size: clamp(1.2rem, 4.2vw, 1.8rem);
  }

  .endzone-brand .sports {
    font-size: clamp(1rem, 3.8vw, 1.4rem);
  }

  .logo-wrap h1 {
    font-size: clamp(0.9rem, 4.6vw, 1.15rem);
  }

  .logo-wrap p {
    font-size: clamp(0.72rem, 3.8vw, 0.9rem);
  }

  .canvas-wrap:not(.game-live) .overlay {
    padding: clamp(110px, 20vh, 170px) 0.65rem 0.75rem;
  }

  .overlay button {
    width: min(300px, 88vw);
  }

  .overlay p {
    margin: 0 0 0.85rem;
    line-height: 1.2;
  }

  .mobile-controls {
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    align-items: end;
  }

  .dpad {
    width: 190px;
    height: 190px;
  }

  .dpad-btn {
    width: 72px;
    height: 72px;
  }

  .mobile-btn {
    min-width: 240px;
    width: 100%;
  }

  .mobile-actions {
    width: min(240px, 44vw);
    justify-self: end;
  }

  .dpad {
    justify-self: start;
  }
}
