/* ============================================
   HOTDOG OR NOT HOTDOG - Retro Diner Theme
   ============================================ */

/* --- Reset & Base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* --- CSS Variables (Design Tokens) --- */
:root {
  /* Diner Theme Colors - Inspired by modern retro aesthetic */
  --diner-terracotta: #d4644a;
  --diner-terracotta-dark: #b85440;
  --diner-navy: #1e3a5f;
  --diner-navy-light: #2a4d7a;
  --diner-navy-rgb: 30, 58, 95;
  --diner-mustard: #e8a838;
  --diner-mustard-light: #f0b848;
  --diner-mustard-dark: #c98e2e;
  --diner-cream: #f5f0e6;
  --diner-cream-dark: #e8e0d0;
  --diner-green: #4a7c59;
  --diner-green-dark: #3a6347;
  --diner-white: #ffffff;
  --diner-white-rgb: 255, 255, 255;
  --diner-black-rgb: 0, 0, 0;

  /* Semantic Colors */
  --color-bg-primary: var(--diner-terracotta);
  --color-bg-secondary: var(--diner-cream);
  --color-text-primary: var(--diner-navy);
  --color-text-muted: var(--diner-navy-light);
  --color-accent: var(--diner-mustard);
  --color-accent-hover: var(--diner-mustard-dark);
  --color-success: #4ade80;
  --color-error: #ef4444;
  --color-loading: #f59e0b;
  --color-easter: #7b68ee;
  --color-border: var(--diner-navy);
  --color-white: var(--diner-white);
  --color-black: var(--diner-navy);

  /* Dispenser Hardware - Warm Diner Style */
  --dispenser-body: var(--diner-mustard);
  --dispenser-body-light: var(--diner-mustard-light);
  --dispenser-body-dark: var(--diner-mustard-dark);
  --dispenser-slot: var(--diner-navy);
  --dispenser-slot-rgb: var(--diner-navy-rgb);
  --dispenser-height: 70px;
  --slot-height: 10px;
  --slot-inset: 24px;
  --slot-overlap: 8px;
  --slot-lip: 4px;

  /* Dot-Matrix Display - Warm Retro Style */
  --dot-matrix-text: var(--diner-navy);
  --dot-matrix-success: var(--diner-green-dark);
  --dot-matrix-error: var(--diner-terracotta-dark);
  --dot-matrix-bg: #fdf8e8;

  /* Paper Surfaces */
  --paper-receipt: #fffef9;
  --paper-canvas: #ffffff;

  /* Typography */
  --font-display: 'Pacifico', cursive;
  --font-sans: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Courier New', 'SF Mono', 'Monaco', monospace;

  /* Spacing Scale (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Borders */
  --border-width: 2px;
  --border-light: 1px solid var(--color-border);
  --border-medium: 2px solid var(--color-border);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;

  /* Focus Ring */
  --focus-ring: 2px solid var(--diner-mustard);
  --focus-ring-offset: 2px;

  /* Color Palette - Drawing Colors (hotdog-friendly!) */
  --palette-red: #c41e3a;
  --palette-orange: #ff851b;
  --palette-yellow: #ffdc00;
  --palette-green: #2ecc40;
  --palette-blue: #0074d9;
  --palette-purple: #b10dc9;
  --palette-black: #2c1810;
  --palette-white: #ffffff;
}

/* --- Layout --- */
body {
  font-family: var(--font-sans);
  background-color: var(--diner-terracotta);
  /* Navy grid lines on terracotta tiles */
  background-image:
    linear-gradient(var(--diner-navy) 1px, transparent 1px),
    linear-gradient(90deg, var(--diner-navy) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--diner-navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Text rendering optimizations for Retina displays */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* App-like behavior: disable zoom and text selection */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  margin-top: 24px;
  padding: var(--space-5);
  padding-top: var(--space-6);
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--diner-cream);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: relative;
}

/* Scalloped top edge */
.container::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: radial-gradient(circle at 50% 100%, var(--diner-cream) 70%, transparent 70%);
  background-size: 24px 20px;
  background-position: center 0;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
}

.header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  text-align: center;
  color: var(--diner-navy);
  letter-spacing: 0.02em;
}

/* --- Game Area --- */
.game-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  flex: 1;
}

