* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-image: linear-gradient(white 60%,#e79b7d);
  background-attachment: fixed;
  color: #212529;
  line-height: 1.5;
}

header {
  background: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header_img {
  height: 48px;
  vertical-align: middle;
}

h1 {
  margin: 0.5rem 0 0;
  font-size: 1.8rem;
  color: #F06932;
}

main {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
}

.drawing-area {
  text-align: center;
}

canvas#draw {
  width: 320px;
  height: 320px;
  background: #000;
  border: 3px solid #343a40;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  cursor: crosshair;
  touch-action: none;
  margin: 0 auto;
  display: block;
}

.controls-and-result {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

#buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

button {
  padding: 0.8rem 1.8rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid #F06932;
  background: white;
  color: #F06932;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: #0d6efd;
  color: white;
  transform: translateY(-1px);
}

#result {
  background: #e7f1ff;
  border: 1px solid #F06932;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  min-height: 140px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.prediction {
  font-size: 4.5rem;
  margin: 0;
  font-weight: 800;
  color: #F06932;
  line-height: 1;
}

.confidence {
  font-size: 1.1rem;
  color: #495057;
  margin-top: 0.5rem;
}

canvas#probability {
  width: 100% !important;
  height: 260px !important;
  max-width: 420px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.history-area {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  border: 1px solid #e9ecef;
}

.history-area h3 {
  margin: 0 0 1rem;
  text-align: center;
  color: #495057;
}

#sample {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  max-height: 60dvh;
  overflow: scroll;
}

#sample > div {
  text-align: center;
}

#sample img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  transition: all 0.15s;
}

#sample img:hover {
  transform: scale(1.08);
  border-color: #0d6efd;
  box-shadow: 0 4px 12px rgba(13,110,253,0.2);
}

footer pre {
  margin: 0;
  padding: 1.5rem;
  background: #f1f3f5;
  border-radius: 12px;
  font-size: 0.95rem;
  color: #495057;
  white-space: pre-wrap;
}