:root {
  --bg-primary: #fcebeb;
  --bg-secondary: #fdfbfb;
  --btn-bg: #fdfbfb;
  --text: #1a1a1a;
  --border: #e0d8d8;
}

/* ================= Base ================= */
::selection {
  background: rgba(255, 16, 240, 0.5); /* #FF10F0 at 50% opacity */
  color: inherit;
}

body {
  background: var(--bg-primary);
  color: var(--text);
  font-family: monospace;
  line-height: 1.65;
  margin: 0 auto;
  padding: 2em;
  max-width: 1200px;
  min-height: calc(100vh - 4em);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* create page layout refinements */
.create-page {
  padding: 1em 20px;
}

@media (max-width: 600px) {
  .create-page {
    padding: 10px 10px;
  }
}

.create-page #topbar {
  padding: 0;
  margin-bottom: 1em;
}

.create-page footer {
  padding: 2em 0;
}

footer {
  margin-top: auto !important;
  text-align: left;
  padding: 2em 0;
  border-top: 1px solid var(--border);
  color: #666;
}

footer a {
  color: inherit;
  text-decoration: underline;
}

h1, h2, h3, h4 { line-height: 1.2; }
h1 { font-size: 2.2em; margin-top: 0; }
h2, h3, h4 { margin-top: 2em; margin-bottom: 0.5em; }

a {
  color: #000;
  text-decoration: underline;
}
a:hover { text-decoration: none; }

code, pre {
  background: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

pre {
  padding: 1em;
  overflow-x: auto;
  border-radius: 5px;
}

img {
  max-width: 100%;
  height: auto;
  border: none;
}

/* ================= Buttons ================= */
button, .tool-btn {
  background: var(--btn-bg);
  color: var(--text);
  border: none;
  padding: 0.5em 1em;
  font-family: monospace;
  font-size: 1em;
  cursor: pointer;
  border-radius: 8px;
}

button.primary-btn {
  background: rgba(255, 16, 240, 0.5); /* #FF10F0 at 50% opacity */
  color: var(--text);
  font-weight: bold;
  padding: 0.5em 2.5em; /* Increased length */
}

button.primary-btn:hover {
  background: #e60ed8; /* Slightly darker pink */
}

button:hover { background: var(--bg-secondary); filter: brightness(0.95); }

.tool-btn.selected {
  background: var(--bg-secondary);
  filter: brightness(0.95);
}

.icon-btn, .tool-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2rem;
}

/* ================= Layout ================= */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5em; /* Reduced margin */
  gap: 1em;
}

#topbar h1 {
  flex: 1;
  text-align: center;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

#headerLogo {
  max-width: 200px;
  height: auto;
  display: block;
  cursor: pointer;
}

@media (max-width: 600px) {
  #headerLogo {
    max-width: 150px;
  }
}

#topbar-right {
  display: flex;
  gap: 0.5em;
}



/* ================= Feed ================= */
#feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.post {
  background: var(--bg-secondary);
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.post img {
  width: 100%;
  height: auto;
  cursor: pointer;
  display: block;
  margin: 0 0 5px 0;
  border: none;
  background: var(--bg-secondary); /* to handle transparency well if any */
}

.post .words {
  font-family: monospace;
  font-size: 0.75em;
  color: #666;
  opacity: 0.8;
}

.author-link {
  cursor: pointer;
  text-decoration: underline;
}

/* ================= Canvas ================= */
#canvasContainer {
  width: 100%;
  max-width: 900px;
  margin: 0 auto 1em auto;
  background: var(--bg-secondary);
  aspect-ratio: 4/3;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05); /* more subtle shadow */
  touch-action: none; /* Crucial for drawing */
}

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

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5em;
}

.tool-buttons {
  display: flex;
  gap: 4px;
}

.brush-label {
  margin: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}



/* Form spacing */
.create-page > div:not(#topbar):not(#canvasContainer):not(.controls) {
  margin-top: 1em;
}

input[type="text"], input[type="password"], textarea {
  width: 100%;
  margin-top: 0.5em;
  font-family: monospace;
  border: none;
  border-radius: 5px;
  padding: 0.5em;
  background: var(--bg-secondary);
}

input[type="number"] {
  font-family: monospace;
  border: none;
  border-radius: 5px;
  padding: 0.3em;
  background: var(--bg-secondary);
}

textarea { height: 120px; }

/* ================= Cursor ================= */
#cursorPreview {
  background: rgba(0,0,0,0.2);
  border-radius: 50%;
  box-sizing: content-box;
}

.post.not-mine {
  position: relative;
  transition: all 0.3s ease;
}

.post.not-mine img {
  filter: grayscale(0.2) brightness(0.8);
}

.post.not-mine::after {
  content: "";
  position: absolute;
  top: 15px; /* match post padding */
  left: 15px;
  right: 15px;
  bottom: 45px; /* roughly leave the words visible? or cover all? */
  background: rgba(255, 16, 240, 0.4); /* Neon Magenta at 40% */
  pointer-events: none;
  z-index: 1;
}

.post.not-mine .words {
  opacity: 0.5;
}

/* ================= Mobile ================= */
@media (max-width: 600px) {
  #topbar {
    flex-wrap: wrap;
  }
  
  #topbar h1 {
    flex: 1 0 100%;
    order: -1;
    margin-bottom: 0.5em;
  }
  
  #topbar-left {
    order: 2;
  }
  
  #topbar-right {
    order: 3;
    margin-left: auto;
  }
}

/* ================= Post page ================= */
#postContent img {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 80vh;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto;
}

/* ================= Suggestions / Spoilers ================= */
.spoiler {
  background: rgba(255, 16, 240, 0.1); /* Subtle pink background for prompts */
  color: inherit;
  padding: 0 4px;
  border-radius: 3px;
}
#postContainer {
  max-width: 900px;
  margin: 0 auto; /* Zero vertical margin */
  padding: 0 1em;
}

/* ================= Shop ================= */
.shop-item {
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
}

.shop-item:hover {
  transform: translateY(-2px);
}

.shop-item img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-secondary);
  transition: all 0.2s ease;
}

.shop-item.selected img {
  outline: 6px solid #FF10F0; /* Brighter neon pink */
  box-shadow: 0 0 25px rgba(255, 16, 240, 0.4);
  transform: scale(1.02);
}

.shop-item.selected::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  background: #FF10F0;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  z-index: 2;
}

#checkoutBar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  box-sizing: border-box;
  text-align: center;
  z-index: 1000;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

.support-section {
  background: var(--bg-secondary);
  border: 4px double var(--border);
  padding: 2rem;
  margin: 4rem auto;
  max-width: 600px;
  text-align: center;
  font-family: monospace;
}

.bmc-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFDD00;
  color: #000000;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  margin-top: 1rem;
  transition: transform 0.2s ease;
}

.bmc-button:hover {
  transform: scale(1.05);
  text-decoration: none;
}

.like-btn, #likeBtn {
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-block;
}

.like-btn:hover, #likeBtn:hover {
  transform: scale(1.3);
}

.like-btn:active, #likeBtn:active {
  transform: scale(0.9);
}