/* --- Receipt Printer Result --- */
.receipt-area {
  position: relative;
  isolation: isolate; /* Creates stacking context for z-index to work properly */
  width: 100%;
  max-width: 280px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Slot lip overlay so paper appears to emerge from the hole */
.receipt-area::after {
  content: '';
  position: absolute;
  left: calc(var(--slot-inset) + 5px);
  right: calc(var(--slot-inset) + 5px);
  height: calc(var(--slot-lip) + 1px);
  top: calc(var(--dispenser-height) - var(--slot-overlap) + 6px);
  background: linear-gradient(
    180deg,
    rgba(var(--dispenser-slot-rgb), 0.4) 0%,
    rgba(var(--dispenser-slot-rgb), 0) 100%
  );
  border-radius: 2px;
  z-index: 4;
  pointer-events: none;
}

/* Dispenser Housing - Warm diner ticket machine */
.receipt-dispenser {
  position: relative;
  width: 100%;
  height: var(--dispenser-height);
  background: linear-gradient(
    180deg,
    var(--dispenser-body-light) 0%,
    var(--dispenser-body) 50%,
    var(--dispenser-body-dark) 100%
  );
  border: 3px solid var(--diner-navy);
  border-radius: 20px 20px 16px 16px;
  box-shadow:
    4px 4px 0 var(--diner-navy),
    inset 0 2px 4px rgba(var(--diner-white-rgb), 0.3);
  z-index: 2;
}

/* Front plate detail - hidden for cleaner look */
.receipt-dispenser::before {
  display: none;
}

/* Dispenser slot (paper exit) */
.receipt-dispenser::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: var(--slot-inset);
  right: var(--slot-inset);
  height: var(--slot-height);
  background: var(--dispenser-slot);
  border-radius: 4px;
  box-shadow: inset 0 2px 3px rgba(var(--diner-black-rgb), 0.3);
}

/* Status indicator dot - friendly circle */
.dispenser-led {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  background: var(--diner-cream);
  border: 2px solid var(--diner-navy);
  border-radius: 50%;
  z-index: 3;
}

/* LED: Waiting/Cooking - terracotta pulse */
.dispenser-led.waiting {
  background: var(--diner-terracotta);
  border-color: var(--diner-terracotta-dark);
  animation: ledPulse 1s ease-in-out infinite;
}

/* LED: Success (Hotdog!) - green solid */
.dispenser-led.success {
  background: var(--diner-green);
  border-color: var(--diner-green-dark);
}

/* LED: Fail/Error states - terracotta */
.dispenser-led.fail,
.dispenser-led.error {
  background: var(--diner-terracotta);
  border-color: var(--diner-terracotta-dark);
}

/* LED: Error (connection) - add flash animation */
.dispenser-led.error {
  animation: ledFlash 0.3s ease-in-out infinite;
}

@keyframes ledPulse {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

@keyframes ledFlash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ================================================
   RETRO DISPLAY - Warm Diner Style
   ================================================ */

/* Display container - cream background with navy text */
.dot-matrix-display {
  position: absolute;
  top: 12px;
  left: 28px;
  right: 28px;
  height: 30px;
  background: var(--dot-matrix-bg);
  border: 2px solid var(--diner-navy);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* Subtle inset */
  box-shadow: inset 0 1px 3px rgba(var(--diner-black-rgb), 0.15);
  z-index: 2;
}

/* Display text styling */
.dot-matrix-text {
  font-family: 'VT323', monospace;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  /* Default navy color (cooking state) */
  color: var(--dot-matrix-text);
  text-shadow: none;
}

/* State-based colors */
.dot-matrix-display.success .dot-matrix-text {
  color: var(--dot-matrix-success);
}

.dot-matrix-display.fail .dot-matrix-text,
.dot-matrix-display.error .dot-matrix-text {
  color: var(--dot-matrix-error);
}

/* Subtle paper texture hint */
.dot-matrix-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(var(--diner-navy-rgb), 0.02) 2px,
    rgba(var(--diner-navy-rgb), 0.02) 4px
  );
  pointer-events: none;
  border-radius: var(--radius-md);
}

/* Paper container - positioned to emerge from dispenser slot */
.receipt-paper-container {
  position: absolute; /* Remove from flow - overlays instead of pushing */
  top: calc(var(--dispenser-height) - var(--slot-overlap) + 3px);
  left: calc(var(--slot-inset) + 3px); /* Account for border + slot inset */
  right: calc(var(--slot-inset) + 3px);
  overflow: hidden; /* CRITICAL: clip boundary */
  z-index: 3;
}

