:root {
  --stone: #2a2c26;
  --stone-deep: #171814;
  --moss: #5c7a4f;
  --torch: #ff9a3c;
  --torch-dim: #b9600f;
  --parchment: #e9c88a;
  --ink: #d8d3c2;
  --app-height: 100dvh;
}

@font-face {
  font-family: "Minecraft";
  src: url("./Minecraft.otf") format("opentype");
  font-display: block;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: var(--app-height);
  height: var(--app-height);
  background: var(--stone-deep);
  font-family: "Courier New", ui-monospace, monospace;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body * {
  -webkit-user-select: none;
  user-select: none;
}

#canvas-wrap {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.nav-hint {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 40px;
  color: rgba(192, 192, 192, 0.5);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

#nav-hint-left {
  left: 12px;
}

#nav-hint-right {
  right: 12px;
}

#lock-toggle {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 13px;
  color: #c0c0c0;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid #555;
  padding: 5px 12px 6px;
  cursor: pointer;
  image-rendering: pixelated;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222;
}

#lock-toggle:hover {
  background: rgba(30, 30, 30, 0.9);
}

#sensor-toggle {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 12px;
  color: #c0c0c0;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid #555;
  padding: 5px 10px 6px;
  cursor: pointer;
  image-rendering: pixelated;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222;
  display: none;
}

#sensor-toggle:hover {
  background: rgba(30, 30, 30, 0.9);
}

#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #2f3129 0%, var(--stone-deep) 70%);
  color: var(--ink);
  z-index: 50;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-screen-inner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-bar {
  width: min(220px, 70vw);
  height: 10px;
  border: 1px solid #555;
  background: rgba(10, 10, 10, 0.7);
  overflow: hidden;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222;
}

.loading-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--torch), var(--torch-dim));
  transition: width 0.2s ease;
}

#fallback {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--stone-deep);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  font-size: 13px;
  line-height: 1.6;
  z-index: 30;
}

@media (max-width: 720px), (max-height: 480px) {
  .nav-hint {
    font-size: 28px;
  }

  #nav-hint-left {
    left: 6px;
  }

  #nav-hint-right {
    right: 6px;
  }

  #lock-toggle {
    bottom: 10px;
    font-size: 11px;
    padding: 4px 10px 5px;
  }
}

#now-playing {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%) translateY(6px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 14px;
  color: #e0e0e0;
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 10px 6px;
  image-rendering: pixelated;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity 400ms ease,
    transform 400ms ease;
}

#now-playing.now-playing-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#now-playing-icon {
  color: var(--torch);
  font-size: 15px;
}




#now-playing.now-playing-show #now-playing-text {
  animation: now-playing-rainbow 2.4s linear infinite;
}

@keyframes now-playing-rainbow {
  0% {
    color: hsl(0, 100%, 68%);
  }
  16% {
    color: hsl(60, 100%, 68%);
  }
  33% {
    color: hsl(120, 100%, 68%);
  }
  50% {
    color: hsl(180, 100%, 68%);
  }
  66% {
    color: hsl(240, 100%, 68%);
  }
  83% {
    color: hsl(300, 100%, 68%);
  }
  100% {
    color: hsl(360, 100%, 68%);
  }
}

@media (max-width: 720px), (max-height: 480px) {
  #now-playing {
    bottom: 52px;
    font-size: 11px;
    padding: 5px 10px 6px;
  }
}

#mc-tooltip {
  display: none;
  position: fixed;
  z-index: 40;
  pointer-events: none;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 14px;
  color: #c0c0c0;
  background: rgba(10, 10, 10, 0.95);
  padding: 5px 9px 6px;
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222,
    0 0 0 2px #0a0a0a;
  image-rendering: pixelated;
  min-width: 50px;
  max-width: 420px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  transform-origin: left top;
  opacity: 0;
}

#mc-tooltip img {
  image-rendering: auto;
  border: 1px solid #555555;
}

#gh-card {
  display: none;
  position: fixed;
  z-index: 41;
  pointer-events: none;
  max-width: calc(100vw - 24px);
  max-height: 65vh;
  font-family: "Minecraft", "Courier New", monospace;
  color: #ffffff;
  transition:
    opacity 200ms cubic-bezier(0.2, 0.9, 0.2, 1),
    transform 200ms cubic-bezier(0.2, 0.9, 0.2, 1);
  transform-origin: top left;
  opacity: 0;
}

#gh-card.locked {
  pointer-events: auto;
}

.gh-card {
  background: rgba(10, 10, 10, 0.95);
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222,
    0 0 0 2px #0a0a0a;
  padding: 10px 12px 12px;
  image-rendering: pixelated;
  max-height: 60vh;
  overflow-y: auto;
}

.gh-card.gh-repo-card,
.gh-card.gh-guestbook {
  width: 320px;
  max-height: 60vh;
}

.gh-card::-webkit-scrollbar {
  width: 5px;
}

.tooltip-show {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
}
.tooltip-hide {
  opacity: 0 !important;
  transform: translateY(-6px) scale(0.98) !important;
}
.card-show {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto;
}
.card-hide {
  opacity: 0 !important;
  transform: translateY(6px) scale(0.98) !important;
  pointer-events: none;
}

.guestbook-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  height: var(--app-height);
  min-height: var(--app-height);
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.guestbook-modal.active {
  display: flex;
}

