:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #b7c0ce;
  --panel: rgba(10, 14, 21, 0.76);
  --line: rgba(255, 255, 255, 0.14);
  --green: #42e3a8;
  --pink: #ff4d8d;
  --yellow: #ffd166;
  --blue: #58c4ff;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  margin: 0;
  overflow: hidden;
  background: #070a10;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.feed {
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  touch-action: pan-y;
}

.feed::-webkit-scrollbar {
  display: none;
}

.game-slide {
  position: relative;
  min-height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
}

.game-slide::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  content: "";
}

.game-slide::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.46), rgba(0, 0, 0, 0.12) 38%, rgba(0, 0, 0, 0.72)),
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, 0.12), transparent 26%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%);
}

[data-game="taprush"]::before {
  background:
    linear-gradient(145deg, #16213f 0%, #0c111d 42%, #261126 100%),
    repeating-linear-gradient(90deg, transparent 0 28px, rgba(255, 255, 255, 0.08) 29px 30px);
}

[data-game="orbit"]::before {
  background:
    linear-gradient(150deg, #04251f 0%, #071016 48%, #22192c 100%),
    conic-gradient(from 30deg at 50% 42%, rgba(66, 227, 168, 0.2), transparent, rgba(88, 196, 255, 0.17), transparent);
}

[data-game="stack"]::before {
  background:
    linear-gradient(160deg, #10151f 0%, #25210e 45%, #351525 100%),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(255, 209, 102, 0.08) 35px 36px);
}

[data-game="match"]::before {
  background:
    linear-gradient(145deg, #121724 0%, #102019 48%, #221a11 100%),
    repeating-radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 18px);
}

[data-game="runner"]::before {
  background:
    linear-gradient(155deg, #0b1d2a 0%, #111018 48%, #281b0b 100%),
    linear-gradient(90deg, rgba(88, 196, 255, 0.08), transparent, rgba(255, 77, 141, 0.08));
}

.phone-safe {
  display: grid;
  min-height: 100dvh;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
}

.topbar,
.game-info {
  position: relative;
  z-index: 2;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-top: 4px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(2rem, 12vw, 3.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.score-pill,
.mini-button,
.icon-button {
  border: 1px solid var(--line);
  background: rgba(6, 10, 16, 0.54);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.score-pill {
  flex: 0 0 auto;
  min-width: 86px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.score-pill strong {
  display: block;
  color: var(--ink);
  font-size: 1.34rem;
  line-height: 1.1;
}

.play-area {
  position: relative;
  align-self: stretch;
  width: 100%;
  min-height: 0;
  max-height: 66dvh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 22%, rgba(255, 209, 102, 0.18), transparent 24%),
    radial-gradient(circle at 78% 66%, rgba(88, 196, 255, 0.14), transparent 28%),
    rgba(3, 6, 10, 0.6);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

/* Iframe integration */
.game-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  display: block;
  color-scheme: dark;
}

.game-info {
  display: grid;
  gap: 8px;
  padding-bottom: 4px;
}

.game-info p {
  max-width: 30rem;
  margin: 0;
  color: rgba(248, 250, 252, 0.88);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Modal styles (Add Game) */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.show {
  opacity: 1;
  pointer-events: auto;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(8px);
}
.modal-content {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  background: rgba(12, 18, 28, 0.85);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 24px;
  transform: scale(0.92);
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal.show .modal-content {
  transform: scale(1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 750;
  margin: 0;
}
.close-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 200ms ease;
}
.close-button:hover {
  color: var(--ink);
}

/* Form controls */
.form-group {
  margin-bottom: 16px;
  display: grid;
  gap: 6px;
}
.form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input,
.form-group textarea {
  background: rgba(6, 10, 16, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(88, 196, 255, 0.2);
}
.submit-button {
  width: 100%;
  background: linear-gradient(135deg, var(--blue), var(--pink));
  border: 0;
  border-radius: 8px;
  padding: 12px;
  color: #070a10;
  font-size: 1rem;
  font-weight: 750;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(255, 77, 141, 0.25);
  transition: transform 150ms ease, filter 200ms ease;
  margin-top: 10px;
}
.submit-button:hover {
  filter: brightness(1.1);
}
.submit-button:active {
  transform: scale(0.98);
}

/* Drawer styles (Comments) */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}
.drawer.show {
  opacity: 1;
  pointer-events: auto;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.5);
  backdrop-filter: blur(4px);
}
.drawer-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: rgba(10, 14, 22, 0.88);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer.show .drawer-content {
  transform: translateX(0);
}
.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
}
.comments-list {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.comment-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.comment-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--pink));
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 750;
  color: #070a10;
  flex-shrink: 0;
}
.comment-body {
  display: grid;
  gap: 4px;
}
.comment-author {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--ink);
}
.comment-text {
  font-size: 0.9rem;
  color: rgba(248, 250, 252, 0.85);
  line-height: 1.35;
}
.comment-time {
  font-size: 0.72rem;
  color: var(--muted);
}
.comment-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  background: rgba(6, 10, 16, 0.4);
}
.comment-input-area input {
  flex: 1;
  background: rgba(6, 10, 16, 0.6);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
}
.comment-input-area input:focus {
  border-color: var(--blue);
}
.send-comment-btn {
  background: transparent;
  border: 0;
  color: var(--blue);
  font-size: 0.95rem;
  font-weight: 750;
  cursor: pointer;
  transition: color 200ms ease;
}
.send-comment-btn:hover {
  color: var(--pink);
}

/* Toast notifications */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(64px, env(safe-area-inset-bottom));
  z-index: 150;
  background: rgba(6, 10, 16, 0.9);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--ink);
  transform: translate(-50%, 50px);
  opacity: 0;
  pointer-events: none;
  transition: transform 250ms cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 200ms ease;
  backdrop-filter: blur(10px);
}
.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* Sidebar adjustments */
.rail {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 12px);
  z-index: 5;
  display: grid;
  gap: 12px;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 150ms ease, background-color 200ms ease, color 200ms ease;
}

.icon-button:active {
  transform: scale(0.9);
}

.icon-button.liked {
  color: var(--pink);
  background: rgba(255, 77, 141, 0.15);
  border-color: rgba(255, 77, 141, 0.3);
  text-shadow: 0 0 10px rgba(255, 77, 141, 0.4);
}

.add-game-btn {
  color: var(--green);
  background: rgba(66, 227, 168, 0.15);
  border-color: rgba(66, 227, 168, 0.3);
}

.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 5;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.42);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

/* Responsive sidebar / drawer adjustments for mobile */
@media (max-width: 580px) {
  .drawer {
    align-items: flex-end;
  }
  .drawer-content {
    height: 70dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .drawer.show .drawer-content {
    transform: translateY(0);
  }
}

@media (min-width: 740px) {
  body {
    background:
      linear-gradient(90deg, #02040a, #101522 30%, #101522 70%, #02040a);
  }

  .phone-safe {
    border-inline: 1px solid rgba(255, 255, 255, 0.08);
  }
}

@media (max-height: 680px) {
  .phone-safe {
    gap: 10px;
  }

  h1,
  h2 {
    font-size: clamp(1.8rem, 10vw, 3rem);
  }

  .game-info p {
    font-size: 0.9rem;
  }
}