.receipt {
  position: relative;
  background: var(--paper-receipt);
  color: var(--diner-navy);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: var(--space-4);
  padding-top: var(--space-5);
  padding-bottom: var(--space-6);
  text-align: center;
  border: none;
  border-radius: 0;
  /* Torn paper edge - defined in index.html SVG for maintainability */
  clip-path: url(#receipt-torn);
  box-shadow: none;
  /* Hidden by default - above container, clipped by overflow:hidden */
  transform: translateY(-100%);
}

/* Torn edge at top of receipt */
.receipt::before {
  display: none;
}

.receipt-area.show .receipt {
  animation: receiptPrint 0.8s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.receipt-area.hide .receipt {
  animation: receiptFall 0.5s ease-in forwards;
}

@keyframes receiptPrint {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes receiptFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(120%) rotate(3deg);
    opacity: 0;
  }
}

.receipt-header {
  margin-bottom: var(--space-2);
}

.receipt-logo {
  font-size: 2rem;
  margin-bottom: var(--space-1);
}

.receipt-title {
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.1em;
}

.receipt-subtitle {
  font-size: 0.7rem;
  color: var(--diner-navy-light);
}

.receipt-divider {
  color: var(--diner-navy-light);
  margin: var(--space-2) 0;
  letter-spacing: -0.05em;
}

.receipt-body {
  margin: var(--space-3) 0;
}

.receipt-label {
  font-size: 0.75rem;
  color: var(--diner-navy-light);
  margin-bottom: var(--space-2);
}

.receipt-verdict {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  padding: var(--space-2) 0;
}

.receipt-verdict.success {
  color: var(--color-success);
}

.receipt-verdict.error {
  color: var(--color-error);
}

.receipt-verdict.easter {
  color: var(--color-easter);
}

.receipt-verdict.loading {
  color: var(--diner-navy-light);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.receipt-footer {
  margin-top: var(--space-2);
}

.receipt-date {
  font-size: 0.65rem;
  color: var(--diner-navy-light);
  margin-bottom: var(--space-1);
}

.receipt-thanks {
  font-size: 0.8rem;
  font-weight: bold;
}

.receipt-tear {
  position: absolute;
  bottom: -10px;
  left: 0;
  right: 0;
  height: 10px;
  background:
    linear-gradient(135deg, var(--paper-receipt) 33.33%, transparent 33.33%),
    linear-gradient(225deg, var(--paper-receipt) 33.33%, transparent 33.33%);
  background-size: 8px 10px;
  background-position: 0 0;
}

/* Legacy result area - visually hidden but accessible */
.result-area {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity var(--transition-base),
    visibility var(--transition-base);
}

.result-area.show {
  visibility: visible;
  opacity: 1;
}

.result-area p {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.result-area .analyzing {
  color: var(--color-loading);
}

/* --- Canvas Container (Paper) --- */
.canvas-container {
  position: relative;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 5/4;
  padding: 8px;
  background: var(--diner-cream-dark);
  border: 3px solid var(--diner-navy);
  border-radius: var(--radius-lg);
  /* Hard offset shadow */
  box-shadow: 4px 4px 0 var(--diner-navy);
}

/* Inner paper area */
.canvas-container::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: var(--paper-canvas);
  border-radius: var(--radius-md);
  z-index: 0;
}

#drawingCanvas,
#overlayCanvas {
  position: absolute;
  top: 8px;
  left: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  border-radius: var(--radius-md);
  touch-action: none;
  z-index: 1;
}

#drawingCanvas {
  background: var(--paper-canvas);
  border: none;
}

#overlayCanvas {
  cursor: crosshair;
  /* Overlay is transparent, receives pointer events */
}

#overlayCanvas:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* --- Controls --- */
.controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Tool & Width Selection - Flat Pill Style */
.tool-selection,
.width-selection {
  display: flex;
  gap: var(--space-2);
  background: var(--diner-cream-dark);
  padding: var(--space-2);
  border: 2px solid var(--diner-navy);
  border-radius: 999px;
}

.tool-button,
.width-button {
  width: 40px;
  height: 40px;
  background: var(--diner-cream);
  border: 2px solid var(--diner-navy);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--diner-navy);
  transition: all var(--transition-fast);
}

