@import url("https://fonts.googleapis.com/css2?family=Shadows+Into+Light&display=swap");

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

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Shadows Into Light", cursive;
  background: #2a2a2a;
  color: #fff;
  overflow: hidden;
}

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  z-index: 1000;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 28px 26px;
  border-radius: 10px;
  background: #2a2a2a;
  border: 1px solid #444;
  min-width: 280px;
}

.loading-card h2 {
  font-size: 1.3em;
}

.loading-card p {
  font-size: 0.9em;
  color: #aaa;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #444;
  border-top-color: #4a90e2;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.main-layout {
  display: flex;
  height: 100vh;
  gap: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.app-ready .main-layout {
  opacity: 1;
  pointer-events: auto;
}

body.app-ready .loading-screen {
  opacity: 0;
  visibility: hidden;
}

/* Canvas Section */
.canvas-section {
  flex: 1;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#drawingCanvas {
  display: block;
  cursor: crosshair;
  background-color: #000;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
  max-width: 100%;
  max-height: 100%;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #2a2a2a;
  padding: 25px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-left: 1px solid #444;
  overflow-y: auto;
}

.header {
  padding-bottom: 15px;
  border-bottom: 1px solid #444;
}

.header h1 {
  font-size: 2em;
  font-weight: 700;
  margin-bottom: 5px;
}

.subtitle {
  font-size: 1.15em;
  color: #aaa;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  padding: 11px 15px;
  border: none;
  border-radius: 6px;
  font-size: 1.15em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background-color: #4a90e2;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: #357abd;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-primary:disabled {
  background-color: #555;
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-secondary {
  background-color: #e74c3c;
  color: white;
}

.btn-secondary:hover {
  background-color: #c0392b;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* Result Box */
.result-box {
  background: #333;
  border: 1px solid #444;
  padding: 18px;
  border-radius: 6px;
  text-align: center;
  display: none;
  animation: slideIn 0.3s ease;
}

.result-box.show {
  display: block;
}

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

.result-label {
  font-size: 1em;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.result-box .digit {
  font-size: 3.2em;
  font-weight: bold;
  color: #4a90e2;
  margin: 12px 0 8px 0;
}

.result-box .confidence {
  font-size: 1.05em;
  color: #aaa;
}

.result-box .confidence span {
  color: #51cf66;
  font-weight: 600;
}

/* Status */
.status {
  background: #333;
  color: #aaa;
  padding: 10px;
  border-radius: 4px;
  font-size: 1.05em;
  text-align: center;
  min-height: 20px;
}

.status.loading {
  color: #4a90e2;
  font-weight: 600;
}

.status.error {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.status.success {
  color: #51cf66;
  background: rgba(81, 207, 102, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 200px;
    border-left: none;
    border-top: 1px solid #444;
    padding: 15px;
    gap: 12px;
  }

  .controls {
    flex-direction: row;
    gap: 8px;
  }

  .btn {
    flex: 1;
    padding: 9px 12px;
    font-size: 1em;
  }

  .result-box .digit {
    font-size: 2.2em;
  }
}
