/* =========================================================
   Crop Game v1
   - Keep styling simple and readable
   - Build foundation first, polish later
   ========================================================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  color: #111;
}

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.header p {
  margin: 0;
  color: #555;
}

.game-shell {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 20px;
}

.image-stage {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid #ccc;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
  touch-action: none;
}

.image-stage img {
  display: block;
  width: 100%;
  height: auto;
}

/* =========================================================
   Fixed crop box for v1
   - Positioned absolutely over the image
   - We will make this draggable next
   ========================================================= */
.crop-box {
  position: absolute;
  left: 25%;
  top: 20%;
  width: 40%;
  height: 40%;
  border: 3px solid #00c853;
  background: rgba(0, 200, 83, 0.12);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  right: -8px;
  bottom: -8px;
  background: #00c853;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: nwse-resize;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  -webkit-user-select: none;
  touch-action: none;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.controls button {
  padding: 10px 18px;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
}

.controls button:hover {
  background: #f0f0f0;
}

.controls button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.results {
  margin-top: 18px;
  text-align: center;
  color: #444;
}

.level-info {
  margin-top: 14px;
  text-align: center;
  color: #666;
  font-size: 0.95rem;
}

.powered-by {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: #777;
}

.powered-by a {
  color: inherit;
  text-decoration: none;
}

.powered-by a:hover {
  text-decoration: underline;
}

.ideal-crop-box {
  position: absolute;
  border: 3px dashed #ff9800;
  background: rgba(255, 152, 0, 0.12);
  pointer-events: none;
}

.crop-box.locked {
  cursor: default;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.action-button {
  padding: 10px 18px;
  border: 1px solid #bbb;
  border-radius: 999px;
  background: #fff;
  color: #222;
  cursor: pointer;
  font-size: 0.95rem;
}

.action-button.primary {
  border-color: #1f6feb;
  background: #1f6feb;
  color: #fff;
}

.preview-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
}

.preview-card {
  width: min(92vw, 980px);
  max-height: 92vh;
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.preview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.preview-card-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.preview-close {
  padding: 8px 14px;
  border: 1px solid #bbb;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.preview-frame {
  position: relative;
  width: 100%;
  max-height: calc(92vh - 110px);
  overflow: hidden;
  border-radius: 12px;
  background: #111;
}

.preview-frame img {
  position: absolute;
  max-width: none;
}

@media (max-width: 640px) {
  .controls {
    flex-wrap: wrap;
  }

  .preview-card {
    padding: 14px;
  }

  .preview-card-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

.hidden {
  display: none;
}