.tool-button:hover,
.width-button:hover {
  background: var(--diner-cream-dark);
}

.tool-button:focus-visible,
.width-button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.tool-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-button[aria-pressed='true'],
.width-button[aria-pressed='true'] {
  background: var(--diner-terracotta);
  color: var(--diner-white);
  border-color: var(--diner-navy);
}

.width-preview {
  background: currentColor;
  border-radius: 50%;
  display: block;
}

.width-preview--small {
  width: 5px;
  height: 5px;
}

.width-preview--medium {
  width: 10px;
  height: 10px;
}

.width-preview--large {
  width: 20px;
  height: 20px;
}

/* Color Palette - Flat Style */
.color-palette {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
  background: var(--diner-cream-dark);
  padding: var(--space-2);
  border: 2px solid var(--diner-navy);
  border-radius: 999px;
}

.color-box {
  width: 28px;
  height: 28px;
  border: 2px solid var(--diner-navy);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.color-box:hover {
  transform: scale(1.1);
}

.color-box:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.color-box[aria-pressed='true'] {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--diner-navy);
}

/* Color box backgrounds - flat colors */
.color-box[data-color='red'] {
  background: var(--palette-red);
}
.color-box[data-color='orange'] {
  background: var(--palette-orange);
}
.color-box[data-color='yellow'] {
  background: var(--palette-yellow);
}
.color-box[data-color='green'] {
  background: var(--palette-green);
}
.color-box[data-color='blue'] {
  background: var(--palette-blue);
}
.color-box[data-color='purple'] {
  background: var(--palette-purple);
}
.color-box[data-color='black'] {
  background: var(--palette-black);
}
.color-box[data-color='white'] {
  background: var(--palette-white);
}

/* Analyze Button - Mustard Pill Style */
.analyze-button {
  padding: var(--space-3) var(--space-6);
  background: var(--diner-mustard);
  color: var(--diner-navy);
  border: 3px solid var(--diner-navy);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 4px 4px 0 var(--diner-navy);
}

.analyze-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--diner-navy);
}

.analyze-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--diner-navy);
}

.analyze-button:focus-visible {
  outline: 3px solid var(--diner-terracotta);
  outline-offset: 3px;
}

.analyze-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 4px 4px 0 var(--diner-navy);
}

/* --- Keyboard Shortcuts Hint (Screen Reader Only) --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Accessibility: Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .result-area {
    transition: none;
  }

  /* Disable hover transforms */
  .color-box:hover,
  .color-box[aria-pressed='true'],
  .analyze-button:hover,
  .analyze-button:active {
    transform: none;
  }

  /* Show receipt immediately without animation */
  .receipt-area.show .receipt {
    animation: none;
    transform: translateY(0);
    opacity: 1;
  }

  .receipt-area.hide .receipt {
    animation: none;
    transform: translateY(120%) rotate(3deg);
    opacity: 0;
  }

  /* Disable loading pulse */
  .receipt-verdict.loading {
    animation: none;
  }
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .container {
    padding: var(--space-3);
    margin-top: 16px;
  }

  .container::before {
    top: -16px;
    height: 16px;
    background-size: 20px 16px;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  /* Receipt adjusts for mobile */
  .receipt-area {
    max-width: 240px;
    --dispenser-height: 56px;
    --slot-height: 10px;
    --slot-inset: 20px;
    --slot-overlap: 6px;
    --slot-lip: 3px;
  }

  .receipt-dispenser {
    height: var(--dispenser-height);
    border-radius: 16px 16px 12px 12px;
  }

  .dispenser-led {
    right: 8px;
    width: 8px;
    height: 8px;
  }

  .dot-matrix-display {
    top: 10px;
    left: 24px;
    right: 24px;
    height: 24px;
    padding: var(--space-1) var(--space-1);
  }

  .dot-matrix-text {
    font-size: 13px;
    letter-spacing: 1px;
  }

  .receipt-paper-container {
    top: calc(var(--dispenser-height) - var(--slot-overlap) + 3px);
    left: calc(var(--slot-inset) + 3px);
    right: calc(var(--slot-inset) + 3px);
  }

  .receipt {
    font-size: 0.7rem;
    padding: var(--space-3);
    padding-top: var(--space-4);
  }

  .receipt-verdict {
    font-size: 1.1rem;
  }

  .receipt-logo {
    font-size: 1.5rem;
  }

  .receipt-title {
    font-size: 0.95rem;
  }

  /* Receipt overlay on mobile - just ensure it's above canvas */
  .receipt-area.show {
    z-index: 10;
  }

  /* Dim and disable canvas when receipt is showing */
  .game-area.result-showing .canvas-container {
    opacity: 0.3;
    pointer-events: none;
  }

  /* Disable draw tools when receipt is showing */
  .game-area.result-showing .tool-selection,
  .game-area.result-showing .width-selection,
  .game-area.result-showing .color-palette {
    opacity: 0.4;
    pointer-events: none;
  }

  /* Fit tools and brush sizes in one row on mobile */
  .controls-row {
    justify-content: center;
  }

  .tool-selection,
  .width-selection {
    padding: var(--space-1);
    gap: var(--space-1);
  }

  /* Canvas container adjustments */
  .canvas-container {
    padding: 8px;
  }

  #drawingCanvas,
  #overlayCanvas {
    top: 8px;
    left: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
  }

  .controls {
    gap: var(--space-3);
  }

  .controls-row {
    justify-content: center;
    gap: var(--space-2);
  }

  /* Touch targets: minimum 44px for accessibility */
  .tool-button,
  .width-button {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .color-box {
    width: 32px;
    height: 32px;
  }

  .analyze-button {
    width: 100%;
    min-height: 50px;
    margin-top: var(--space-2);
    font-size: 1.1rem;
  }
}