.guestbook-modal-sign {
  width: min(420px, 100%);
  max-height: calc(var(--app-height) - 40px);
  overflow-y: auto;
  background: rgba(10, 10, 10, 0.95);
  box-shadow:
    inset 1px 1px 0 0 #6a6a6a,
    inset -1px -1px 0 0 #222222,
    0 0 0 2px #0a0a0a;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  font-family: "Minecraft", "Courier New", monospace;
  color: #c0c0c0;
}

.guestbook-modal-header {
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #aaaaaa;
}

#guestbook-modal-input {
  width: 100%;
  min-height: 44px;
  padding: 12px 10px;
  border: 1px solid #555555;
  background: rgba(5, 5, 5, 0.6);
  color: #c0c0c0;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 14px;
  outline: none;
}

#guestbook-modal-input:focus {
  border-color: #888888;
}

.guestbook-modal-sign button {
  color: #ffaa00;
  border: 1px solid #555555;
  background: rgba(60, 60, 60, 0.25);
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}

.guestbook-modal-sign button:hover {
  background: rgba(80, 80, 80, 0.35);
}

.gh-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gh-card-title {
  font-size: 13px;
  color: var(--torch);
}

.gh-card-close {
  font-size: 13px;
  color: #999999;
  line-height: 1;
}

#gh-card.locked .gh-card-close {
  color: var(--torch);
  cursor: pointer;
}

.gh-card-loading {
  font-size: 12px;
  color: #aaaaaa;
  padding: 4px 0 2px;
}

.gh-avatar {
  width: 32px;
  height: 32px;
  border-radius: 0;
  image-rendering: pixelated;
}

.gh-card-body {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gh-guestbook-body {
  flex-direction: column;
  gap: 10px;
}

#guestbook-entry {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: 2px solid #555555;
  background: rgba(10, 10, 10, 0.8);
  color: #c0c0c0;
  font-family: "Minecraft", "Courier New", monospace;
  font-size: 12px;
  padding: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.gh-card-actions {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.gh-guestbook-list {
  border: 2px solid #555555;
  padding: 10px;
  max-height: 180px;
  overflow-y: auto;
  background: rgba(20, 20, 20, 0.6);
}

.gh-guestbook-entry {
  font-size: 12px;
  color: #cccccc;
  padding: 6px 0;
  border-bottom: 1px solid rgba(60, 60, 60, 0.5);
}

.gh-guestbook-entry:last-child {
  border-bottom: none;
}

.gh-guestbook-empty {
  color: #aaaaaa;
  font-size: 12px;
  padding: 4px 0;
}

.gh-name {
  font-size: 14px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gh-handle {
  font-size: 12px;
  color: #aaaaaa;
}

.gh-card-stats {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid #555555;
  font-size: 12px;
  color: #aaaaaa;
}

.gh-card-stats b {
  color: #ffaa00;
}

.gh-repo-card {
  width: 320px;
}

.gh-repo-owner {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #aaaaaa;
  margin-bottom: 8px;
}

.gh-avatar-sm {
  width: 16px;
  height: 16px;
  border-radius: 0;
  image-rendering: pixelated;
  display: block;
  background: #555555;
}

.gh-owner {
  color: #bbbbbb;
}

.gh-repo-name-link {
  color: #7ee0a8;
}

.gh-repo-desc {
  font-size: 12.5px;
  color: #cccccc;
  line-height: 1.4;
  margin-bottom: 8px;
}

.gh-repo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: #aaaaaa;
  margin-bottom: 10px;
}

.gh-lang {
  display: flex;
  align-items: center;
  gap: 5px;
}

.gh-lang-dot {
  width: 7px;
  height: 7px;
  border-radius: 0;
  display: inline-block;
}

.gh-repo-btn {
  text-align: center;
  font-size: 12px;
  color: var(--torch);
  border: 2px solid #555555;
  background: rgba(60, 60, 60, 0.35);
  padding: 7px 0;
  margin-bottom: 10px;
}

#gh-card.locked .gh-repo-btn {
  cursor: pointer;
}

#gh-card.locked .gh-repo-btn:hover {
  background: rgba(255, 154, 60, 0.16);
  border-color: var(--torch);
}

.gh-section-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888888;
  margin: 8px 0 4px;
}

.gh-files-list {
  border: 1px solid #555555;
  max-height: 140px;
  overflow-y: auto;
}

.gh-files-list::-webkit-scrollbar {
  width: 5px;
}

.gh-files-list::-webkit-scrollbar-thumb {
  background: #555555;
}

.gh-file-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  padding: 4px 8px;
  border-bottom: 1px solid #555555;
  color: #cccccc;
}

.gh-file-row:last-child {
  border-bottom: none;
}

.gh-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-file-size {
  color: #888888;
  flex-shrink: 0;
}

.gh-readme-body {
  font-size: 11.5px;
  line-height: 1.5;
  color: #cccccc;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 4px;
}

.gh-readme-body p {
  margin: 0 0 8px;
}

.gh-readme-body ul {
  margin: 0 0 8px;
  padding-left: 16px;
}

.gh-readme-body li {
  margin-bottom: 4px;
}

.gh-readme-body h1,
.gh-readme-body h2,
.gh-readme-body h3 {
  font-size: 12px;
  color: var(--torch);
  margin: 6px 0;
}

.gh-readme-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
}

.gh-readme-body::-webkit-scrollbar {
  width: 5px;
}

.gh-readme-body::-webkit-scrollbar-thumb {
  background: #555555;
}
