:root {
  color-scheme: dark;
  --background: #070707;
  --surface: #111111;
  --surface-raised: #171717;
  --border: #2a2a2a;
  --border-strong: #444444;
  --text: #f1f1f1;
  --muted: #8e8e8e;
  --danger: #df9696;
  --radius: 15px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
}

.game-screen {
  overflow: hidden;
  background: #050505;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.game-hud {
  position: fixed;
  top: 20px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 4;
}

.game-hud strong {
  font-size: 13px;
  font-weight: 650;
}

.game-hud span {
  color: var(--muted);
  font-size: 12px;
}

.lock-screen {
  display: grid;
  place-items: center;
  padding: 22px;
  background: #030303;
}

.lock-card {
  width: min(390px, 100%);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lock-card h1,
.vault-header h1,
.dialog-card h2 {
  margin: 0;
  font-weight: 580;
  letter-spacing: -0.04em;
}

.lock-card h1 {
  margin-bottom: 15px;
  font-size: clamp(31px, 8vw, 46px);
}

.hint {
  min-height: 21px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.input-row {
  display: flex;
  gap: 9px;
}

.input-row input,
.text-input,
.text-area {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 150ms ease, background 150ms ease;
}

.input-row input,
.text-input {
  padding: 13px 14px;
}

.text-area {
  min-height: 112px;
  padding: 13px 14px;
  resize: vertical;
  line-height: 1.45;
}

.input-row input:focus,
.text-input:focus,
.text-area:focus {
  border-color: var(--border-strong);
  background: #141414;
}

.error,
.status-text {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12px;
}

.error {
  color: var(--danger);
}

.status-text {
  color: var(--muted);
}

.button,
.icon-button {
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.button {
  padding: 10px 13px;
  border-radius: 11px;
  background: var(--surface);
}

.button:hover {
  border-color: #3b3b3b;
  background: var(--surface-raised);
}

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

.button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.button.primary {
  border-color: #eeeeee;
  background: #eeeeee;
  color: #080808;
  font-weight: 700;
}

.button.primary:hover {
  background: #ffffff;
}

.button.danger {
  color: var(--danger);
}

.button.danger:hover {
  border-color: #4a2929;
  background: #211313;
}

.shake {
  animation: shake 280ms ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.vault-screen {
  min-height: 100vh;
  padding: 24px;
}

.vault-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.vault-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 25px;
  border-bottom: 1px solid var(--border);
}

.vault-header h1 {
  font-size: 27px;
}

.subtext {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  padding: 24px 0;
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.image-preview {
  display: grid;
  width: 100%;
  height: 310px;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background-color: #0b0b0b;
  background-image:
    linear-gradient(45deg, #121212 25%, transparent 25%),
    linear-gradient(-45deg, #121212 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #121212 75%),
    linear-gradient(-45deg, transparent 75%, #121212 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-info {
  padding: 14px;
}

.image-name {
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-meta {
  margin: 5px 0 13px;
  color: var(--muted);
  font-size: 11px;
}

.image-actions {
  display: flex;
  gap: 8px;
}

.image-actions .button {
  flex: 1;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 90px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
}

.dialog {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 20px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}

.dialog[open] {
  display: grid;
  place-items: center;
}

.dialog-card {
  width: min(540px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: #101010;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.dialog-card h2 {
  font-size: 21px;
}

.dialog-copy {
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.dialog-copy code {
  color: #d6d6d6;
}

.field-label {
  display: block;
  margin: 14px 0 7px;
  color: #d8d8d8;
  font-size: 12px;
  font-weight: 650;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.split-actions {
  justify-content: space-between;
}

.right-actions {
  display: flex;
  gap: 9px;
}

.edit-preview {
  display: grid;
  min-height: 190px;
  max-height: 320px;
  margin-top: 16px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #080808;
}

.edit-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: contain;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #171717;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
  font-size: 13px;
  animation: toast-in 180ms ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 680px) {
  .vault-screen {
    padding: 15px;
  }

  .vault-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .button {
    flex: 1;
  }

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

  .image-preview {
    height: 290px;
  }

  .input-row {
    align-items: stretch;
    flex-direction: column;
  }

  .split-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .right-actions {
    width: 100%;
  }

  .right-actions .button,
  .split-actions > .button {
    flex: 1;
  }
}