/* Small mobile screens */
@media (max-width: 360px) {
  .header h1 {
    font-size: 1.1rem;
  }

  .tool-selection,
  .width-selection {
    padding: var(--space-1);
    gap: var(--space-1);
  }

  .tool-button,
  .width-button {
    width: 40px;
    height: 40px;
  }

  .color-box {
    width: 34px;
    height: 34px;
  }

  .color-palette {
    padding: var(--space-1);
    gap: var(--space-1);
  }
}

/* --- High Contrast Mode Support --- */
@media (prefers-contrast: high) {
  :root {
    --diner-terracotta: #cc0000;
    --diner-navy: #000000;
    --diner-mustard: #ffcc00;
    --diner-cream: #ffffff;
    --diner-green: #006600;
    --diner-green-dark: #004400;
    --diner-loading: #ff9900;
    --focus-ring: 3px solid var(--diner-navy);
  }

  .tool-button,
  .width-button,
  .color-box {
    border-width: 3px;
    border-color: var(--diner-navy);
  }

  .analyze-button {
    border-width: 3px;
  }

  .receipt-dispenser {
    background: var(--diner-mustard);
    border-color: var(--diner-navy);
    box-shadow: none;
  }

  .receipt-dispenser::before {
    display: none;
  }

  .dot-matrix-display {
    background: var(--diner-cream);
    border-color: var(--diner-navy);
  }

  .dispenser-led {
    background: var(--diner-cream);
    border: 2px solid var(--diner-navy);
  }

  .dispenser-led.waiting {
    background: var(--diner-loading);
    animation: none;
  }

  .dispenser-led.success {
    background: var(--diner-green);
  }

  .dispenser-led.fail,
  .dispenser-led.error {
    background: var(--diner-terracotta);
    animation: none;
  }

  .receipt {
    border: 2px solid var(--diner-navy);
    box-shadow: none;
  }

  .receipt-verdict.success {
    color: var(--diner-green);
  }

  .receipt-verdict.error {
    color: var(--diner-terracotta);
  }
}

/* --- Desktop Layout: Receipt on Right --- */
@media (min-width: 900px) {
  .container {
    max-width: 880px;
  }

  .game-area {
    display: grid;
    grid-template-columns: 520px 280px;
    grid-template-areas:
      'canvas receipt'
      'controls receipt';
    gap: var(--space-6);
    align-items: start;
    justify-content: space-between;
  }

  .canvas-container {
    grid-area: canvas;
    max-width: none;
    width: 100%;
  }

  .controls {
    grid-area: controls;
    max-width: 520px;
    width: 100%;
    margin-top: 0;
    align-items: stretch;
  }

  /* Compact controls layout on desktop */
  .controls-row {
    justify-content: center;
  }

  .analyze-button {
    width: 100%;
    max-width: 520px;
  }

  .receipt-area {
    grid-area: receipt;
    align-self: start;
    margin-top: 0;
  }
}
