@import url('https://fonts.googleapis.com/css2?family=Nova+Flat&display=swap');

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
  Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background: #16213e;
  color: #fff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dropzone {
  border: 2px dashed #007bff;
  padding: 1rem;
  background: #e9f5ff;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1rem;
  user-select: none;
}

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  justify-content: flex-start;
}

.controls label {
  display: flex;
  flex-direction: column;
  font-size: .95rem;
  min-width: 120px;
}

input, select, button {
  padding: .4rem;
  font-size: 1rem;
  user-select: none;
}

.btn-group {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-right: auto;
}

.file-download-group {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 280px;
  flex-wrap: wrap;
}

.file-download-group input[type='text'] {
  flex: 1 1 auto;
  padding: .4rem;
  font-size: 1rem;
}

.file-download-group button {
  padding: .4rem 1rem;
  font-weight: bold;
  font-size: 1rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.file-download-group select {
  padding: .4rem;
  font-size: 1rem;
  user-select: none;
  margin-left: 1rem;
}

.panels {
  display: flex;
  gap: 1rem;
}

.panel {
  background: white;
  border: 2px dashed #ccc;
  padding: 1rem;
  flex: 1;
  min-height: 300px;
  position: relative;
}

canvas, img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: auto;
  user-select: none;
}

#canvasWrapper {
  position: relative;
  display: inline-block;
}

#cropRect {
  position: absolute;
  border: 2px dashed #f60;
  background: rgba(255, 102, 0, .2);
  cursor: move;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
}

.handle {
  width: 12px;
  height: 12px;
  background: #f60;
  border: 1px solid #fff;
  position: absolute;
  box-sizing: border-box;
  user-select: none;
}

.handle.nw {
  top: -7px;
  left: -7px;
  cursor: nwse-resize;
}

.handle.ne {
  top: -7px;
  right: -7px;
  cursor: nesw-resize;
}

.handle.sw {
  bottom: -7px;
  left: -7px;
  cursor: nesw-resize;
}

.handle.se {
  bottom: -7px;
  right: -7px;
  cursor: nwse-resize;
}

/* Crop size label */
#cropSize {
  position: absolute;
  bottom: -24px;
  left: 0;
  background: #f60;
  color: white;
  padding: 2px 6px;
  font-size: .85rem;
  font-weight: bold;
  border-radius: 4px;
  user-select: none;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-group {
    margin-right: 0;
    justify-content: flex-start;
    margin-bottom: .5rem;
  }

  .file-download-group {
    flex-direction: column;
    align-items: stretch;
  }

  .file-download-group select {
    margin-left: 0;
    margin-top: .5rem;
  }

  .file-download-group button {
    width: 100%;
    margin-top: .5rem;
  }

  .panels {
    flex-direction: column;
  }

  .panel {
    min-height: 250px;
  }
}

/* Header */
header {
  background: #1a1a2e;
  border-bottom: 1px solid #3a3a5e;
  padding: 12px 24px;
  text-align: center;
}

header a {
  font-family: 'Nova Flat', cursive;
  font-size: 22px;
  color: #ffd700;
  text-decoration: none;
}

/* Main content */
main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 3rem;
  padding: 3rem 1rem;
  background: white;
  color: #000;
  border-radius: 16px;
  border: 1px solid #3a3a5e;
  box-shadow: 0 8px 24px rgb(0 71 171 / .15);
}

header a {
  font-family: 'Nova Flat', cursive;
  font-size: 22px;
  color: #ffd700;
  text-decoration: none;
}

main h1 {
  /* Standard font here */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
  Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  font-size: 28px;
  margin-bottom: 1rem;
  text-align: center;
  color: #0047ab;
}

header a:hover {
  text-decoration: none;
}

p {
  font-size: 20px;
  text-align: center;
}

/* Footer */
footer {
  background: #1a1a2e;
  border-top: 1px solid #3a3a5e;
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
  Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

footer .left a, footer .right a {
  color: #0dcaf0;
  text-decoration: none;
  margin: 0 .6rem;
}

footer .left a:hover, footer .right a:hover {
  text-decoration: none;
}

footer .left {
  flex: 1 1 40%;
  text-align: left;
}

footer .right {
  flex: 1 1 50%;
  text-align: right;
}

@media (max-width: 1240px) {
  main {
    flex: 1;
    max-width: 1100px;
  }
}

@media (max-width: 1120px) {
  main {
    flex: 1;
    max-width: 950px;
  }
}

@media (max-width: 1000px) {
  main {
    flex: 1;
    max-width: 850px;
  }
}

@media (max-width: 880px) {
  main {
    flex: 1;
    max-width: 700px;
  }
}

@media (max-width: 740px) {
  main {
    flex: 1;
    max-width: 500px;
  }
}

@media (max-width: 530px) {
  main {
    flex: 1;
    max-width: 400px;
  }
}

@media (max-width: 450px) {
  main {
    flex: 1;
    max-width: 370px;
  }
}

@media (max-width: 480px) {
  header a {
    font-size: 22px;
  }
}

/* Responsive */
@media (max-width: 480px) {
  footer {
    flex-direction: column;
    gap: .5rem;
    font-size: 13px;
    text-align: center;
  }

  footer .left, footer .right {
    flex: unset;
    text-align: center;
  }

  footer .right a {
    margin: 0 .4rem;
  }
}
