/* Direction C — Unhinged Deli Counter */
:root {
  --bg-color: #1a1a2e;
  --text-color: #e8e8e8;
  --accent-color: #f4d03f;
  --wrong-color: #ff1744;
  --wrong-bg: rgba(255, 23, 68, 0.15);
  --input-bg: #2a2a4a;
  --input-border: #444;
  --input-focus: #f4d03f;
  --button-bg: #f4d03f;
  --button-text: #1a1a2e;
  --flash-color: rgba(255, 0, 0, 0.4);
  --font-display: 'Georgia', 'Times New Roman', serif;
  --font-body: 'Georgia', 'Times New Roman', serif;
}

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

body {
  background: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
}

h1 {
  font-family: var(--font-display);
  font-size: 72px;
  font-weight: 900;
  letter-spacing: 8px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f4d03f 0%, #d4a017 40%, #8b6914 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 36px;
  color: #888;
  margin-bottom: 32px;
  font-style: italic;
}

.sandwich-img {
  width: 200px;
  margin-bottom: 24px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.sandwich-icon {
  height: 100px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* Input area */
.input-area {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}

#sandwich-input {
  font-family: var(--font-display);
  font-size: 24px;
  padding: 12px 20px;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-color);
  width: 320px;
  outline: none;
  transition: border-color 0.2s;
}

#sandwich-input:focus {
  border-color: var(--input-focus);
}

#sandwich-input::placeholder {
  color: #666;
}

#order-btn {
  font-family: var(--font-display);
  font-size: 20px;
  padding: 12px 28px;
  background: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

#order-btn:hover {
  transform: scale(1.05);
}

#order-btn:active {
  transform: scale(0.95);
}

#order-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Status / processing messages */
#status {
  font-size: 18px;
  color: #888;
  min-height: 28px;
  margin-bottom: 16px;
  font-style: italic;
  transition: opacity 0.3s;
}

/* WRONG display */
#wrong-display {
  font-family: 'Impact', 'Arial Black', sans-serif;
  font-size: clamp(4rem, 18vw, 12rem);
  color: var(--wrong-color);
  text-transform: uppercase;
  letter-spacing: 8px;
  opacity: 0;
  transform: scale(0.3);
  transition: none;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 40px rgba(255, 23, 68, 0.6), 0 4px 8px rgba(0,0,0,0.5);
  user-select: none;
}

#wrong-display.slam {
  animation: wrongSlam 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes wrongSlam {
  0% {
    opacity: 0;
    transform: scale(4);
  }
  50% {
    opacity: 1;
    transform: scale(0.9);
  }
  70% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Screen shake */
.shake {
  animation: screenShake 0.6s ease-out;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  10% { transform: translate(-8px, 4px) rotate(-0.5deg); }
  20% { transform: translate(6px, -6px) rotate(0.5deg); }
  30% { transform: translate(-4px, 2px) rotate(-1deg); }
  40% { transform: translate(4px, -4px) rotate(1deg); }
  50% { transform: translate(-2px, 4px) rotate(-1deg); }
  60% { transform: translate(2px, -2px) rotate(1deg); }
  70% { transform: translate(-2px, 2px) rotate(-1deg); }
  80% { transform: translate(2px, -1px) rotate(0.5deg); }
  90% { transform: translate(-1px, 1px) rotate(-0.5deg); }
}

/* Red flash overlay */
#flash-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--flash-color);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}

#flash-overlay.flash {
  animation: redFlash 0.4s ease-out forwards;
}

@keyframes redFlash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Scoreboard */
.scoreboard {
  margin-top: 32px;
  font-size: 14px;
  color: #666;
  display: flex;
  gap: 24px;
}

.scoreboard span {
  color: var(--accent-color);
  font-weight: bold;
}

/* Escalation text */
#escalation {
  font-size: 16px;
  color: #cc8800;
  max-width: 500px;
  text-align: center;
  min-height: 24px;
  margin-top: 12px;
  font-style: italic;
}

/* Mute toggle */
#mute-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: none;
  border: 1px solid #444;
  color: #888;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

/* Progress bar (Phase 4 fake calm) */
#progress-container {
  width: 320px;
  height: 28px;
  background: #2a2a4a;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
  border: 1px solid #444;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  border-radius: 14px;
  transition: width 0.3s ease;
  position: relative;
}

#progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    rgba(255,255,255,0.1) 8px,
    rgba(255,255,255,0.1) 16px
  );
  animation: barberpole 0.6s linear infinite;
}

@keyframes barberpole {
  0% { background-position: 0 0; }
  100% { background-position: 22.6px 0; }
}

#progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Phase 5 lowercase collapse */
#wrong-display.lowercase {
  font-family: 'Georgia', serif;
  text-transform: none;
  letter-spacing: 0;
  color: #666;
  text-shadow: none;
}

/* Secret menu overlay */
#secret-menu-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  border: 2px solid #f4d03f;
  border-radius: 16px;
  padding: 32px;
  z-index: 300;
  text-align: center;
  color: #f4d03f;
  font-size: 18px;
  max-width: 400px;
  animation: fadeInOut 5s ease-in-out forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

/* Gold sparkle for secret menu items */
#wrong-display.gold {
  color: #f4d03f;
  text-shadow: 0 0 20px rgba(244, 208, 63, 0.8), 0 0 60px rgba(244, 208, 63, 0.4);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #wrong-display.slam {
    animation: none;
    opacity: 1;
    transform: scale(1);
  }
  .shake { animation: none; }
  #flash-overlay.flash { animation: none; opacity: 0; }
}

/* Recent submissions */
#recent-log {
  margin-top: 16px;
  width: 100%;
  max-width: 500px;
}

/* History button */
#history-btn {
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 14px;
  padding: 6px 16px;
  background: none;
  border: 1px solid #444;
  color: #888;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 2px;
}

#history-btn:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* History modal */
#history-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1e1e3a;
  border: 1px solid #444;
  border-radius: 12px;
  width: 400px;
  max-height: 60vh;
  flex-direction: column;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
  font-size: 16px;
  color: var(--accent-color);
}

#history-header button {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
}

#history-header button:hover {
  color: #fff;
}

#submission-log {
  overflow-y: auto;
  padding: 8px 16px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
}

.log-entry {
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid #2a2a4a;
  color: #888;
}

.log-num {
  color: #555;
  margin-right: 8px;
}

.log-name {
  color: var(--text-color);
}

.log-wrong {
  color: var(--wrong-color);
  font-weight: bold;
  margin-left: 8px;
}

.log-comment {
  color: #cc8800;
  font-style: italic;
}

/* Splash screen */
#splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#splash .sandwich img {
  max-width: 420px;
  margin-bottom: 32px;
}

#splash h1 {
  font-size: 72px;
  margin-bottom: 16px;
}

#play-btn {
  font-family: var(--font-display);
  font-size: 28px;
  padding: 16px 48px;
  background: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.1s;
  letter-spacing: 4px;
}

#play-btn:hover {
  transform: scale(1.08);
}

#play-btn:active {
  transform: scale(0.95);
}

.version-tag {
  margin-top: 24px;
  font-size: 12px;
  color: #444;
  letter-spacing: 1px;
}

/* Game screen */
#game {
  display: none;
}

/* Mobile */
@media (max-width: 600px) {
  body { justify-content: flex-start; padding: 24px 16px 0; }
  h1 { font-size: 28px; letter-spacing: 4px; }
  .subtitle { font-size: 16px; margin-bottom: 16px; }
  #splash { padding: 0 16px; }
  #splash .sandwich img { width: 55vw; max-width: 200px; margin-bottom: 16px; }
  #splash h1 { font-size: 32px; letter-spacing: 3px; margin-bottom: 8px; }
  #play-btn { font-size: 20px; padding: 12px 32px; letter-spacing: 2px; }
  .version-tag { font-size: 10px; margin-top: 12px; }
  .sandwich-icon { height: 60px; }
  .input-area { flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; }
  #sandwich-input { width: 85vw; max-width: 320px; font-size: 18px; padding: 10px 14px; }
  #order-btn { width: 85vw; max-width: 320px; font-size: 18px; }
  #wrong-display { font-size: clamp(3rem, 18vw, 6rem); min-height: 60px; letter-spacing: 4px; }
  #status { font-size: 15px; margin-bottom: 8px; }
  #escalation { font-size: 14px; max-width: 90vw; margin-bottom: 4px; }
  .scoreboard { font-size: 12px; gap: 12px; }
  #recent-log { margin-top: 8px; }
  #history-btn { margin-top: 8px; }
  #progress-container { width: 85vw; max-width: 320px; }
  #history-modal { width: 90vw; max-width: 400px; }
}
