/* ========== GUESTBOOK (Nintendo DS / PicoChat-ish) ========== */

:root {
  --ds-bg: rgba(112, 108, 108, 0.1);
  --ds-panel: rgba(115, 108, 134, 0.25);
  --ds-panel-2: rgba(115, 108, 134, 0.2);
  --ds-border: rgb(208, 226, 184);
  --ds-dark: rgb(208, 226, 184);
  --ds-text: rgb(208, 226, 184);

  --grid-a: rgba(208, 226, 184, 0.05);
  --grid-b: rgba(208, 226, 184, 0.02);
}

/* DS Screen */
.right-sidebar {
  font-family: 'DotGothic16', monospace;
  background: var(--ds-bg);
  border: .1px solid rgb(208, 226, 184);
  padding: 10px;
  height: auto;
  max-height: 520px;
  width: 100%;
  max-width: 100%;
  position: relative;
  backdrop-filter: blur(4px);
  overflow: hidden;
  box-shadow:
  0 0 50px rgba(255, 140, 90, 0.15),
  inset 0 0 0 1px rgba(255, 200, 170, 0.12);
}

/* Faint LCD grid + a little “screen noise” */
.right-sidebar::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom,
      var(--grid-b),
      var(--grid-b) 1px,
      transparent 1px,
      transparent 14px),
    repeating-linear-gradient(to right,
      var(--grid-a),
      var(--grid-a) 1px,
      transparent 1px,
      transparent 14px);
  mix-blend-mode: multiply;
}

/* Title tab */
.right-sidebar-title {
  position: relative;
  z-index: 2;
  font-size: 20px;
  background: transparent;
  color: rgb(208, 226, 184);
  padding: 6px 8px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 6px;
  letter-spacing: 0;
  font-family: 'Jacquard 12', sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Messages panel */
#gbMessages {
  position: relative;
  z-index: 2;
  background: rgba(115, 108, 134, 0.4);
  border: .1px solid var(--ds-border);
  height: 270px;
  min-height: 270px;
  max-height: 270px;
  padding: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 11px;
  width: 100%;

  /* bevel */
  box-shadow:
    inset 0 1px 0 rgba(208, 226, 184, 0.15),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

/* Chunky DS-ish scrollbar */
#gbMessages::-webkit-scrollbar {
  width: 10px;
}

#gbMessages::-webkit-scrollbar-track {
  background: rgba(115, 108, 134, 0.15);
  border-left: 1px solid rgba(208, 226, 184, 0.25);
}

#gbMessages::-webkit-scrollbar-thumb {
  background: rgba(255, 79, 216, 0.4);
  border: 1px solid rgba(208, 226, 184, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 79, 216, 0.2);
}

#gbMessages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 79, 216, 0.6);
}

/* Entries */
.gb-entry {
  background: linear-gradient(180deg, #7d8796 0%, #6c7585 100%);
  border: .1px solid var(--ds-border);
  padding: 6px;
  margin-bottom: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16);
  opacity: 1;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Meta */
.gb-meta {
  font-size: 9px;
  color: rgb(225, 244, 199);
  margin-bottom: 4px;
  border-bottom: 1px dotted rgba(208, 226, 184, 0.4);
  padding-bottom: 2px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.gb-meta strong {
  font-weight: normal;
  letter-spacing: 0;
}

/* Cycling name colors: blue, pink, purple */
.gb-entry:nth-child(3n+1) .gb-meta strong {
  color: rgba(172, 245, 152, 0.8);
  /* Blue */
}

.gb-entry:nth-child(3n+2) .gb-meta strong {
  color: rgba(250, 205, 241, 0.8);
  /* Pink */
}

.gb-entry:nth-child(3n) .gb-meta strong {
  color: rgba(249, 220, 188, 0.8);
  /* Purple */
}

.gb-meta span {
  font-size: 8px;
  color: rgba(208, 226, 184, 0.6);
  font-family: monospace;
  letter-spacing: 0.4px;
}

/* Text */
.gb-text {
  font-size: 11px;
  line-height: 1.6;
  color: var(--ds-text);
  font-family: 'DotGothic16', monospace;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
  hyphens: auto;
}

/* If message has a stamp, add padding on the right */
.gb-text:has(img) {
  padding-right: 60px;
  padding-bottom: 12px;
  min-height: 56px;
}

.gb-text img {
  position: absolute;
  bottom: 6px;
  right: 6px;
  max-width: 50px;
  max-height: 50px;
  border: none;
  padding: 0;
  background: none;
  box-shadow: none;
}

/* ===========================
   INPUT PANEL (layout fix)
   =========================== */

/* Form structure and styling */
#guestbookForm {
  position: relative;
  z-index: 2;
  margin-top: 10px;
  background: rgba(115, 108, 134, 0.35);
  border: .1px solid var(--ds-border);
  padding: 10px;
  box-shadow:
    inset 0 1px 0 rgba(208, 226, 184, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.15);
  width: 100%;
  box-sizing: border-box;

  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto;
  gap: 6px;
  align-items: start;
}

/* Name takes full width */
#gbName {
  grid-column: 1 / -1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  height: 32px;
}

