:root {
  color: #202124;
  background: #edf1f4;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #263241;
  color: #fff;
  font-weight: 750;
  padding: 0 14px;
}

button.active {
  background: #1f7a5f;
}

.app {
  display: grid;
  gap: 14px;
  width: min(1180px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.workspace,
.touch-panel {
  border: 1px solid #d5dde4;
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.topbar,
.pad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #557087;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 4vw, 2.4rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 340px;
  gap: 14px;
  margin-top: 14px;
}

.canvas-panel,
.controls-panel {
  display: grid;
  gap: 12px;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #ccd6dd;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #d9e0e5 25%, transparent 25%),
    linear-gradient(-45deg, #d9e0e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9e0e5 75%),
    linear-gradient(-45deg, transparent 75%, #d9e0e5 75%);
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
  padding: 10px;
}

#pixel-canvas {
  width: min(100%, 66vh, 620px);
  max-height: 66vh;
  aspect-ratio: 1;
  border-radius: 6px;
  image-rendering: pixelated;
  touch-action: none;
}

.cursor-readout {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-radius: 8px;
  background: #e7edf1;
  color: #334454;
  font-size: 0.92rem;
  font-weight: 750;
  padding: 10px 12px;
}

.tool-row,
.action-grid,
.nudge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.color-field,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: #edf3f1;
  color: #243a34;
  font-weight: 750;
  padding: 10px;
}

input[type="color"] {
  width: 72px;
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

input[type="checkbox"] {
  width: 22px;
  height: 22px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.palette button {
  min-height: 42px;
  border: 2px solid #d2d8dd;
  border-radius: 8px;
}

.touch-panel {
  position: sticky;
  bottom: 0;
  box-shadow: 0 -10px 24px rgba(38, 50, 65, 0.1);
}

.pad-header p {
  margin-top: 4px;
  color: #5e6b76;
  line-height: 1.45;
}

.touch-pad {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 164px;
  margin-top: 12px;
  overflow: hidden;
  border: 2px solid #95b6d4;
  border-radius: 8px;
  background: #dcecf8;
  color: #48647b;
  font-weight: 850;
  touch-action: none;
  user-select: none;
}

.pad-cross {
  position: absolute;
  background: rgba(38, 50, 65, 0.14);
}

.pad-cross.horizontal {
  width: 100%;
  height: 2px;
}

.pad-cross.vertical {
  width: 2px;
  height: 100%;
}

.nudge-grid {
  margin-top: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 820px) {
  .app {
    width: min(100vw - 16px, 720px);
    padding-bottom: 8px;
  }

  .topbar,
  .pad-header {
    display: grid;
    align-items: stretch;
  }

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

  .controls-panel {
    grid-template-columns: 1fr;
  }

  #pixel-canvas {
    width: min(100%, 78vw);
    max-height: 58vh;
  }

  .touch-pad {
    min-height: 188px;
  }

  .touch-panel {
    position: static;
    max-height: 260px;
    overflow: auto;
  }
}
