:root {
  --bg-1: #dfe6ea;
  --bg-2: #d3dde4;
  --surface: #f5f8fa;
  --surface-strong: #ffffff;
  --surface-muted: #ecf2f6;
  --ink: #1a2a33;
  --ink-soft: #5b6d77;
  --line: #b9c8d2;
  --accent: #0078d7;
  --accent-2: #006fbe;
  --danger: #b54848;
  --success: #2f8a68;
  --shadow-1: 0 4px 10px rgba(16, 45, 63, 0.12);
  --shadow-2: 0 2px 6px rgba(16, 45, 63, 0.08);
  --radius-xl: 0;
  --radius-lg: 0;
  --radius-sm: 0;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  font-family: "Segoe UI", "Segoe UI Variable", "Noto Sans", sans-serif;
  padding: 20px;
}

.site-nav {
  max-width: 1450px;
  margin: 0 auto 14px;
  border: 1px solid #96acbb;
  background: #eaf0f4;
  box-shadow: var(--shadow-2);
}

.landing-shell {
  max-width: 1450px;
  margin: 0 auto;
  animation: rise-in 0.4s ease-out;
}

.landing-hero {
  border: 1px solid #9cb0be;
  background: linear-gradient(135deg, #f7fbfd, #e8f1f6);
  box-shadow: var(--shadow-1);
  padding: 28px;
}

.landing-kicker {
  display: inline-block;
  border: 1px solid #8eaec1;
  background: #dce8f0;
  color: #11455f;
  padding: 6px 10px;
  margin-bottom: 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-hero h1 {
  max-width: 10ch;
  color: #11384c;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  text-transform: uppercase;
}

.landing-hero p {
  max-width: 68ch;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.6;
}

.landing-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.landing-primary,
.landing-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.landing-primary {
  background: var(--accent);
  color: #fff;
}

.landing-secondary {
  background: #e2ebf1;
  color: #1f4b62;
  border-color: #aebfcc;
}

.landing-section {
  margin-top: 18px;
  border: 1px solid #9cb0be;
  background: #f6fafc;
  box-shadow: var(--shadow-1);
  padding: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 16px;
}

.section-head h2 {
  color: #11384c;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-head span {
  color: var(--ink-soft);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tool-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.tool-card {
  min-height: 180px;
  border: 1px solid #9eb5c4;
  background: #eaf1f5;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tool-card h3 {
  color: #11384c;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 12px;
}

.tool-card p {
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.5;
  margin-top: 10px;
}

.tool-card span {
  display: inline-block;
  margin-top: 18px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1f4b62;
}

.tool-card-featured {
  background: #dbeaf7;
  border-color: #89a9bf;
}

.tool-card-placeholder {
  background: #eef4f8;
}

.tool-card-tag {
  display: inline-block;
  width: fit-content;
  border: 1px solid #8eaec1;
  background: #d4e1ea;
  color: #11455f;
  padding: 5px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
}

.nav-brand {
  color: #0f3f59;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  display: inline-block;
  padding: 7px 10px;
  border: 1px solid transparent;
  color: #204b62;
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.nav-link:hover {
  background: #dce7ee;
  border-color: #b2c3cf;
}

.nav-link.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nav-toggle {
  display: none;
  border: 1px solid #89a8bb;
  background: #dce8ef;
  color: #1f4559;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 6px 10px;
  cursor: pointer;
}

.nav-contact-toggle {
  font-family: inherit;
  background: #d8e4ec;
  border-color: #adc0cc;
}

.contact-menu {
  display: none;
  border-top: 1px solid #b7c7d2;
  background: #f2f7fa;
  padding: 10px 12px 12px;
}

.site-nav.contact-open .contact-menu {
  display: block;
}

.contact-header {
  font-size: 0.72rem;
  color: #2a556d;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.contact-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.contact-links li {
  margin: 0;
}

.contact-links a {
  display: inline-block;
  text-decoration: none;
  border: 1px solid #adc0cc;
  background: #e1ebf2;
  color: #194a63;
  padding: 7px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.contact-links a:hover {
  background: #d2e2ee;
}

.rpg-app,
.rpg-tool {
  max-width: 1450px;
  margin: 0 auto;
  animation: rise-in 0.4s ease-out;
}

.site-footer {
  max-width: 1450px;
  margin: 14px auto 0;
  border: 1px solid #9cb0be;
  background: #e8eff3;
  box-shadow: var(--shadow-2);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-links a {
  display: inline-block;
  text-decoration: none;
  border: 1px solid #afc1cd;
  background: #dfe9f0;
  color: #1f4b62;
  padding: 7px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.footer-links a:hover {
  background: #d1e1eb;
}

.footer-copy {
  color: #476472;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.rpg-header,
.tool-header {
  margin-bottom: 22px;
  padding: 18px 22px;
  background: #eff4f7;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}

.rpg-header h1,
.tool-header h1 {
  font-size: clamp(1.2rem, 2.8vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #14475b;
}

.rpg-subhead,
.tool-header p {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.rpg-workspace,
.workspace {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.rpg-panel,
.rpg-panel-right,
.control-panel,
.canvas-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.rpg-panel,
.control-panel {
  flex: 1.1;
  min-width: 290px;
}

.rpg-panel-right,
.canvas-panel {
  flex: 2.2;
  min-width: 540px;
}

.rpg-panel-header,
.panel-header {
  background: var(--accent);
  color: #f3fbff;
  padding: 12px 18px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}

.rpg-panel-content,
.panel-content {
  padding: 18px;
}

.rpg-upload,
.upload-area {
  border: 1px dashed #77a9d4;
  border-radius: var(--radius-lg);
  background: #edf4fb;
  padding: 14px;
  text-align: center;
  margin-bottom: 14px;
}

.rpg-upload-label,
.upload-label {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 9px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.rpg-upload-label:hover,
.upload-label:hover {
  transform: translateY(-1px);
  filter: brightness(0.95);
}

input[type="file"] {
  display: none;
}

.rpg-stats {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 10px;
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.stats-accent {
  color: #0d7192;
  font-weight: 700;
}

.sprite-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 2px;
}

.sprite-tile {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-sm);
  border: 1px solid #9eb5c4;
  background: #e7eff4;
  position: relative;
  overflow: hidden;
  cursor: grab;
  transition: transform 0.12s ease;
}

.sprite-tile:hover {
  transform: translateY(-2px);
}

.sprite-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sprite-delete,
.cell-remove,
.delete-sprite {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(181, 72, 72, 0.95);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.rpg-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(6, 72px);
  gap: 8px;
  border-radius: var(--radius-lg);
  background: #eaf1f5;
  padding: 12px;
  border: 1px solid var(--line);
}

.rpg-grid-cell {
  border: 1px solid #b6ccd8;
  border-radius: var(--radius-sm);
  background: #f3f7fa;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rpg-grid-cell.drag-over {
  background: #d9ebfb;
  border-color: var(--accent);
}

.rpg-grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rpg-grid-cell:hover .cell-remove {
  opacity: 1;
}

.cell-remove {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.empty-sprite {
  font-size: 0.62rem;
  color: #6f8a96;
}

.rpg-actions,
.action-buttons {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.action-buttons {
  justify-content: center;
}

.rpg-btn,
.reset-btn {
  border: 1px solid #99b9c8;
  background: #edf5f9;
  color: #244a5b;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.rpg-btn:hover,
.reset-btn:hover {
  background: #deebf3;
}

.rpg-btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.rpg-btn-danger {
  background: #fcecec;
  border-color: #efc3c3;
  color: #8f3a3a;
}

.rpg-btn-success {
  background: #e4f6ef;
  border-color: #b7ddcd;
  color: #22684d;
}

.rpg-hint,
.tip-card {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  text-align: center;
}

.import-export-row {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.muted-note {
  margin-top: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
}

.toast-notify,
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: #fff;
  box-shadow: var(--shadow-2);
  animation: toast-fade 2.5s ease forwards;
  z-index: 1000;
  font-size: 0.82rem;
}

.sprite-list {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f6fbfd;
}

.sprite-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid #d8e6ee;
  cursor: pointer;
}

.sprite-item:hover {
  background: #ecf5fa;
}

.sprite-item.active {
  background: #dbeafb;
  border-left: 4px solid var(--accent);
}

.sprite-thumb {
  width: 40px;
  height: 40px;
  border: 1px solid #b6ccd8;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.sprite-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sprite-info {
  flex: 1;
  font-size: 0.72rem;
}

.sprite-name {
  font-weight: 700;
  color: #14475b;
}

.sprite-dims {
  color: #63808e;
  font-size: 0.65rem;
}

.delete-sprite {
  position: static;
}

.position-controls,
.transform-info {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #eef4f8;
  padding: 12px;
  margin-bottom: 12px;
}

.control-group {
  margin-bottom: 12px;
}

.control-group label {
  display: block;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #386779;
  margin-bottom: 6px;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="range"] {
  flex: 1;
}

.coord-input {
  width: 64px;
  border: 1px solid #afc6d3;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: #254a5b;
  background: #fff;
  text-align: center;
}

.transform-info p {
  font-size: 0.72rem;
  color: #5a7684;
  margin-bottom: 4px;
}

.transform-info span {
  color: #154b5f;
  font-weight: 700;
}

.canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.canvas-wrapper {
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: #eff7fb;
}

canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid #b7ceda;
  background-image:
    linear-gradient(45deg, #e7eff4 25%, transparent 25%),
    linear-gradient(-45deg, #e7eff4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7eff4 75%),
    linear-gradient(-45deg, transparent 75%, #e7eff4 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

@keyframes toast-fade {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(6px);
    visibility: hidden;
  }
}

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

@media (max-width: 980px) {
  .rpg-panel-right,
  .canvas-panel {
    min-width: 320px;
  }

  .rpg-grid {
    grid-template-rows: repeat(6, 58px);
    gap: 6px;
  }

  .nav-toggle {
    display: inline-block;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid #bfd0da;
    margin-top: 6px;
  }

  .site-nav.is-open .nav-links {
    display: flex;
  }

  .nav-inner {
    flex-wrap: wrap;
  }

  .nav-link {
    width: 100%;
    text-align: left;
  }

  .nav-contact-toggle {
    width: 100%;
  }

  .contact-links {
    flex-direction: column;
  }

  .contact-links a {
    width: 100%;
    text-align: left;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-links,
  .footer-links a {
    width: 100%;
  }

  .tool-card-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .landing-hero {
    padding: 20px;
  }
}