/* Message and buttons row */
.gb-message-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

/* Message box */
#gbMessage {
  width: 100%;
  max-width: 100%;
  min-height: 80px;
  max-height: 80px;
  height: 80px;
  resize: none;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Button stack container */
.gb-button-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  justify-content: flex-start;
}

/* Buttons */
#guestbookForm button[type="button"],
#guestbookForm button[type="submit"] {
  width: 110px;
  min-width: 110px;
  max-width: 110px;
  min-height: 37px;
  max-height: 37px;

  position: relative;
  background: #736c86;
  border: .1px solid var(--ds-border);
  font-size: 10px;
  color: rgb(208, 226, 184);
  padding: 0 10px 0 22px;
  text-align: left;

  box-shadow: inset 13px 0px 6px -10px rgb(66 66 66 / 20%), inset -13px 0px 6px -10px rgb(66 66 66 / 56%), inset 0px 13px 6px -10px #9d9d9d, inset 0px -13px 6px -10px rgb(66 66 66 / 38%);
  opacity: 0.85;
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
}

#gbAddStamp::before {
  content: "★";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-58%);
  font-size: 10px;
  opacity: 0.85;
}

#guestbookForm button[type="submit"]::before {
  content: "▲";
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-58%);
  font-size: 10px;
  opacity: 0.85;
}

#guestbookForm button[type="button"]:hover,
#guestbookForm button[type="submit"]:hover {
  opacity: 0.9;
}

#guestbookForm button[type="button"]:active,
#guestbookForm button[type="submit"]:active {
  opacity: 1;
  box-shadow:
    inset 0 2px 0 rgba(0, 0, 0, 0.3),
    inset 0 -1px 0 rgba(208, 226, 184, 0.2);
}

#guestbookForm button[type="button"]:disabled,
#guestbookForm button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inputs styling */
#gbName,
#gbMessage {
  background: rgb(97, 92, 114);
  border: .1px solid var(--ds-border);
  font-size: 11px;
  padding: 6px 8px;
  color: rgb(208, 226, 184);
  box-shadow: inset 0 0 0 1px rgba(208, 226, 184, 0.15);
  font-family: 'DotGothic16', monospace;
}

#gbName::placeholder,
#gbMessage::placeholder {
  color: rgba(208, 226, 184, 0.4);
  opacity: 1;
}

#gbName:focus,
#gbMessage:focus {
  outline: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 79, 216, 0.5),
    0 0 8px rgba(255, 79, 216, 0.2);
}

/* Status line */
#gbStatus {
  grid-column: 1 / -1;
  font-size: 9px;
  text-align: center;
  font-family: 'DotGothic16', sans-serif;
  color: rgba(208, 226, 184, 0.7);
  letter-spacing: 0.3px;
  padding: 2px 0;
  min-height: 14px;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
#gbMessages:empty::after {
  content: "No messages.\AStart chatting.";
  white-space: pre;
  font-size: 10px;
  color: rgba(208, 226, 184, 0.5);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* ===========================
   STAMP PICKER MODAL
   =========================== */

#stampPickerModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

#stampPickerModal.show {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.stamp-picker-container {
  background: rgba(115, 108, 134, 0.95);
  border: 2px solid rgb(208, 226, 184);
  padding: 16px;
  max-width: 400px;
  max-height: 500px;
  overflow-y: auto;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(208, 226, 184, 0.2);
  backdrop-filter: blur(10px);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.stamp-picker-container::-webkit-scrollbar {
  width: 8px;
}

.stamp-picker-container::-webkit-scrollbar-track {
  background: rgba(115, 108, 134, 0.3);
}

.stamp-picker-container::-webkit-scrollbar-thumb {
  background: rgba(255, 79, 216, 0.4);
  border-radius: 4px;
}

.stamp-picker-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 79, 216, 0.6);
}

.stamp-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(208, 226, 184, 0.4);
}

.stamp-picker-title {
  font-family: 'Jacquard 12', sans-serif;
  font-size: 16px;
  color: rgb(208, 226, 184);
  line-height: 1.2;
}

.stamp-picker-close {
  background: #736c86;
  border: 1px solid rgb(208, 226, 184);
  color: rgb(208, 226, 184);
  font-size: 18px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  box-shadow: inset 13px 0px 6px -10px rgb(66 66 66 / 20%), inset -13px 0px 6px -10px rgb(66 66 66 / 56%), inset 0px 13px 6px -10px #9d9d9d, inset 0px -13px 6px -10px rgb(66 66 66 / 38%);
}

.stamp-picker-close:hover {
  opacity: 1;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 4px;
}

.stamp-option {
  background: rgba(97, 92, 114, 0.6);
  border: 1px solid rgba(208, 226, 184, 0.4);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  box-shadow: inset 0 1px 0 rgba(208, 226, 184, 0.1);
  transition: all 0.2s;
}

.stamp-option:hover {
  background: rgba(97, 92, 114, 0.8);
  border-color: rgba(255, 79, 216, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(208, 226, 184, 0.15),
    0 0 8px rgba(255, 79, 216, 0.3);
}

.stamp-option img {
  max-width: 100%;
  max-height: 70px;
  object-fit: contain;
}