html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  font-family: sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #222;
  transition: background 0.2s, color 0.2s;
}
body.dark {
  background: #222;
  color: #eee;
}
div h2 {
  text-align: center;
}
footer {
  margin-top: auto;
  text-align: center;
  padding: 1em 0;
}
#topbar {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  padding: 10px;
  background: #f7f7f7;
  border-bottom: 1px solid #ddd;
  transition: background 0.2s, border-color 0.2s;
}
body.dark #topbar {
  background: #222;
  border-bottom: 1px solid #444;
}
#topbar button {
  font-size: 22px;
  padding: 10px 28px;
  background: #f9f9f9;
  color: #222;
  border: 1px solid #bbb;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
#topbar button:hover,
#topbar button:focus {
  background: #e0e0e0;
  color: #111;
  border-color: #888;
}
body.dark #topbar button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
}
body.dark #topbar button:hover,
body.dark #topbar button:focus {
  background: #444;
  color: #fff;
  border-color: #888;
}
#outlineBtn.outline-off {
  background: #eee !important;
  color: #222 !important;
}
body.dark #outlineBtn.outline-off {
  background: #222 !important;
  color: #bbb !important;
}
#container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  height: 93vh;
}
#left, #right {
  width: 375px;
  overflow-y: auto;
  height: 90vh;
  background: transparent;
  color: inherit;
  transition: background 0.2s, color 0.2s;
}
body.dark #left,
body.dark #right {
  background: #222;
  color: #eee;
}
#center {
  flex: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.grid {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
}
#backgrounds img, #templates img, #characters img, #items img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin: 0;
  cursor: pointer;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s, border-color 0.2s;
}
#canvasWrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 80vw;
  max-height: 60vh;
  background: #eee;
  margin-bottom: 8px;
  transition: background 0.2s;
}
body.dark #canvasWrapper {
  background: #222;
}
#memeCanvas {
  background: #eee;
  border: 1px solid #333;
  display: block;
  max-width: 100%;
  max-height: 60vh;
  transition: background 0.2s, border-color 0.2s;
}
body.dark #memeCanvas {
  background: #111;
  border-color: #bbb;
}
#textInputs {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#textInputs input[type="text"] {
  margin: 2px;
  width: 260px;
  font-size: 22px;
  font-weight: bold;
}
#textInputs button {
  margin: 2px;
  font-size: 18px;
  background: #f9f9f9;
  color: #222;
  border: 1px solid #bbb;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
#textInputs button:hover,
#textInputs button:focus {
  background: #e0e0e0;
  color: #111;
  border-color: #888;
}
body.dark #textInputs button {
  background: #333;
  color: #eee;
  border: 1px solid #555;
}
body.dark #textInputs button:hover,
body.dark #textInputs button:focus {
  background: #444;
  color: #fff;
  border-color: #888;
}
#fontControls {
  display: flex;
  gap: 10px;
  margin-top: 7px;
  align-items: center;
}
.outline-border {
  stroke: red !important;
}
.rotate-icon {
  position: absolute;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid #444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 10;
}
.font-and-text {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}
.fontControls {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 180px;
}
.fontControls > div {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.fontControls label {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.fontControls span {
  display: inline-block;
  text-align: right;
  min-width: 60px;
  margin-right: 10px;
}
.fontControls select,
.fontControls input[type="color"],
.fontControls input[type="number"] {
  flex: 1;
  min-width: 60px;
}
.text-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.button-row {
  display: flex;
  gap: 10px;
  margin-top: 7px;
}
#freeTextArea {
  width: 260px;
  font-size: 17px;
  border-radius: 4px;
  border: 1px solid #bbb;
  padding: 6px;
  resize: vertical;
  background: #fff;
  color: #222;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
body.dark #freeTextArea {
  background: #222;
  color: #eee;
  border: 1px solid #555;
}
