/* Draw & Survive — Editorial Sketchbook & Inspection Workbench UI */
#gameStageFrame {
  position: relative;
  background: #faf7f0 url('./assets/paper_texture.webp') center/cover no-repeat;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #18181b;
}

/* Mobile portrait friendly tall workbench instead of cramped 16:9 */
@media (max-width: 720px) and (orientation: portrait) {
  #gameStageFrame {
    aspect-ratio: auto !important;
    height: min(78vh, 660px) !important;
    min-height: 490px;
  }
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* Overlay Layer */
.ds-ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px;
  z-index: 12;
}

.ds-top-hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ds-pill-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #18181b;
  box-shadow: 2px 2px 0 #18181b;
  font-size: 12.5px;
  font-weight: 800;
  color: #18181b;
  letter-spacing: 0.01em;
}

.ds-badge-day {
  background: #fde047;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.ds-badge-day:hover { transform: translateY(-1px); }

.ds-badge-timer {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 14px;
  min-width: 68px;
  justify-content: center;
}
.ds-badge-timer.is-urgent {
  background: #fee2e2;
  color: #dc2626;
  border-color: #dc2626;
  animation: dsPulse 0.5s infinite alternate;
}
@keyframes dsPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.ds-ink-meter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #18181b;
  box-shadow: 2px 2px 0 #18181b;
  font-size: 11.5px;
  font-weight: 800;
}
.ds-ink-bar-bg {
  width: 78px;
  height: 10px;
  background: #e2e8f0;
  border: 1.5px solid #18181b;
  border-radius: 99px;
  overflow: hidden;
}
.ds-ink-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2563eb, #0f172a);
  transition: width 0.08s linear;
}
.ds-ink-bar-fill.is-low { background: #dc2626; }

/* Center prompt banner */
.ds-prompt-banner {
  align-self: center;
  margin-top: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.9);
  color: #faf7f0;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  text-align: center;
  max-width: 92%;
}

/* Bottom Action Dock */
.ds-bottom-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 2px solid #18181b;
  background: #ffffff;
  color: #18181b;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 2px 3px 0 #18181b;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s;
}
.ds-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 #18181b; }
.ds-btn:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 #18181b; }
.ds-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.ds-btn-primary {
  background: #2563eb;
  color: #ffffff;
  font-size: 14px;
  padding: 9px 20px;
}
.ds-btn-primary:hover { background: #1d4ed8; }

.ds-btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.ds-btn-active {
  background: #18181b;
  color: #fde047;
}

/* Start / Title Splash Card */
.ds-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 24, 27, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 25;
  pointer-events: auto;
}
.ds-modal-backdrop[hidden] { display: none; }

.ds-card {
  width: min(560px, 96%);
  max-height: 92%;
  overflow-y: auto;
  background: #faf7f0;
  border: 3px solid #18181b;
  border-radius: 16px;
  box-shadow: 6px 6px 0 #18181b;
  padding: 18px 20px;
  color: #18181b;
}

.ds-splash-hero {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #18181b;
  margin-bottom: 12px;
}

.ds-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.ds-title-row h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.ds-sub {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: #475569;
  line-height: 1.45;
}

/* Inspection Report Modal */
.ds-report-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 12px;
  margin: 10px 0 12px;
}
@media (max-width: 560px) {
  .ds-report-grid { grid-template-columns: 1fr; }
}

.ds-report-visual {
  position: relative;
  background: #ffffff;
  border: 2px solid #18181b;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.ds-report-visual canvas {
  width: 100%;
  height: 150px;
  display: block;
}

.ds-polaroid {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 96px;
  background: #fff;
  padding: 4px 4px 14px;
  border: 1.5px solid #94a3b8;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
  transform: rotate(6deg);
}
.ds-polaroid img {
  width: 100%;
  height: 58px;
  object-fit: cover;
  display: block;
}
.ds-polaroid span {
  display: block;
  font-size: 8.5px;
  font-weight: 800;
  color: #dc2626;
  text-align: center;
  margin-top: 2px;
  font-family: ui-monospace, monospace;
}

.ds-roast-box {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #faf7f0;
  border: 2px solid #18181b;
  border-radius: 10px;
  padding: 10px;
}
.ds-mascot-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  mix-blend-mode: multiply;
  flex-shrink: 0;
}
.ds-roast-text {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
  color: #18181b;
}

.ds-metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.ds-metric-cell {
  background: #fff;
  border: 2px solid #18181b;
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
}
.ds-metric-cell small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}
.ds-metric-cell strong {
  font-size: 16px;
  font-weight: 900;
}

.ds-stamp {
  display: inline-block;
  padding: 3px 10px;
  border: 3px solid #dc2626;
  color: #dc2626;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.06em;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transform: rotate(-6deg);
}
.ds-stamp.is-pass { border-color: #16a34a; color: #16a34a; }
.ds-stamp.is-cursed { border-color: #d97706; color: #d97706; background: #fef3c7; }

.ds-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

/* 30-Day Calendar Drawer */
.ds-cal-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
@media (max-width: 560px) {
  .ds-cal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ds-cal-cell {
  border: 2px solid #18181b;
  border-radius: 9px;
  background: #ffffff;
  color: #18181b;
  padding: 7px 4px;
  min-width: 0;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11.5px;
  font-weight: 800;
  transition: transform 0.1s;
}
.ds-cal-cell span {
  color: #18181b;
}
.ds-cal-cell:hover { transform: translateY(-2px); background: #fef9c3; }
.ds-cal-cell.is-current { background: #fde047; box-shadow: 2px 2px 0 #18181b; }
.ds-cal-cell.is-cleared { border-color: #16a34a; background: #dcfce7; }
.ds-cal-cell.is-cursed { border-color: #d97706; background: #fef3c7; }

/* Mobile Portrait Polished Workbench Layout */
@media (max-width: 600px) {
  .ds-ui-layer { padding: 8px 10px; }
  .ds-top-hud { gap: 5px; }
  .ds-pill-group { gap: 5px; }
  .ds-badge { padding: 4px 8px; font-size: 11px; border-radius: 7px; }
  #dsRigBadge { display: none; }
  .ds-badge-timer { font-size: 12px; min-width: 54px; }
  .ds-ink-meter { padding: 4px 7px; font-size: 10.5px; }
  .ds-ink-bar-bg { width: 52px; height: 8px; }
  .ds-prompt-banner { font-size: 11.5px; padding: 5px 11px; margin-top: 6px; }
  .ds-bottom-dock { flex-direction: column; align-items: stretch; gap: 6px; }
  .ds-bottom-dock .ds-pill-group { width: 100%; justify-content: space-between; }
  #dsDrawTools .ds-btn { flex: 1; padding: 7px 6px; font-size: 11.5px; }
  #dsBtnAction { width: 100%; padding: 10px 14px; font-size: 14px; }
  .ds-card { padding: 14px 14px; }
  .ds-title-row h2 { font-size: 17px; }
}

.ds-toast {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  background: #18181b;
  color: #fde047;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.ds-toast.is-show { opacity: 1; }
